#include #include #include #include #include #include #include #include #include #include using namespace std; int N, nr, pos[109][109], b[109 * 109]; int main() { //freopen ("input", "r", stdin); //freopen ("output", "w", stdout); scanf ("%d", &N); for (int i=1; i<=N * N; i++) scanf ("%d", &b[i]); sort (b + 1, b + N * N + 1); reverse (b + 1, b + N * N + 1); for (int i=1; i<=N; i++) pos[i][i] = b[++nr]; for (int i=1; i<=N; i++) for (int j=1; j<=N; j++) if (i != j) pos[i][j] = b[++nr]; for (int i=1; i<=N; i++, printf ("\n")) for (int j=1; j<=N; j++) printf ("%d ", pos[i][j]); return 0; }