#include <iostream>
#include <algorithm>
using namespace std;

const int DIM = 101;
int n, a[DIM * DIM], c[DIM][DIM];
int d[DIM];

int main()
{
    cin >> n;
    for ( int i = 1; i <= n * n; i++ )
        cin >> a[i];
    sort (a + 1, a + n * n + 1);
    for (int i = n * n, j = 1; i > 0; i--, j++ )
        d[j] = a[i];
    int q = 1, p = 1;
    for ( int i = 1; i <= n; i++ )
        for ( int j = 1; j <= n; j++ )
            if ( i == j )
                c[i][j] = d[p++];
            else
                c[i][j] = a[q++];
    for ( int i = 1; i <= n; i++ )
    {
        for ( int j = 1; j <= n; j++ )
            cout << c[i][j] << ' ';
        cout << '\n';
    }
    return 0;
}