#include #define pii pair #define pb push_back #define mp make_pair #define ll long long using namespace std; int A[110][110], a[100000], i, j, l, n, N; int main() { cin >> n; N = n * n; for(i = 1; i <= N; i++) cin >> a[i]; sort(a + 1, a + N + 1); for(i = 1, l = N; i <= n; i++) A[i][i] = a[l--]; for(i = 1; i <= n; i++) { for(j = 1; j <= n; j++) { if(i != j) A[i][j] = a[l--]; cout << A[i][j] << ' '; } cout << '\n'; } return 0; }