#include <stdio.h> #include <string> #include <iostream> #include <algorithm> #include <cstdlib> #include <fstream> #include <vector> #include <iomanip> #include <map> #include <sstream> #include <iterator> #include <set> #include <queue> #include <cstring> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef pair<int, int> ii; int main() { //freopen("C:\\in.txt","r",stdin); // freopen("C:\\out.txt", "w", stdout); int n; scanf("%d", &n); int all = n*n; vector<int> v; int x; while(all--){ scanf("%d",&x); v.push_back(x); } int mat[111][111]; sort(v.rbegin(), v.rend()); for(int i=0; i<n; ++i){ mat[i][i] = v[i]; } int curr = n; for(int i=0; i<n; ++i){ for(int j=0; j<n; ++j){ if(i!=j){ mat[i][j] = v[curr]; curr++; } } } for(int i=0; i<n; ++i){ for(int j=0; j<n; ++j){ if(j!=0) printf(" "); printf("%d", mat[i][j]); } printf("\n"); } return 0; }