#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define mp make_pair #define pb push_back #define ff first #define ss second #define int64 unsigned long long int a[105*105]; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; for(int i = 1; i <= n*n; i++) cin >> a[i]; sort(a+1,a+n*n+1); int r = n*n; int l = 1; for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ if(i == j){ cout << a[r]; r--; } else{ cout << a[l]; l++; } cout << " "; } cout << "\n"; } }