import java.io.*; import java.util.*; public class prog { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; void solve() throws IOException { int n = nextInt(); int[] a = new int[n * n]; for (int i = 0; i < n * n; i++) { a[i] = nextInt(); } int[][] b = new int[n][n]; Arrays.sort(a); int ptr = n * n - 1; for (int i = 0; i < n; i++) { b[i][i] = a[ptr--]; } for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { if (i != j) { b[i][j] = a[ptr--]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { out.print(b[i][j] + " " ); } out.println(); } } prog() throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); } public static void main(String[] args) throws IOException { new prog(); } String nextToken() { while (st == null || !st.hasMoreTokens()) { try { st = new StringTokenizer(br.readLine()); } catch (Exception e) { eof = true; return null; } } return st.nextToken(); } String nextString() { try { return br.readLine(); } catch (IOException e) { eof = true; return null; } } int nextInt() throws IOException { return Integer.parseInt(nextToken()); } long nextLong() throws IOException { return Long.parseLong(nextToken()); } double nextDouble() throws IOException { return Double.parseDouble(nextToken()); } }