#include #include using namespace std; const int MAX_N = 105; int main() { int n; int v[MAX_N * MAX_N]; cin >> n; for (int i = 1; i <= n * n; i += 1) { cin >> v[i]; } sort(v + 1, v + n * n + 1, greater()); int ind = n + 1; for (int i = 1; i <= n; i += 1) { for (int j = 1; j <= n; j += 1) { if (i == j) { cout << v[i] << ' '; } else { cout << v[ind] << ' '; ind += 1; } } cout << '\n'; } return 0; }