#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

vector <int> s;
vector <int>::iterator it;

int main(){
	int n, nr;
	int a[105][105];
	//freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i = 0; i < n * n; ++i){
		cin >> nr;
		s.push_back(nr);
	}

	sort(s.begin(), s.end());
	it = s.end();
	--it;
	for(int i = 0; i < n; ++i){
		a[i][i] = *it;
		--it;
	}
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			if(i == j)
				continue;
			a[i][j] = *it;
			--it;
		}
	}
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j)
			cout << a[i][j] << " ";
		cout << '\n';
	}
}