Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.

For example, the following matrices are palindromic: $\left[ \begin{array}{l l l}{1} & {3} & {1} \\{3} & {1} & {3} \\{1} & {3} & {1} \end{array} \right] \quad \left[ \begin{array}{l l l l}{1} & {2} & {2} & {1} \\{8} & {2} & {2} & {8} \\{8} & {2} & {2} & {8} \\{1} & {2} & {2} & {1} \end{array} \right]$ 

The following matrices are not palindromic because they change after the order of rows is reversed: $\left[ \begin{array}{l l l}{1} & {3} & {1} \\{3} & {1} & {3} \\{2} & {3} & {2} \end{array} \right] \rightarrow \left[ \begin{array}{l l l}{2} & {3} & {2} \\{3} & {1} & {3} \\{1} & {3} & {1} \end{array} \right] \quad \left[ \begin{array}{l l l l}{1} & {8} & {8} & {9} \\{2} & {4} & {3} & {2} \\{1} & {3} & {4} & {1} \\{9} & {8} & {8} & {1} \end{array} \right] \rightarrow \left[ \begin{array}{l l l l}{9} & {8} & {8} & {1} \\{1} & {3} & {4} & {1} \\{2} & {4} & {3} & {2} \\{1} & {8} & {8} & {9} \end{array} \right]$ 

The following matrices are not palindromic because they change after the order of columns is reversed: $\left[ \begin{array}{l l l}{1} & {3} & {2} \\{3} & {1} & {3} \\{1} & {3} & {2} \end{array} \right] \rightarrow \left[ \begin{array}{l l l}{2} & {3} & {1} \\{3} & {1} & {3} \\{2} & {3} & {1} \end{array} \right] \quad \left[ \begin{array}{l l l l}{1} & {2} & {1} & {9} \\{8} & {4} & {3} & {8} \\{8} & {3} & {4} & {8} \\{9} & {2} & {1} & {1} \end{array} \right] \rightarrow \left[ \begin{array}{l l l l}{9} & {1} & {2} & {1} \\{8} & {3} & {4} & {8} \\{8} & {4} & {3} & {8} \\{1} & {1} & {2} & {9} \end{array} \right]$ 

You are given $n^2$ integers. Put them into a matrix of $n$ rows and $n$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic. If there are multiple answers, print any. If there is no solution, print "NO".


-----Input-----

The first line contains one integer $n$ ($1 \le n \le 20$).

The second line contains $n^2$ integers $a_1, a_2, \dots, a_{n^2}$ ($1 \le a_i \le 1000$) — the numbers to put into a matrix of $n$ rows and $n$ columns.


-----Output-----

If it is possible to put all of the $n^2$ numbers into a matrix of $n$ rows and $n$ columns so that each number is used exactly once, each cell contains exactly one number and the resulting matrix is palindromic, then print "YES". Then print $n$ lines with $n$ space-separated numbers — the resulting matrix.

If it's impossible to construct any matrix, then print "NO".

You can print each letter in any case (upper or lower). For example, "YeS", "no" and "yES" are all acceptable.


-----Examples-----
Input
4
1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1

Output
YES
1 2 2 1
8 2 2 8
8 2 2 8
1 2 2 1

Input
3
1 1 1 1 1 3 3 3 3

Output
YES
1 3 1
3 1 3
1 3 1

Input
4
1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1

Output
NO

Input
1
10

Output
YES
10 



-----Note-----

Note that there exist multiple answers for the first two examples.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Implementation

Constructive algorithms


Solutions:
import sys
n = int(input())
A = list(map(int, input().split()))
from collections import Counter
counter = Counter(A)
ANS = [[0] * n for i in range(n)]

def write(ANS):
	for i in range(n):
		print(' '.join([str(a) for a in ANS[i]]))
if n % 2 == 0:
	for v in counter.values():
		if v % 4 != 0:
			print('NO')
			sys.exit()
	i = j = 0
	for k in counter.keys():
		while counter[k] > 0:
			ANS[i][j] = ANS[n - i - 1][j] = ANS[i][n - j - 1] = ANS[n - i - 1][n - j - 1] = k
			counter[k] -= 4
			if j == n // 2 - 1:
				i += 1
				j = 0
			else:
				j += 1
	print('YES')
	write(ANS)
else:
	c1 = 0
	c2 = 0
	for v in counter.values():
		if v % 2 == 1:
			c1 += 1
			v -= 1
		if v % 4 == 2:
			c2 += 1
	if c1 > 1 or c2 > n - 1:
		print('NO')
		sys.exit()
	i2 = 0
	j2 = 0
	for k in counter.keys():
		if counter[k] > 0:
			if counter[k] % 2 == 1:
				ANS[n // 2][n // 2] = k
				counter[k] -= 1
			if counter[k] % 4 == 2 and i2 != n // 2:
				ANS[i2][n // 2] = ANS[n - i2 - 1][n // 2] = k
				i2 += 1
				counter[k] -= 2
			if counter[k] % 4 == 2 and i2 == n // 2:
				ANS[n // 2][j2] = ANS[n // 2][n - 1 - j2] = k
				j2 += 1
				counter[k] -= 2
	i = j = 0
	for k in counter.keys():
		if counter[k] > 0:
			while counter[k] > 0:
				if j == n // 2:
					if ANS[i][j] == 0:
						ANS[i][j] = ANS[n - i - 1][j] = ANS[j][i] = ANS[j][n - i - 1] = k
						counter[k] -= 4
					else:
						i += 1
						j = 0
				if i != n // 2 and j != n // 2:
					ANS[i][j] = ANS[n - i - 1][j] = ANS[i][n - j - 1] = ANS[n - i - 1][n - j - 1] = k
					counter[k] -= 4
				if i == n // 2 and ANS[i][j] == 0:
					ANS[i][j] = ANS[i][n - j - 1] = k
					counter[k] -= 2
				if j == n // 2:
					i += 1
					j = 0
				else:
					j += 1
	print('YES')
	write(ANS)


from collections import Counter
n = int(input())
A = [int(i) for i in input().split()]
C = Counter(A)
B = [[] for i in range(5)]
Q = [[0] * 5 for i in range(21)]
Q[1][1] = 1
for i in range(3, 21, 2):
	Q[i][1] = 1
	Q[i][2] = Q[i - 2][2] + 2
	Q[i][4] = Q[i - 2][4] + (i - 2)
for i in range(2, 21, 2):
	Q[i][4] = (i // 2) ** 2
P = Q[n]
if n % 2 == 0:
	for (k, v) in C.items():
		if v % 4 != 0:
			print('NO')
			exit()
		B[4] += [k] * (v // 4)
	print('YES')
	m = n // 2
	D = dict()
	for i in range(n):
		a = i if i < m else n - i - 1
		ans = []
		for j in range(n):
			b = j if j < m else n - j - 1
			if not (a, b) in D:
				D[a, b] = B[4].pop()
			ans.append(D[a, b])
		print(*ans)
else:
	for (k, v) in C.items():
		if v % 2 == 1:
			C[k] -= 1
			P[1] -= 1
			B[1].append(k)
	for (k, v) in C.items():
		if P[4] == 0:
			break
		t = min(P[4], v // 4)
		C[k] -= 4 * t
		P[4] -= t
		B[4] += [k] * t
	for (k, v) in C.items():
		t = v // 2
		B[2] += [k] * t
		P[2] -= t
		C[k] -= 2 * t
	if P[1] != 0 or P[4] != 0 or P[2] != 0:
		print('NO')
		exit()
	print('YES')
	m = n // 2
	D = dict()
	for i in range(n):
		ans = []
		for j in range(n):
			if i == m and j == m:
				ans.append(B[1][0])
			elif i == m:
				k = j if j < m else n - j - 1
				k += Q[n][2] // 2
				ans.append(B[2][k])
			elif j == m:
				k = i if i < m else n - i - 1
				ans.append(B[2][k + m])
			else:
				(a, b) = (abs(i - m), abs(j - m))
				if not (a, b) in D:
					D[a, b] = B[4].pop()
				ans.append(D[a, b])
		print(*ans)


n = int(input())
a = list(map(int, input().split()))
cnt = [0] * 1001
for val in a:
	cnt[val] += 1

def solve():
	if n % 2 == 0:
		for i in range(1001):
			if cnt[i] % 4 != 0:
				print('NO')
				return
		pos = 0
		m = [[0] * n for _ in range(n)]
		for row in range(n // 2):
			for row_or_col in range(n // 2):
				while cnt[pos] == 0:
					pos += 1
				m[row][row_or_col] = pos
				m[row][n - 1 - row_or_col] = pos
				m[n - 1 - row][row_or_col] = pos
				m[n - 1 - row][n - 1 - row_or_col] = pos
				cnt[pos] -= 4
		print('YES')
		for row in range(n):
			print(' '.join(map(str, m[row])))
	else:
		pos4 = 0
		pos2 = 0

		def next4(pos4):
			while pos4 < len(cnt) and (cnt[pos4] == 0 or cnt[pos4] < 4):
				pos4 += 1
			return pos4

		def next2(pos2):
			while pos2 < len(cnt) and (cnt[pos2] == 0 or cnt[pos2] < 2):
				pos2 += 1
			return pos2

		def next1():
			for pos in range(len(cnt)):
				if cnt[pos] > 0:
					return pos
			return len(cnt)
		m = [[0] * n for _ in range(n)]
		for row in range(n // 2):
			for row_or_col in range(n // 2):
				pos4 = next4(pos4)
				if pos4 >= len(cnt):
					print('NO')
					return
				cnt[pos4] -= 4
				m[row][row_or_col] = pos4
				m[row][n - 1 - row_or_col] = pos4
				m[n - 1 - row][row_or_col] = pos4
				m[n - 1 - row][n - 1 - row_or_col] = pos4
		for row_or_col in range(n // 2):
			if row_or_col != n // 2:
				pos2 = next2(pos2)
				if pos2 >= len(cnt):
					print('NO')
					return
				cnt[pos2] -= 2
				m[n // 2][row_or_col] = m[n // 2][n - 1 - row_or_col] = pos2
				pos2 = next2(pos2)
				if pos2 >= len(cnt):
					print('NO')
					return
				cnt[pos2] -= 2
				m[row_or_col][n // 2] = m[n - 1 - row_or_col][n // 2] = pos2
		pos1 = next1()
		if pos1 >= len(cnt):
			print('NO')
			return
		m[n // 2][n // 2] = pos1
		print('YES')
		for row in range(n):
			print(' '.join(map(str, m[row])))
solve()


n = int(input())
s = [int(x) for x in input().split()]
L = sorted(s)
flag = 0
if n % 2 != 0:
	l4 = []
	l2 = []
	l1 = []
	G = []
	p = 1
	for i in range(1, len(L)):
		if L[i] != L[i - 1]:
			G.append([L[i - 1], p])
			p = 1
		else:
			p = p + 1
	G.append([L[-1], p])
	for i in range(0, len(G)):
		if G[i][1] >= 4:
			l4 = l4 + [G[i][0]] * (4 * (G[i][1] // 4))
			G[i][1] = G[i][1] % 4
			l2 = l2 + [G[i][0]] * (2 * (G[i][1] // 2))
			G[i][1] = G[i][1] % 2
			l1 = l1 + [G[i][0]] * G[i][1]
		elif G[i][1] >= 2:
			l2 = l2 + [G[i][0]] * (2 * (G[i][1] // 2))
			G[i][1] = G[i][1] % 2
			l1 = l1 + [G[i][0]] * G[i][1]
		else:
			l1 = l1 + [G[i][0]] * G[i][1]
	n1 = 4 * ((n - 1) // 2) ** 2
	n2 = 2 * (n - 1)
	if len(l4) > n1:
		l2 = l2 + l4[n1:]
		l4 = l4[:n1]
	if len(l2) > n2:
		l1 = l1 + l2[n2:]
		l2 = l2[:n2]
	if len(l4) == n1 and len(l2) == n2 and (len(l1) == 1):
		flag = 1
	if flag != 0:
		L1 = []
		k = (n - 1) // 2
		pt1 = 0
		pt2 = 0
		for i in range(0, k):
			for j in range(0, k):
				for m in range(4):
					L1.append(l4[pt1])
					pt1 = pt1 + 1
			for j in range(2):
				L1.append(l2[pt2])
				pt2 = pt2 + 1
		for i in range(n - 1):
			L1.append(l2[pt2])
			pt2 = pt2 + 1
		L1 = L1 + l1
		L = L1
else:
	I = 0
	for i in range(0, len(L), 4):
		W = L[i:4 * (I + 1)]
		I = I + 1
		if len(list(set(W))) == 1:
			flag = 2
		else:
			flag = 0
			break
if flag == 0:
	print('NO')
else:
	print('YES')
	dp = []
	for i in range(0, n):
		h = []
		for j in range(0, n):
			h.append(0)
		dp.append(h)
	ptr1 = [0, 0]
	ptr3 = [n - 1, n - 1]
	ptr2 = [n - 1, 0]
	ptr4 = [0, n - 1]
	if n % 2 != 0:
		c = 1
		r = -1
		for i in range(0, len(L), 2):
			r = r + 1
			if ptr1 == ptr2 and ptr3 == ptr4 and (ptr1 != ptr3):
				dp[ptr1[0]][ptr1[1]] = L[i]
				dp[ptr3[0]][ptr3[1]] = L[i + 1]
				ptr1 = [0, c]
				ptr3 = [n - 1, n - c - 1]
				ptr2 = [n - 1, c]
				ptr4 = [0, n - c - 1]
				c = c + 1
				r = 0
			elif ptr1 == ptr4 and ptr2 == ptr3 and (ptr1 != ptr2):
				dp[ptr1[0]][ptr1[1]] = L[i]
				dp[ptr2[0]][ptr2[1]] = L[i + 1]
				ptr1 = [ptr1[0] + 1, ptr1[1]]
				ptr2 = [ptr2[0] - 1, ptr2[1]]
				ptr3 = [ptr3[0] - 1, ptr3[1]]
				ptr4 = [ptr4[0] + 1, ptr4[1]]
			elif ptr1 == ptr3 and ptr2 == ptr4 and (ptr1 == ptr4):
				dp[ptr1[0]][ptr1[1]] = L[i]
			elif r % 2 == 0:
				dp[ptr1[0]][ptr1[1]] = L[i]
				dp[ptr2[0]][ptr2[1]] = L[i + 1]
				ptr1 = [ptr1[0] + 1, ptr1[1]]
				ptr2 = [ptr2[0] - 1, ptr2[1]]
			else:
				dp[ptr3[0]][ptr3[1]] = L[i]
				dp[ptr4[0]][ptr4[1]] = L[i + 1]
				ptr3 = [ptr3[0] - 1, ptr3[1]]
				ptr4 = [ptr4[0] + 1, ptr4[1]]
	else:
		c = 1
		for i in range(0, len(L), 4):
			dp[ptr1[0]][ptr1[1]] = L[i]
			dp[ptr2[0]][ptr2[1]] = L[i + 1]
			dp[ptr3[0]][ptr3[1]] = L[i + 2]
			dp[ptr4[0]][ptr4[1]] = L[i + 3]
			ptr1 = [ptr1[0] + 1, ptr1[1]]
			ptr2 = [ptr2[0] - 1, ptr2[1]]
			ptr3 = [ptr3[0] - 1, ptr3[1]]
			ptr4 = [ptr4[0] + 1, ptr4[1]]
			if ptr1[0] > ptr2[0]:
				ptr1 = [0, c]
				ptr3 = [n - 1, n - c - 1]
				ptr2 = [n - 1, c]
				ptr4 = [0, n - c - 1]
				c = c + 1
	for i in range(0, n):
		for j in range(0, n):
			print(dp[i][j], end=' ')
		print(' ')


n = int(input())
A = list(map(int, input().split()))
count = [0] * 1001
for a in A:
	count[a] += 1
if n % 2 == 1:
	can = True
	one = []
	two = []
	fore = []
	for i in range(1001):
		c = count[i]
		if c % 4 == 0:
			fore += [i] * (c // 4)
		elif c % 4 == 1:
			one += [i]
			fore += [i] * (c // 4)
		elif c % 4 == 2:
			two += [i]
			fore += [i] * (c // 4)
		else:
			one += [i]
			two += [i]
			fore += [i] * (c // 4)
	if len(one) != 1:
		can = False
	if len(two) > n - 1:
		can = False
	if can:
		answer = [[0] * n for i in range(n)]
		print('YES')
		current = 0
		for i in range((n + 1) // 2):
			for j in range((n + 1) // 2):
				if i == (n - 1) // 2:
					if j == (n - 1) // 2:
						answer[i][j] = one[-1]
					else:
						if len(two) == 0:
							two += [fore[-1]] * 2
							fore = fore[:-1]
						answer[i][j] = two[-1]
						answer[i][n - j - 1] = two[-1]
						two = two[:-1]
				elif j == (n - 1) // 2:
					if len(two) == 0:
						two += [fore[-1]] * 2
						fore = fore[:-1]
					answer[i][j] = two[-1]
					answer[n - i - 1][j] = two[-1]
					two = two[:-1]
				else:
					answer[i][j] = fore[-1]
					answer[n - i - 1][j] = fore[-1]
					answer[i][n - j - 1] = fore[-1]
					answer[n - i - 1][n - j - 1] = fore[-1]
					fore = fore[:-1]
		for line in answer:
			print(' '.join(list(map(str, line))))
	else:
		print('NO')
else:
	can = True
	fore = []
	for i in range(1001):
		c = count[i]
		if c % 4 == 0:
			fore += [i] * (c // 4)
		else:
			can = False
	if can:
		answer = [[0] * n for i in range(n)]
		print('YES')
		current = 0
		for i in range(n // 2):
			for j in range(n // 2):
				answer[i][j] = fore[-1]
				answer[n - i - 1][j] = fore[-1]
				answer[i][n - j - 1] = fore[-1]
				answer[n - i - 1][n - j - 1] = fore[-1]
				fore = fore[:-1]
		for line in answer:
			print(' '.join(list(map(str, line))))
	else:
		print('NO')


import sys
dl = 0
srodek = 0
sr = 0
n = int(input())
tab = [int(i) for i in input().split()]
numof = [0] * 1001
for i in tab:
	numof[i] += 1
czworki = []
for i in range(1001):
	if numof[i] > 0:
		czworki.append(i)
matrix = [[0 for x in range(n)] for y in range(n)]
pom = 1
zm = 0
for i in range(n // 2):
	for j in range(n // 2):
		zm = 0
		if len(czworki) > 0:
			pom = 1
			while pom:
				if len(czworki) == 0:
					break
				else:
					dl = len(czworki) - 1
					if numof[czworki[dl]] >= 4:
						matrix[i][j] = czworki[dl]
						matrix[i][n - 1 - j] = czworki[dl]
						matrix[n - 1 - i][j] = czworki[dl]
						matrix[n - 1 - i][n - 1 - j] = czworki[dl]
						numof[czworki[dl]] -= 4
						pom = 0
						zm = 1
					if numof[czworki[dl]] < 4:
						czworki.pop()
		if len(czworki) == 0 and zm == 0:
			print('NO')
			sys.exit(0)
if n % 2 == 1:
	k = n // 2
	duzo = []
	for i in range(1001):
		if numof[i] > 3:
			duzo.append(i)
	t = len(duzo)
	chuj = -1
	for i in range(n):
		zm = 0
		if len(duzo) > 0:
			pom = 1
			while pom:
				if len(duzo) == 0:
					break
				else:
					dl = len(duzo) - 1
					if numof[duzo[dl]] >= 4:
						matrix[i][k] = duzo[dl]
						matrix[k][i] = duzo[dl]
						matrix[n - 1 - i][k] = duzo[dl]
						matrix[k][n - 1 - i] = duzo[dl]
						numof[duzo[dl]] -= 4
						pom = 0
						zm = 1
					if numof[duzo[dl]] < 4:
						duzo.pop()
		if len(duzo) == 0 and chuj == -1:
			chuj = i
	if t == 0:
		chuj = -1
	dupa = 0
	for i in range(1001):
		if numof[i] % 2 == 1:
			numof[i] -= 1
			if dupa == 0:
				dupa = 1
				srodek = i
	ziomki = []
	for i in range(1001):
		if numof[i] == 2:
			ziomki.append(i)
	if len(ziomki) < n - 1 - 2 * (chuj + 1):
		print('NO')
		sys.exit(0)
	else:
		for i in range(chuj + 1, n // 2):
			matrix[k][i] = ziomki[len(ziomki) - 1]
			matrix[k][n - 1 - i] = ziomki[len(ziomki) - 1]
			ziomki.pop()
			matrix[i][k] = ziomki[len(ziomki) - 1]
			matrix[n - 1 - i][k] = ziomki[len(ziomki) - 1]
			ziomki.pop()
		matrix[n // 2][n // 2] = srodek
print('YES', end='\n')
for i in range(n):
	for j in range(n):
		if j < n - 1:
			print(matrix[i][j], end=' ')
		else:
			print(matrix[i][j], end='\n')


n = int(input())
ar = list(map(int, input().split()))
dic = {}
for i in range(n * n):
	if ar[i] in dic:
		dic[ar[i]] += 1
	else:
		dic[ar[i]] = 1
ans = []
for i in range(n):
	tem = []
	for j in range(n):
		tem.append(0)
	ans.append(tem)
flag = True
for i in range(n // 2):
	for j in range(n // 2):
		if max(list(dic.values())) < 4:
			flag = False
		else:
			for k in dic:
				if dic[k] >= 4:
					dic[k] -= 4
					ans[i][j] = k
					ans[n - i - 1][j] = k
					ans[i][n - j - 1] = k
					ans[n - i - 1][n - j - 1] = k
					break
if n % 2 != 0:
	for j in range(n // 2):
		if max(list(dic.values())) < 2:
			flag = False
		else:
			for k in dic:
				if dic[k] >= 2:
					dic[k] -= 2
					ans[j][n // 2] = k
					ans[n - j - 1][n // 2] = k
					break
	for j in range(n // 2):
		if max(list(dic.values())) < 2:
			flag = False
		else:
			for k in dic:
				if dic[k] >= 2:
					dic[k] -= 2
					ans[n // 2][j] = k
					ans[n // 2][n - j - 1] = k
					break
	for k in dic:
		if dic[k] != 0:
			ans[n // 2][n // 2] = k
if flag:
	print('YES')
	for i in ans:
		print(*i)
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
from collections import defaultdict as dc
d = dc(int)
for i in a:
	d[i] += 1
ch = 0
for i in d:
	if d[i] % 2 != 0:
		ch += 1
	if ch > 1:
		print('NO')
		exit()
l = len(d)
ch = 0
a1 = (n // 2) ** 2
if n % 2 == 0:
	if l > a1:
		ch = 1
elif l > a1 + (n ** 2 - a1 * 4 - 1) // 2 + 1:
	ch = 1
if ch == 1:
	print('NO')
	exit()
ans = [[0 for j in range(n)] for i in range(n)]
sa = [[i, d[i]] for i in d]
sa.sort(reverse=True, key=lambda x: x[1])
ch1 = 0
try:
	for i in range(n // 2):
		for j in range(n // 2):
			while sa[ch1][1] < 4:
				ch1 += 1
			ans[i][j] = sa[ch1][0]
			ans[n - i - 1][j] = sa[ch1][0]
			ans[i][n - j - 1] = sa[ch1][0]
			ans[n - i - 1][n - j - 1] = sa[ch1][0]
			sa[ch1][1] -= 4
	if n % 2 != 0:
		ss = []
		for (i, j) in sa:
			if j != 0:
				ss.append([i, j])
		ss.sort(reverse=True, key=lambda x: x[1])
		ch1 = 0
		for i in range(n // 2):
			while ss[ch1][1] < 2:
				ch1 += 1
			ans[n // 2][i] = ss[ch1][0]
			ans[n // 2][n - i - 1] = ss[ch1][0]
			ss[ch1][1] -= 2
		for i in range(n // 2):
			while ss[ch1][1] < 2:
				ch1 += 1
			ans[i][n // 2] = ss[ch1][0]
			ans[n - i - 1][n // 2] = ss[ch1][0]
			ss[ch1][1] -= 2
		for (i, j) in ss:
			if j != 0:
				ans[n // 2][n // 2] = i
				break
except:
	print('NO')
	exit()
print('YES')
for i in ans:
	print(*i)


from sys import stdin, stdout
from collections import *
from math import gcd, floor, ceil
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007
INF = float('inf')

def solve():
	n = inp()
	l = li()
	d = Counter(l)
	ele = -1
	odd = 0
	(v, o) = ([], [])
	for i in d:
		if d[i] & 1:
			if n % 2 == 0:
				pr('NO')
				return
			else:
				odd += 1
				ele = i
				if odd > 1:
					pr('NO')
					return
		if d[i] % 2 == 0:
			v.append(i)
			if d[i] % 4 == 2:
				o.append(i)
	if (d[ele] - 1) % 2 == 0:
		v.append(ele)
		if (d[ele] - 1) % 4 == 2:
			o.append(ele)
	i = 0
	v.sort(key=lambda x: d[x], reverse=True)
	ans = [[0 for i in range(n)] for j in range(n)]
	if n & 1:
		ans[n // 2][n // 2] = ele
		d[ele] -= 1
		(j, k) = (n // 2, 0)
		i = 0
		while k < n // 2 and i < len(o):
			ans[j][k] = o[i]
			ans[j][n - 1 - k] = o[i]
			k += 1
			d[o[i]] -= 2
			i += 1
		(j, k) = (0, n // 2)
		while j < n // 2 and i < len(o):
			ans[j][k] = o[i]
			ans[n - 1 - j][k] = o[i]
			d[o[i]] -= 2
			i += 1
			j += 1
		i = 0
		(j, k) = (n // 2, 0)
		while i < len(v):
			while k < n // 2 and d[v[i]] > 0:
				if ans[j][k] == 0:
					ans[j][k] = v[i]
					ans[j][n - 1 - k] = v[i]
					d[v[i]] -= 2
				k += 1
			i += 1
		i = 0
		(j, k) = (0, n // 2)
		while i < len(v):
			while j < n // 2 and d[v[i]] > 0:
				if ans[j][k] == 0:
					ans[j][k] = v[i]
					ans[n - 1 - j][k] = v[i]
					d[v[i]] -= 2
				j += 1
			i += 1
	x = [[d[i], i] for i in d if d[i]]
	(p, q) = (0, 0)
	i = 0
	while i < len(x):
		(a, b) = x[i]
		if a % 4:
			pr('NO')
			return
		if p < n // 2:
			while a > 0:
				ans[p][q] = b
				ans[p][n - 1 - q] = b
				ans[n - 1 - p][q] = b
				ans[n - 1 - p][n - 1 - q] = b
				a -= 4
				if a > 0 and a % 4 == 0:
					p += 1
					if p == n // 2:
						p = 0
						q += 1
			p += 1
			if p == n // 2:
				p = 0
				q += 1
		i += 1
	pr('YES')
	for i in ans:
		print(*i)
solve()


import ctypes

class Array:

	def __init__(self, size):
		assert size > 0
		self.size = size
		py_array = ctypes.py_object * size
		self.items = py_array()

	def __len__(self):
		return self.size

	def __getitem__(self, index):
		assert 0 <= index < len(self)
		return self.items[index]

	def __setitem__(self, index, value):
		assert 0 <= index < len(self)
		self.items[index] = value
n = int(input())
a = list(map(int, input().split()))
d_count = {}
matrix = Array(n)
s = len(a)
for i in range(n):
	matrix[i] = Array(n)
for i in range(n ** 2):
	if a[i] in d_count:
		d_count[a[i]] += 1
	else:
		d_count[a[i]] = 1
if n % 2:
	(i, j) = (0, 0)
	count = 0
	for key in d_count:
		while d_count[key] >= 4 and i <= n // 2 - 1:
			matrix[i][j] = matrix[i][n - 1 - j] = matrix[n - 1 - i][j] = matrix[n - 1 - i][n - 1 - j] = key
			d_count[key] -= 4
			count += 4
			j += 1
			if j > n // 2 - 1:
				j = 0
				i += 1
		if i > n // 2 - 1:
			break
	i = n // 2
	j = 0
	for key in d_count:
		while d_count[key] >= 2 and j < n // 2:
			matrix[i][j] = matrix[i][n - 1 - j] = key
			d_count[key] -= 2
			count += 2
			j += 1
		if j == n // 2:
			break
	i = 0
	j = n // 2
	for key in d_count:
		while d_count[key] >= 2 and i < n // 2:
			matrix[i][j] = matrix[n - 1 - i][j] = key
			d_count[key] -= 2
			count += 2
			i += 1
		if i == n // 2:
			break
	i = j = n // 2
	for key in d_count:
		if d_count[key] == 1:
			d_count[key] -= 1
			count += 1
			matrix[i][j] = key
			break
	if count == n * n:
		print('YES')
		for i in range(n):
			for j in range(n):
				print(matrix[i][j], end=' ')
			print('')
	else:
		print('NO')
else:
	count = 0
	(i, j) = (0, 0)
	for key in d_count:
		while d_count[key] and count < n * n:
			matrix[i][j] = matrix[i][n - 1 - j] = matrix[n - 1 - i][j] = matrix[n - 1 - i][n - 1 - j] = key
			d_count[key] -= 4
			count += 4
			j += 1
			if j > (n - 1) // 2:
				j = 0
				i += 1
	possible = True
	for key in d_count:
		if d_count[key]:
			possible = False
			break
	if possible:
		print('YES')
		for i in range(n):
			for j in range(n):
				print(matrix[i][j], end=' ')
			print('')
	else:
		print('NO')


def mi():
	return map(int, input().split())
n = int(input())
a = list(mi())
curInd = 0
from collections import Counter as C
temp = C(a)
db4 = []
db2 = []
db1 = []
for i in temp:
	while temp[i] >= 4:
		db4.append(i)
		temp[i] -= 4
	while temp[i] >= 2:
		db2.append(i)
		temp[i] -= 2
	while temp[i] >= 1:
		db1.append(i)
		temp[i] -= 1
o = [[10000000000.0] * n for i in range(n)]
ldb4 = len(db4)
for i in range(n // 2):
	for j in range(n // 2):
		if curInd == ldb4:
			print('NO')
			exit(0)
		o[i][j] = o[-1 - i][-1 - j] = o[i][-1 - j] = o[-1 - i][j] = db4[curInd]
		curInd += 1
ci1 = ci2 = 0
ldb2 = len(db2)
ldb1 = len(db1)
if n % 2:
	flag = 0
	f1 = 0
	for i in range(n // 2):
		if flag == 1:
			flag = 0
			continue
		if curInd != ldb4:
			if i == n // 2 - 1:
				o[i][n // 2] = o[-1 - i][n // 2] = o[n // 2][0] = o[n // 2][-1] = db4[curInd]
				f1 = 1
			else:
				o[i][n // 2] = o[i + 1][n // 2] = o[-1 - i][n // 2] = o[-i - 1 - 1][n // 2] = db4[curInd]
			curInd += 1
			flag = 1
		elif ci2 != ldb2:
			o[i][n // 2] = o[-1 - i][n // 2] = db2[ci2]
			ci2 += 1
		elif ci1 != ldb1:
			o[i][n // 2] = db1[ci1]
			ci1 += 1
	flag = 0
	for i in range(n // 2):
		if f1 and i == 0:
			continue
		if flag == 1:
			flag = 0
			continue
		if curInd != ldb4:
			o[n // 2][i] = o[n // 2][i + 1] = o[n // 2][-1 - i] = o[n // 2][-1 - i - 1] = db4[curInd]
			curInd += 1
			flag = 1
		elif ci2 != ldb2:
			o[n // 2][i] = o[n // 2][-i - 1] = db2[ci2]
			ci2 += 1
		elif ci1 != ldb1:
			o[n // 2][i] = db1[ci1]
			ci1 += 1
	if ldb1 != ci1:
		o[n // 2][n // 2] = db1[ci1]
		ci1 += 1
for i in range(n // 2):
	for j in range(n // 2):
		t = [o[i][j], o[-1 - i][-1 - j], o[i][-1 - j], o[-1 - i][j]]
		if min(t) != max(t) or max(t) == 10000000000.0:
			print('NO')
			exit(0)
if n % 2:
	for i in range(n):
		t = [o[i][n // 2], o[-1 - i][n // 2]]
		if min(t) != max(t) or max(t) == 10000000000.0:
			print('NO')
			exit(0)
		t = [o[n // 2][i], o[n // 2][-1 - i]]
		if min(t) != max(t) or max(t) == 10000000000.0:
			print('NO')
			exit(0)
print('YES')
for i in range(n):
	for j in range(n):
		print(o[i][j], end=' ')
	print()


from collections import *
from math import *
n = int(input())
a = list(map(int, input().split()))
(ct4, ct2, ct1) = ([], [], [])
d = dict()
for i in a:
	if i not in d:
		d[i] = 0
	d[i] += 1
	if d[i] == 4:
		d[i] = 0
		ct4.append(i)
for (k, v) in d.items():
	if v == 0:
		continue
	if v >= 2:
		ct2.append(k)
		v -= 2
	if v == 1:
		ct1.append(k)
if n & 1 and len(ct1) != 1:
	print('NO')
	exit(0)
ans = [[0 for j in range(n)] for i in range(n)]
for i in range((n + 1) // 2):
	for j in range((n + 1) // 2):
		if j == n - j - 1 and i == n - i - 1:
			ct = 1
		elif i == n - i - 1 or j == n - j - 1:
			ct = 2
		else:
			ct = 4
		if ct == 4:
			if len(ct4) == 0:
				print('NO')
				exit(0)
			y = ct4[-1]
			ct4.pop()
		elif ct == 2:
			if len(ct2) == 0:
				if len(ct4) == 0:
					print('NO')
					exit(0)
				y = ct4[-1]
				ct4.pop()
				ct2.append(y)
			else:
				y = ct2[-1]
				ct2.pop()
		else:
			y = ct1[-1]
			ct1.pop()
		(ans[i][j], ans[i][n - j - 1], ans[n - i - 1][j], ans[n - i - 1][n - j - 1]) = (y, y, y, y)
print('YES')
for i in ans:
	print(*i)


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
d = {}
Matrix = [[0 for x in range(n)] for y in range(n)]
for x in a:
	if x in d:
		d[x] += 1
	else:
		d[x] = 1
sum = 0
for x in d:
	if d[x] % 2 == 1 and n & 1 and (Matrix[n // 2][n // 2] == 0):
		d[x] -= 1
		Matrix[n // 2][n // 2] = x
	if d[x] % 4 == 2:
		sum += 1
	if d[x] % 2 == 1:
		print('NO')
		break
else:
	if sum & 1:
		print('NO')
	elif sum > 0 and n % 2 == 0:
		print('NO')
	elif sum > n - 1:
		print('NO')
	else:
		print('YES')
		f = 1
		for x in d:
			if d[x] % 4 == 2:
				if f == 1:
					for i in range(n):
						if Matrix[i][n // 2] == 0:
							Matrix[i][n // 2] = Matrix[n - i - 1][n // 2] = x
							d[x] -= 2
							fla = True
							break
					f = 0
				else:
					for i in range(n):
						if Matrix[n // 2][i] == 0:
							Matrix[n // 2][i] = Matrix[n // 2][n - i - 1] = x
							d[x] -= 2
							break
					f = 1
		for x in d:
			while d[x] > 0:
				fla = False
				for i in range(n):
					for j in range(n):
						if Matrix[i][j] == 0:
							Matrix[i][j] = Matrix[i][n - j - 1] = Matrix[n - i - 1][j] = Matrix[n - i - 1][n - j - 1] = x
							if n & 1 and j == n // 2:
								Matrix[n - j - 1][i] = Matrix[n - j - 1][n - i - 1] = x
							fla = True
							break
					if fla:
						break
				d[x] -= 4
		for i in range(n):
			for j in range(n):
				print(Matrix[i][j], end=' ')
			print('')


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
ctr = Counter(a)

def mp(r, size):
	for i in range(size):
		for j in range(size):
			print(r[i][j], end='')
			print(' ' if j < size - 1 else '', end='')
		print('')
if n % 2 == 0:
	b = True
	for i in range(1, max(a) + 1):
		if ctr[i] % 4 != 0:
			b = False
			break
	print('yes' if b else 'no')
	if b:
		t = [[0 for i in range(n)] for j in range(n)]
		x = y = 0
		for i in range(1, max(a) + 1):
			while ctr[i] > 0:
				t[x][y] = t[n - x - 1][y] = t[x][n - y - 1] = t[n - x - 1][n - y - 1] = i
				y += 0 if x < n // 2 - 1 else 1
				x = x + 1 if x < n // 2 - 1 else 0
				ctr[i] -= 4
		mp(t, n)
else:
	odd = two = four = temp = 0
	b = True
	for i in range(1, max(a) + 1):
		if ctr[i] % 2 == 1:
			odd += 1
			temp = i
		elif ctr[i] % 4 == 0 and ctr[i] != 0:
			four += 1
		elif ctr[i] % 4 == 2 and ctr[i] != 0:
			two += 1
	if odd != 1:
		print('no')
		b = False
	else:
		if (ctr[temp] - 1) % 4 == 0:
			four += 1
		else:
			two += 1
		print('yes' if two <= n - 1 or n == 1 else 'no')
		b = True if two <= n - 1 or n == 1 else False
	if b:
		t = [[0 for i in range(n)] for j in range(n)]
		t[n // 2][n // 2] = temp
		ctr[temp] -= 1
		x = y = 0
		tt = 0
		for i in range(1, max(a) + 1):
			while ctr[i] > 0 and (ctr[i] % 4 == 0 or ctr[i] > 4) and (y < n // 2):
				t[x][y] = t[n - x - 1][y] = t[x][n - y - 1] = t[n - x - 1][n - y - 1] = i
				y += 0 if x < n // 2 - 1 else 1
				x = x + 1 if x < n // 2 - 1 else 0
				ctr[i] -= 4
			while ctr[i] > 0:
				if tt < n // 2:
					t[tt][n // 2] = t[n - tt - 1][n // 2] = i
					ctr[i] -= 2
					tt += 1
				else:
					t[n // 2][tt - n // 2] = t[n // 2][n - tt + n // 2 - 1] = i
					ctr[i] -= 2
					tt += 1
		mp(t, n)


n = int(input())
l = list(map(int, input().split()))
d = dict()
for j in range(n * n):
	if l[j] not in d:
		d.update({l[j]: 1})
	else:
		d[l[j]] += 1
four = 0
t = 0
f = 0
for j in d:
	if d[j] % 2 == 1:
		if n % 2 == 1 and t == 0:
			t = 1
		else:
			f = 1
			break
	if d[j] >= 4:
		four += d[j] // 4
if f == 1 or four < (n // 2) ** 2:
	print('NO')
else:
	print('YES')
	a = [[0 for j in range(n)] for i in range(n)]
	for i in range(n // 2):
		for j in range(n // 2):
			for k in d:
				if d[k] >= 4:
					a[i][j] = k
					a[n - 1 - i][j] = k
					a[i][n - 1 - j] = k
					a[n - 1 - i][n - 1 - j] = k
					d[k] -= 4
					if d[k] == 0:
						del d[k]
					break
	if n % 2 == 1:
		for i in range(n // 2):
			for k in d:
				if d[k] >= 2:
					a[i][n // 2] = k
					a[n - 1 - i][n // 2] = k
					d[k] -= 2
					if d[k] == 0:
						del d[k]
					break
		for i in range(n // 2):
			for k in d:
				if d[k] >= 2:
					a[n // 2][i] = k
					a[n // 2][n - 1 - i] = k
					d[k] -= 2
					if d[k] == 0:
						del d[k]
					break
		for k in d:
			if d[k] == 1:
				a[n // 2][n // 2] = k
	for i in range(n):
		print(*a[i], sep=' ')


n = int(input())
A = list(map(int, input().split()))

def Find(x, par):
	if par[x] < 0:
		return x
	else:
		par[x] = Find(par[x], par)
		return par[x]

def Unite(x, y, par, rank):
	x = Find(x, par)
	y = Find(y, par)
	if x != y:
		if rank[x] < rank[y]:
			par[y] += par[x]
			par[x] = y
		else:
			par[x] += par[y]
			par[y] = x
			if rank[x] == rank[y]:
				rank[x] += 1

def Same(x, y, par):
	return Find(x, par) == Find(y, par)

def Size(x, par):
	return -par[Find(x, par)]
par = [-1] * n ** 2
rank = [0] * n ** 2
for i in range(n):
	for j in range(n):
		idx1 = i * n + j
		idx2 = i * n + (n - 1 - j)
		idx3 = (n - 1 - i) * n + j
		Unite(idx1, idx2, par, rank)
		Unite(idx1, idx3, par, rank)
S = []
from collections import defaultdict
d = defaultdict(lambda : [])
for i in range(n ** 2):
	if par[i] < 0:
		S.append((-par[i], i))
		d[i].append(i)
	else:
		d[Find(i, par)].append(i)
S.sort(reverse=True)
C = [0] * (1000 + 1)
for i in range(n ** 2):
	C[A[i]] += 1
C = [(-c, i) for (i, c) in enumerate(C)]
import heapq
heapq.heapify(C)
ans = [[0] * n for _ in range(n)]
for (s, i) in S:
	(c, j) = heapq.heappop(C)
	c *= -1
	if c >= s:
		for idx in d[i]:
			(row, col) = divmod(idx, n)
			ans[row][col] = j
		c -= s
		heapq.heappush(C, (-c, j))
	else:
		print('NO')
		exit()
else:
	print('YES')
	for i in range(n):
		print(*ans[i])


n = int(input())
a = list(map(int, input().split()))
h = {}
for i in range(n ** 2):
	if a[i] in h:
		h[a[i]].append(i)
	else:
		h[a[i]] = [i]
f = 0
c1 = c2 = 0
if n % 2 == 0:
	for i in h:
		if len(h[i]) % 4 != 0:
			f = 1
			break
else:
	for i in h:
		if len(h[i]) % 4 != 0:
			if len(h[i]) % 4 == 1:
				if c1 == 0:
					c1 += 1
				else:
					f = 1
					break
			elif len(h[i]) % 4 == 2:
				if c2 <= n - 1:
					c2 += 1
				else:
					f = 1
					break
if f == 1 or c1 > 1 or c2 > n - 1:
	print('NO')
else:
	print('YES')
	if n % 2 == 0:
		mat = [[0 for i in range(n)] for i in range(n)]
		for i in range(n // 2):
			for j in range(n // 2):
				mat[i][j] = a[0]
				mat[i][n - j - 1] = a[0]
				mat[n - i - 1][n - j - 1] = a[0]
				mat[n - i - 1][j] = a[0]
				r = a[0]
				a.remove(r)
				a.remove(r)
				a.remove(r)
				a.remove(r)
		for i in range(n):
			print(*mat[i])
	else:
		mat = [[0 for i in range(n)] for i in range(n)]
		for i in range(n // 2):
			for j in range(n // 2):
				for k in h:
					if len(h[k]) % 4 == 0 and len(h[k]) != 0 or (len(h[k]) % 4 == 2 and len(h[k]) != 2) or (len(h[k]) % 4 == 1 and len(h[k]) != 1) or (len(h[k]) % 4 == 3 and len(h[k]) != 3):
						ci = k
				c = a.index(ci)
				mat[i][j] = a[c]
				mat[i][n - j - 1] = a[c]
				mat[n - i - 1][n - j - 1] = a[c]
				mat[n - i - 1][j] = a[c]
				r = a[c]
				a.remove(r)
				a.remove(r)
				a.remove(r)
				a.remove(r)
				del h[ci][0]
				del h[ci][0]
				del h[ci][0]
				del h[ci][0]
		for i in h:
			if len(h[i]) % 4 % 2 == 1:
				mid = i
		mat[n // 2][n // 2] = mid
		del h[mid][0]
		a.remove(mid)
		for i in range(n // 2):
			mat[i][n // 2] = a[0]
			mat[n - i - 1][n // 2] = a[0]
			r = a[0]
			a.remove(r)
			a.remove(r)
		for i in range(n // 2):
			mat[n // 2][i] = a[0]
			mat[n // 2][n - i - 1] = a[0]
			r = a[0]
			a.remove(r)
			a.remove(r)
		for i in range(n):
			print(*mat[i])


n = int(input())
a = list(map(int, input().split()))
o = [0] * 1001
for i in range(n * n):
	o[a[i]] += 1
if n % 2 == 0:
	for i in range(1, 1001):
		if o[i] % 4 != 0:
			print('NO')
			exit()
	ans = [[0] * n for i in range(n)]
	for i in range(n // 2):
		for j in range(n // 2):
			for k in range(1001):
				if o[k] != 0:
					ans[i][j] = k
					ans[n - i - 1][j] = k
					ans[i][n - j - 1] = k
					ans[n - i - 1][n - j - 1] = k
					o[k] -= 4
					break
	print('YES')
	for i in range(n):
		for j in range(n):
			print(ans[i][j], end=' ')
		print()
else:
	f1 = 0
	f2 = 1
	for i in range(1, 1001):
		if o[i] % 4 != 0:
			if o[i] % 4 == 2:
				f1 += 1
			elif o[i] % 4 == 1:
				if f2 == 1:
					f2 = 0
				else:
					print('NO')
					exit()
			elif o[i] % 4 == 3:
				if f2 == 1:
					f2 = 0
					f1 += 1
				else:
					print('NO')
					exit()
			else:
				print('NO')
				exit()
	if f1 >= n:
		print('NO')
		exit()
	ans = [[0] * n for i in range(n)]
	for i in range(n // 2):
		for j in range(n // 2):
			for k in range(1001):
				if o[k] > 3:
					ans[i][j] = k
					ans[n - i - 1][j] = k
					ans[i][n - j - 1] = k
					ans[n - i - 1][n - j - 1] = k
					o[k] -= 4
					break
	for i in range(n // 2 + 1):
		for j in range(n // 2 + 1):
			if i == n // 2 and j == n // 2:
				for k in range(1001):
					if o[k] % 2 == 1:
						ans[i][j] = k
						o[k] -= 1
						break
			if i == n // 2:
				for k in range(1001):
					if o[k] > 1:
						ans[i][j] = k
						ans[i][n - j - 1] = k
						o[k] -= 2
						break
			if j == n // 2:
				for k in range(1, 1001):
					if o[k] > 1:
						ans[i][j] = k
						ans[n - i - 1][j] = k
						o[k] -= 2
						break
	print('YES')
	for i in range(n):
		for j in range(n):
			print(ans[i][j], end=' ')
		print()


import collections

def print_matrix(m):
	l = len(m)
	for i in range(l):
		for j in range(l):
			print(m[i][j], end=' ')
		print()
n = int(input())
a = input().split()
a = [int(i) for i in a]
c = collections.Counter(a)
matrix = [[0 for _ in range(n)] for _ in range(n)]
if n % 2 == 0:
	length = n // 2
	index = 0
	for (k, v) in c.items():
		if v % 4 != 0:
			print('NO')
			exit(0)
		while v > 0:
			x = index % length
			y = index // length
			matrix[x][y] = k
			matrix[n - x - 1][y] = k
			matrix[x][n - y - 1] = k
			matrix[n - x - 1][n - y - 1] = k
			v -= 4
			index += 1
	print('YES')
	print_matrix(matrix)
else:
	center = False
	length = (n - 1) // 2
	area_index = 0
	ver_index = 0
	hon_index = 0
	for (k, v) in c.items():
		while v >= 4 and area_index < length * length:
			x = area_index % length
			y = area_index // length
			matrix[x][y] = k
			matrix[n - x - 1][y] = k
			matrix[x][n - y - 1] = k
			matrix[n - x - 1][n - y - 1] = k
			v -= 4
			area_index += 1
		while v >= 4 and area_index == length * length:
			if ver_index < length:
				matrix[length][ver_index] = k
				matrix[length][n - 1 - ver_index] = k
				ver_index += 1
			elif hon_index < length:
				matrix[hon_index][length] = k
				matrix[n - 1 - hon_index][length] = k
				hon_index += 1
			else:
				print('NO')
				exit(0)
			v -= 2
		if v == 1 or v == 3:
			if center:
				print('NO')
				exit(0)
			else:
				center = True
				matrix[length][length] = k
				v -= 1
		if v == 2:
			if ver_index < length:
				matrix[length][ver_index] = k
				matrix[length][n - 1 - ver_index] = k
				ver_index += 1
			elif hon_index < length:
				matrix[hon_index][length] = k
				matrix[n - 1 - hon_index][length] = k
				hon_index += 1
			else:
				print('NO')
				exit(0)
	print('YES')
	print_matrix(matrix)


import math
import os
import random
import re
import sys

def printMatrix(m):
	for i in range(len(m)):
		print(' '.join(m[i]))

def solve(n, digits):
	if n == 1:
		print('YES')
		print(digits[0])
		return
	if n == 2:
		first = digits[0]
		for digit in digits:
			if digit != first:
				print('NO')
				return
		print('YES')
		printMatrix([[first, first], [first, first]])
		return
	sums = {}
	for digit in digits:
		if digit not in sums:
			sums[digit] = 0
		sums[digit] += 1
	m = []
	for i in range(n):
		m.append([])
		for j in range(n):
			m[i].append('0')
	halfn = n // 2
	for i in range(halfn):
		for j in range(halfn):
			found = False
			for digit in sums:
				if sums[digit] >= 4:
					found = True
					m[i][j] = digit
					m[n - 1 - i][j] = digit
					m[n - 1 - i][n - 1 - j] = digit
					m[i][n - 1 - j] = digit
					if sums[digit] == 4:
						del sums[digit]
					else:
						sums[digit] -= 4
					break
			if not found:
				print('NO')
				return
	if halfn * 2 != n:
		for i in range(halfn):
			found = False
			for digit in sums:
				if sums[digit] >= 2:
					found = True
					m[halfn][i] = digit
					m[halfn][n - 1 - i] = digit
					if sums[digit] == 2:
						del sums[digit]
					else:
						sums[digit] -= 2
					break
			if not found:
				print('NO')
				return
		for i in range(halfn):
			found = False
			for digit in sums:
				if sums[digit] >= 2:
					found = True
					m[i][halfn] = digit
					m[n - 1 - i][halfn] = digit
					if sums[digit] == 2:
						del sums[digit]
					else:
						sums[digit] -= 2
					break
			if not found:
				print('NO')
				return
		found = False
		for digit in sums:
			if sums[digit] >= 1:
				found = True
				m[halfn][halfn] = digit
				break
		if not found:
			print('NO')
			return
	print('YES')
	printMatrix(m)
n = int(input())
digits = list(input().strip().split())
solve(n, digits)


from collections import defaultdict
n = int(input())
arr = list(map(int, input().split()))
counts = defaultdict(int)
for a in arr:
	counts[a] += 1
if n == 1:
	print('YES')
	print(arr[0])
	exit(0)
matrix = [[None] * n for _ in range(n)]
if n % 2 == 0:
	vals = []
	for (val, cnt) in counts.items():
		if cnt % 4 != 0:
			print('NO')
			exit(0)
		vals.append((val, cnt))
	for i in range(n // 2):
		for j in range(n // 2):
			(val, cnt) = vals.pop(0)
			matrix[i][j] = val
			matrix[i][n - j - 1] = val
			matrix[n - i - 1][j] = val
			matrix[n - i - 1][n - j - 1] = val
			if cnt - 4 != 0:
				vals.append((val, cnt - 4))
	print('YES')
	for row in matrix:
		print(*row)
else:
	vals = []
	avail = True
	c = 0
	for (val, cnt) in counts.items():
		if cnt % 4 == 1 and avail:
			avail = False
			matrix[n // 2][n // 2] = val
			cnt -= 1
			if cnt != 0:
				vals.append((val, cnt))
		elif cnt % 4 == 3 and avail:
			avail = False
			matrix[n // 2][n // 2] = val
			if c < n // 2:
				matrix[n // 2][c] = val
				matrix[n // 2][n - c - 1] = val
				c += 1
			elif c < n - 1:
				i = c % (n // 2)
				matrix[i][n // 2] = val
				matrix[n - i - 1][n // 2] = val
				c += 1
			else:
				print('NO')
				exit(0)
			if cnt - 3 > 0:
				vals.append((val, cnt - 3))
		elif cnt % 4 == 0:
			vals.append((val, cnt))
		elif cnt % 2 == 0:
			if c < n // 2:
				matrix[n // 2][c] = val
				matrix[n // 2][n - c - 1] = val
				c += 1
			elif c < n - 1:
				i = c % (n // 2)
				matrix[i][n // 2] = val
				matrix[n - i - 1][n // 2] = val
				c += 1
			else:
				print('NO')
				exit(0)
			if cnt - 2 > 0:
				vals.append((val, cnt - 2))
		else:
			print('NO')
			exit(0)
	while c < n - 1:
		(val, cnt) = vals.pop(0)
		if c < n // 2:
			matrix[n // 2][c] = val
			matrix[n // 2][n - c - 1] = val
			c += 1
		else:
			i = c % (n // 2)
			matrix[i][n // 2] = val
			matrix[n - i - 1][n // 2] = val
			c += 1
		if cnt - 2 > 0:
			vals.insert(0, (val, cnt - 2))
	if vals[0][1] % 4 != 0:
		print('NO')
		exit(0)
	if avail:
		print('NO')
		exit(0)
	for i in range(n // 2):
		for j in range(n // 2):
			(val, cnt) = vals.pop(0)
			matrix[i][j] = val
			matrix[i][n - j - 1] = val
			matrix[n - i - 1][j] = val
			matrix[n - i - 1][n - j - 1] = val
			if cnt - 4 != 0:
				vals.append((val, cnt - 4))
	print('YES')
	for row in matrix:
		print(*row)


n = int(input())
a = list(map(int, input().split()))
d = {}
for i in a:
	d[i] = d.get(i, 0) + 1
if n % 2 == 0:
	ans = []
	for i in d:
		if d[i] % 4 != 0:
			print('NO')
			break
		ans = ans + [i] * (d[i] // 4)
	else:
		print('YES')
		for i in range(n // 2):
			for j in range(i * (n // 2), (i + 1) * (n // 2)):
				print(ans[j], end=' ')
			for j in range((i + 1) * (n // 2) - 1, i * (n // 2) - 1, -1):
				print(ans[j], end=' ')
			print()
		for i in range(n // 2 - 1, -1, -1):
			for j in range(i * (n // 2), (i + 1) * (n // 2)):
				print(ans[j], end=' ')
			for j in range((i + 1) * (n // 2) - 1, i * (n // 2) - 1, -1):
				print(ans[j], end=' ')
			print()
else:
	ans1 = []
	ans2 = []
	ans4 = []
	for i in d:
		ans4 = ans4 + [i] * (d[i] // 4)
		ans2 = ans2 + [i] * (d[i] % 4 // 2)
		ans1 = ans1 + [i] * (d[i] % 2)
	if len(ans1) != 1 or len(ans4) < (n // 2) ** 2:
		print('NO')
	else:
		print('YES')
		for i in range(len(ans4) - (n // 2) ** 2):
			a = ans4.pop()
			ans2 = ans2 + [a] * 2
		for i in range(n // 2):
			for j in range(n // 2):
				print(ans4[i * (n // 2) + j], end=' ')
			print(ans2[i], end=' ')
			for j in range(n // 2):
				print(ans4[i * (n // 2) + n // 2 - 1 - j], end=' ')
			print()
		for j in range(n // 2):
			print(ans2[j + n // 2], end=' ')
		print(ans1[0], end=' ')
		for j in range(n // 2):
			print(ans2[n // 2 - 1 - j + n // 2], end=' ')
		print()
		for i in range(n // 2):
			for j in range(n // 2):
				print(ans4[(n // 2 - 1 - i) * (n // 2) + j], end=' ')
			print(ans2[n // 2 - 1 - i], end=' ')
			for j in range(n // 2):
				print(ans4[(n // 2 - 1 - i) * (n // 2) + n // 2 - 1 - j], end=' ')
			print()


n = int(input())
a = list(map(int, input().split()))
d = {}
for i in a:
	if d.get(i):
		d[i] += 1
	else:
		d[i] = 1
b = [[0 for i in range(n)] for j in range(n)]
a.sort()
ind = 0
p = 0
if n % 2 == 0:
	for i in range(n // 2):
		t = 0
		for j in range(n // 2):
			if d[a[ind]] > 3:
				b[i][j] = a[ind]
				b[-1 - i][j] = a[ind]
				b[i][-1 - j] = a[ind]
				b[-1 - i][-1 - j] = a[ind]
				d[a[ind]] -= 4
				ind += 4
			else:
				p = 1
				t = 1
				break
		if t:
			break
else:
	i = 0
	l = len(a)
	while i < n // 2:
		j = 0
		t = 0
		while j < n // 2:
			if ind >= l:
				p = 1
				t = 1
				break
			if d[a[ind]] > 3:
				b[i][j] = a[ind]
				b[-1 - i][j] = a[ind]
				b[i][-1 - j] = a[ind]
				b[-1 - i][-1 - j] = a[ind]
				d[a[ind]] -= 4
				ind += 4
				j += 1
			else:
				ind += d[a[ind]]
		if t:
			break
		i += 1
	j = 0
	if p == 0:
		for i in d:
			while d[i] > 1 and j < n // 2:
				b[j][n // 2] = i
				b[-1 - j][n // 2] = i
				d[i] -= 2
				j += 1
	j = 0
	if p == 0:
		for i in d:
			while d[i] > 1 and j < n // 2:
				b[n // 2][j] = i
				b[n // 2][-1 - j] = i
				d[i] -= 2
				j += 1
	x = 0
	if p == 0:
		for i in d:
			if d[i] > 0 and x == 0:
				b[n // 2][n // 2] = i
				x = 1
			elif d[i] > 0 and x == 1:
				p = 1
				break
if p:
	print('NO')
else:
	print('YES')
	for i in range(n):
		for j in range(n):
			print(b[i][j], end=' ')
		print()


import sys
n = int(sys.stdin.readline())
a = [int(tmp) for tmp in sys.stdin.readline().split()]
df = dict()
for ea in a:
	if ea in df:
		df[ea] += 1
	else:
		df[ea] = 1
m = []
for i in range(n):
	m.append([0] * n)
yes = True
odd = n % 2
ndiv2 = n // 2
p4 = ndiv2 ** 2
p2h = odd * ndiv2
p2v = odd * ndiv2
p1 = int(odd)
(f4x, f4y) = (0, 0)
(f2h, f2v) = (0, 0)
f1 = 0
for ea in df:
	if not yes:
		break
	cc = df[ea]
	hi = 1
	while yes and cc > 0 and hi:
		if cc % 4 == 0 and p4 > 0:
			while cc > 0 and p4 > 0:
				m[f4y][f4x] = ea
				cc -= 4
				p4 -= 1
				f4x += 1
				if f4x >= ndiv2:
					f4x = 0
					f4y += 1
		elif cc % 2 == 0:
			if p2h > 0:
				m[ndiv2][f2h] = ea
				cc -= 2
				p2h -= 1
				f2h += 1
			elif p2v > 0:
				m[f2v][ndiv2] = ea
				cc -= 2
				p2v -= 1
				f2v += 1
			else:
				yes = False
				break
		elif p1 > 0:
			m[ndiv2][ndiv2] = ea
			cc -= 1
			p1 -= 1
			f1 += 1
		else:
			yes = False
			break
if yes:
	print('YES')
	if n > 1:
		for i in range(ndiv2 + odd):
			m[i][ndiv2 + odd:] = m[i][ndiv2 - 1::-1] + []
		for i in range(ndiv2):
			m[n - 1 - i] = m[i]
	for em in m:
		print(*em)
else:
	print('NO')


def gen_matrix(matrix, count, n):
	c = 0
	if n % 2 == 0:
		for i in range(n // 2):
			for j in range(n // 2):
				while count[c] == 0:
					c += 1
				matrix[i][j] = matrix[n - 1 - i][j] = matrix[i][n - 1 - j] = matrix[n - 1 - i][n - 1 - j] = c + 1
				count[c] -= 4
	else:
		for i in range(n // 2):
			for j in range(n // 2):
				while count[c] < 4:
					c += 1
				matrix[i][j] = matrix[n - 1 - i][j] = matrix[i][n - 1 - j] = matrix[n - 1 - i][n - 1 - j] = c + 1
				count[c] -= 4
		c = 0
		for i in range(n // 2):
			while count[c] < 2:
				c += 1
			matrix[i][n // 2] = matrix[n - 1 - i][n // 2] = c + 1
			count[c] -= 2
		for j in range(n // 2):
			while count[c] < 2:
				c += 1
			matrix[n // 2][j] = matrix[n // 2][n - 1 - j] = c + 1
			count[c] -= 2
		c = 0
		while count[c] < 1:
			c += 1
		matrix[n // 2][n // 2] = c + 1
n = int(input())
count = [0] * 1000
matrix = [[0] * n for _ in range(n)]
for a in map(int, input().split()):
	count[a - 1] += 1
even = n % 2
pair = (n - 1) * (n % 2)
for c in count:
	if c % 4:
		even -= c % 2
		pair -= 1 if c % 4 > 1 else 0
if even >= 0 and pair >= 0:
	print('YES')
	gen_matrix(matrix, count, n)
	for i in range(n):
		for j in range(n - 1):
			print(matrix[i][j], end=' ')
		print(matrix[i][n - 1])
else:
	print('NO')


n = int(input())
l = list(map(int, input().split()))
d = {}
for i in l:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
count = 0
for i in d:
	if d[i] % 2 == 1:
		count += 1
flag = True
if n % 2 == 0:
	for i in d:
		if d[i] % 4 != 0:
			flag = False
			print('NO')
			break
if flag:
	flag = True
	mat = [[0 for i in range(n)] for i in range(n)]
	m = n // 2
	left = {}
	temp = {}
	for i in d:
		if d[i] < 4:
			left[i] = d[i]
		else:
			temp[i] = d[i]
	d = temp
	for j in range(m):
		for i in range(m):
			if len(d) == 0:
				flag = False
				break
			ele = list(d.keys())[0]
			mat[i][j] = ele
			mat[i][n - 1 - j] = ele
			mat[n - 1 - i][j] = ele
			mat[n - 1 - i][n - 1 - j] = ele
			d[ele] -= 4
			if d[ele] == 0:
				del d[ele]
			elif d[ele] < 4:
				left[ele] = d[ele]
				del d[ele]
		if not flag:
			break
	if not flag:
		print('NO')
	else:
		flag = True
		for i in d:
			left[i] = d[i]
		if n % 2 == 1:
			count = 0
			mid_ele = 0
			for i in left:
				if left[i] % 2 == 1:
					count += 1
					mid_ele = i
					left[i] -= 1
			if count != 1:
				print('NO')
				flag = False
			else:
				if left[mid_ele] == 0:
					del left[mid_ele]
				for i in range(m):
					ele = list(left.keys())[0]
					mat[n // 2][i] = ele
					mat[n // 2][n - 1 - i] = ele
					left[ele] -= 2
					if left[ele] == 0:
						del left[ele]
				for i in range(m):
					if not left:
						flag = False
						print('NO')
						break
					ele = list(left.keys())[0]
					mat[i][n // 2] = ele
					mat[n - 1 - i][n // 2] = ele
					left[ele] -= 2
					if left[ele] == 0:
						del left[ele]
				mat[n // 2][n // 2] = mid_ele
		if flag:
			print('YES')
			for i in range(n):
				print(*mat[i])


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(RL())

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)

def toord(c):
	return ord(c) - ord('a')

def lcm(a, b):
	return a * b // gcd(a, b)
mod = 998244353
INF = float('inf')
from math import factorial, sqrt, ceil, floor, gcd
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	n = N()
	arr = RLL()
	ct = Counter(arr)
	res = [[0] * n for _ in range(n)]
	index = 0
	le = n // 2

	def put(value):
		nonlocal index
		(px, py) = (index // le, index % le)
		res[px][py] = value
		res[px][n - py - 1] = value
		res[n - px - 1][py] = value
		res[n - px - 1][n - py - 1] = value
		index += 1
	center = 0
	sd_index_v = 0
	sd_index_h = 0
	for (k, v) in ct.items():
		for _ in range(v // 4):
			if index == le ** 2:
				tag = 2
				while tag > 0:
					if sd_index_v < le:
						res[sd_index_v][le] = k
						res[n - 1 - sd_index_v][le] = k
						sd_index_v += 1
					else:
						res[le][sd_index_h] = k
						res[le][n - 1 - sd_index_h] = k
						sd_index_h += 1
					tag -= 1
			else:
				put(k)
		if v % 2 == 1:
			if n % 2 == 0:
				print('NO')
				break
			center += 1
			res[le][le] = k
		if v % 4 >= 2:
			if n % 2 == 0:
				print('NO')
				break
			if sd_index_v < le:
				res[sd_index_v][le] = k
				res[n - 1 - sd_index_v][le] = k
				sd_index_v += 1
			else:
				res[le][sd_index_h] = k
				res[le][n - 1 - sd_index_h] = k
				sd_index_h += 1
		if center > 1 or sd_index_h > le:
			print('NO')
			break
	else:
		print('YES')
		for i in res:
			print(*i)
main()


from collections import Counter
import math
import sys
n = int(input())
stock = Counter(map(int, input().split()))
subn = math.floor(n / 2)
use = [[0 for col in range(subn)] for row in range(subn)]
if n == 1:
	print('YES')
	print(stock.most_common(1)[0][0])
	exit()
for row in range(subn):
	for col in range(subn):
		mc = stock.most_common(1)[0]
		if mc[1] < 4:
			print('NO')
			exit()
		stock[mc[0]] -= 4
		use[row][col] = mc[0]
if n % 2:
	for row in range(subn):
		mc = stock.most_common(1)[0]
		if mc[1] < 2:
			print('NO')
			exit()
		stock[mc[0]] -= 2
		use[row].append(mc[0])
	use.append([])
	for col in range(subn):
		mc = stock.most_common(1)[0]
		if mc[1] < 2:
			print('NO')
			exit()
		stock[mc[0]] -= 2
		use[subn].append(mc[0])
	mc = stock.most_common(1)[0]
	if mc[1] < 1:
		print('NO')
		exit()
	use[subn].append(mc[0])
	subn += 1
print('YES')
for row in range(subn):
	for col in range(subn):
		print(use[row][col], end=' ')
	for col in reversed(range(1, subn - n % 2)):
		print(use[row][col], end=' ')
	print(use[row][0])
for row in reversed(range(1, subn - n % 2)):
	for col in range(subn):
		print(use[row][col], end=' ')
	for col in reversed(range(1, subn - n % 2)):
		print(use[row][col], end=' ')
	print(use[row][0])
for col in range(subn):
	print(use[0][col], end=' ')
for col in reversed(range(1, subn - n % 2)):
	print(use[0][col], end=' ')
print(use[0][0])


import random
storona = int(input())
mas = list(map(int, input().split(' ')))

def get_slovar(mas):
	sl = {}
	for i in mas:
		if i not in sl:
			sl[i] = 1
		else:
			sl[i] += 1
	return sl

def chet(sl, storona):
	sl_strok = {}
	for i in sl.values():
		if i % 4 != 0:
			return False
	for i in range(1, storona + 1):
		sl_strok[i] = []
	for i in range(1, storona // 2 + 1):
		for g in range(1, storona // 2 + 1):
			a = random.sample(sl.keys(), 1)[0]
			if sl[a] == 4:
				del sl[a]
			else:
				sl[a] = sl[a] - 4
			sl_strok[i] = [a] + sl_strok[i] + [a]
			sl_strok[storona - i + 1] = [a] + sl_strok[storona - i + 1] + [a]
	return sl_strok

def nechet(mas, storona):
	temp1 = 0
	krest = []
	sl_strok = {}
	sl = get_slovar(mas)
	sl_dvoek = {}
	vert = []
	goris = []
	for (key, value) in sl.items():
		if value % 2 != 0:
			sl[key] -= 1
			central = key
			break
	for (key, value) in sl.items():
		if value % 2 != 0:
			return False
		if value % 4 != 0:
			sl[key] -= 2
			sl_dvoek[key] = 2
	ostatok = (storona - 1) * 2 - sum(sl_dvoek.values())
	if ostatok < 0:
		return False
	if ostatok % 4 != 0:
		return False
	while ostatok > 0:
		a = random.sample(sl.keys(), 1)[0]
		if sl[a] >= 4:
			sl[a] -= 4
			if a not in sl_dvoek:
				sl_dvoek[a] = 4
			else:
				sl_dvoek[a] += 4
			ostatok -= 4
	sl = {key: value for (key, value) in sl.items() if value != 0}
	for i in range(storona - 1):
		a = random.sample(sl_dvoek.keys(), 1)[0]
		if sl_dvoek[a] == 2:
			del sl_dvoek[a]
		else:
			sl_dvoek[a] = sl_dvoek[a] - 2
		krest = [a] + krest + [a]
	sl_strok = chet(sl, storona - 1)
	goris = krest[:len(krest) // 4] + [central] + krest[-len(krest) // 4:]
	vert = krest[len(krest) // 4:-len(krest) // 4]
	vert = vert[:len(vert) // 2] + [central] + vert[len(vert) // 2:]
	sl_strok[storona / 2] = goris
	for i in sorted(sl_strok.keys()):
		if i != storona / 2:
			sl_strok[i] = sl_strok[i][:len(sl_strok[i]) // 2] + [vert[temp1]] + sl_strok[i][len(sl_strok[i]) // 2:]
		temp1 += 1
	return sl_strok
if storona % 2 == 0:
	a = chet(get_slovar(mas), storona)
else:
	a = nechet(mas, storona)
if not a:
	print('NO')
	exit()
else:
	print('YES')
for i in sorted(a.keys()):
	print(*a[i])


import sys
n = int(input())
l = list(map(int, input().split()))
freq = [0] * 1001
d = {}
for i in range(n * n):
	try:
		d[l[i]] += 1
	except:
		d[l[i]] = 1
ans = [[0] * n for i in range(n)]
if n % 2:
	for i in d:
		if d[i] & 1:
			ans[n // 2][n // 2] = i
			d[i] -= 1
			break
for x in d:
	jana_hai = x
	kitna = d[x]
	for i in range(n // 2):
		for j in range(n // 2):
			if ans[i][j] != 0:
				continue
			if kitna >= 4:
				ans[i][j] = ans[n - 1 - i][j] = ans[i][n - 1 - j] = ans[n - 1 - i][n - 1 - j] = jana_hai
				kitna -= 4
	if n % 2:
		for i in range(n // 2):
			if ans[i][n // 2] != 0:
				continue
			if kitna >= 2:
				ans[i][n // 2] = ans[n - 1 - i][n // 2] = jana_hai
				kitna -= 2
		for i in range(n // 2):
			if ans[n // 2][i] != 0:
				continue
			if kitna >= 2:
				ans[n // 2][i] = ans[n // 2][n - 1 - i] = jana_hai
				kitna -= 2
	if kitna > 0:
		print('NO')
		sys.exit(0)
print('YES')
for i in range(n):
	print(*ans[i])


n = int(input())
a = list(map(int, input().split()))
b = [[0 for i in range(n)] for j in range(n)]
o0 = []
o1 = []
o2 = []
o3 = 0
z = set(a)
for e in z:
	r = a.count(e)
	if r % 2 == 1:
		o1 += [e]
		r -= 1
	if r % 4 == 2:
		o2 += [e]
		r -= 2
	if r % 4 == 0:
		for i in range(r // 4):
			o0 += [e]
	else:
		o3 = 1
c = o0
c1 = o0[(n // 2) ** 2:] * 2 + o2
if o3 != 0:
	print('NO')
elif n % 2 == 0:
	if len(o1) != 0 or len(o2) != 0:
		print('NO')
	else:
		print('YES')
		for j in range(n // 2):
			for i in range(n // 2):
				b[j][i] = c[j * (n // 2) + i]
				b[n - 1 - j][i] = c[j * (n // 2) + i]
				b[j][n - 1 - i] = c[j * (n // 2) + i]
				b[n - 1 - j][n - 1 - i] = c[j * (n // 2) + i]
		for j in range(n):
			for i in range(n):
				print(b[j][i], end=' ')
			print()
elif len(o1) > 1 or len(o0) * 4 < n * n - 2 * n + 1 or len(o1) + len(o2) * 2 + len(o0) * 4 != n * n:
	print('NO')
else:
	print('YES')
	for j in range(n // 2):
		for i in range(n // 2):
			b[j][i] = c[j * (n // 2) + i]
			b[n - 1 - j][i] = c[j * (n // 2) + i]
			b[j][n - 1 - i] = c[j * (n // 2) + i]
			b[n - 1 - j][n - 1 - i] = c[j * (n // 2) + i]
	for j in range(n // 2):
		b[j][n // 2] = c1[j]
		b[n - 1 - j][n // 2] = c1[j]
	for j in range(n // 2):
		b[n // 2][j] = c1[j + n // 2]
		b[n // 2][n - 1 - j] = c1[j + n // 2]
	b[n // 2][n // 2] = o1[0]
	for j in range(n):
		for i in range(n):
			print(b[j][i], end=' ')
		print()


from collections import defaultdict
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
cnt = defaultdict(lambda : 0)
for i in a:
	cnt[i] += 1
b = [[-1] * n for _ in range(n)]
x = [[] for _ in range(5)]
for i in range((n + 1) // 2):
	for j in range((n + 1) // 2):
		s = set()
		s.add((i, j))
		s.add((n - i - 1, j))
		s.add((i, n - j - 1))
		s.add((n - i - 1, n - j - 1))
		s = list(s)
		x[len(s)].append(s)
for i in [4, 2, 1]:
	for j in cnt:
		while cnt[j] >= i and x[i]:
			y = x[i].pop()
			cnt[j] -= i
			for (k, l) in y:
				b[k][l] = j
ans = 'YES' if not max((cnt[i] for i in cnt)) else 'NO'
print(ans)
if ans == 'YES':
	for b0 in b:
		print(*b0)


n = int(input())
a = list(map(int, input().split()))
d = {i: 0 for i in set(a)}
for i in a:
	d[i] += 1
k = 0
ii = -1
r = []
for i in range(n):
	r.append([0] * n)
if n % 2 == 0:
	m = n // 2
	cur = 0
	for i in d:
		if d[i] % 4:
			k += 1000000
			break
		while d[i]:
			r[cur % m][cur // m] = i
			r[n - cur % m - 1][cur // m] = i
			r[cur % m][n - cur // m - 1] = i
			r[n - cur % m - 1][n - cur // m - 1] = i
			cur += 1
			d[i] -= 4
else:
	q = w = 0
	m = n // 2
	cur = 0
	s = 0
	for i in d:
		if d[i] % 2:
			q += 1
			if q > 1:
				k += 100000
				break
			r[m][m] = i
			d[i] -= 1
		if d[i] % 4:
			w += 2
			d[i] -= 2
			if w > 4 * m:
				k += 100000
				break
			if s < m:
				r[m][s] = i
				r[m][n - s - 1] = i
			else:
				r[s - m][m] = i
				r[n - s + m - 1][m] = i
			s += 1
		while d[i]:
			if cur >= m * m:
				if s < m:
					r[m][s] = i
					r[m][n - s - 1] = i
				else:
					r[s - m][m] = i
					r[n - s + m - 1][m] = i
				s += 1
				d[i] -= 2
			else:
				r[cur % m][cur // m] = i
				r[n - cur % m - 1][cur // m] = i
				r[cur % m][n - cur // m - 1] = i
				r[n - cur % m - 1][n - cur // m - 1] = i
				cur += 1
				d[i] -= 4
if k > 100:
	print('NO')
else:
	print('YES')
	for i in r:
		print(*i)


import collections
n = int(input())
a = list(map(int, input().split()))
try:
	matrix = [[1]]
	for i in range(1, 12):
		matrix.append([4 for j in range(len(matrix[-1]))])
		matrix.append(sorted(matrix[-2] + [2, 2] + [4 for j in range(i * 2 - 1)], reverse=True))
	nowmatrix = matrix[n - 1]
	nowmatrix = collections.Counter(nowmatrix)
	nowmatrix = nowmatrix.most_common()
	matrix = []
	for i in range(len(nowmatrix)):
		matrix.append(list(nowmatrix[i]))
	matrix.sort(reverse=True)
	a = collections.Counter(a)
	a = a.most_common()
	alist = []
	for i in range(len(a)):
		alist.append(list(a[i]))
	ans = []
	for i in range(len(alist)):
		count = alist[i][1] // 4
		alist[i][1] -= 4 * count
		ans += [alist[i][0] for j in range(count)]
	if n % 2 == 1:
		if len(ans) >= matrix[0][1]:
			ans += ans[matrix[0][1]:]
			for i in range(len(alist)):
				count = alist[i][1] // 2
				alist[i][1] -= 2 * count
				ans += [alist[i][0] for j in range(count)]
			if len(ans) == matrix[0][1] + matrix[1][1]:
				for i in range(len(alist)):
					count = alist[i][1]
					alist[i][1] -= count
					ans += [alist[i][0] for j in range(count)]
			else:
				ans = -1
		else:
			ans = -1
	elif len(ans) != matrix[0][1]:
		ans = -1
	if n == 1:
		print('YES')
		print(alist[0][0])
	elif ans == -1:
		print('NO')
	else:
		ansmatrix = [[0 for i in range(n)] for j in range(n)]
		count = 0
		for i in range(n // 2):
			for j in range(n // 2):
				ansmatrix[i][j] = ans[count]
				ansmatrix[n - 1 - i][n - 1 - j] = ans[count]
				ansmatrix[n - 1 - i][j] = ans[count]
				ansmatrix[i][n - 1 - j] = ans[count]
				count += 1
		if n % 2 == 1:
			for i in range(n // 2):
				ansmatrix[n // 2][i] = ans[count]
				ansmatrix[n // 2][n - 1 - i] = ans[count]
				count += 1
			for i in range(n // 2):
				ansmatrix[i][n // 2] = ans[count]
				ansmatrix[n - 1 - i][n // 2] = ans[count]
				count += 1
			ansmatrix[n // 2][n // 2] = ans[count]
		print('YES')
		for i in range(len(ansmatrix)):
			print(' '.join(map(str, ansmatrix[i])))
except:
	print('NO')


n = int(input())
arr = list(map(int, input().split()))
if n == 1:
	print('YES')
	print(arr[0])
elif n % 2 == 0:
	arr1 = list(set(arr))
	arr2 = []
	if len(arr1) > n * n // 4:
		print('NO')
	else:
		for a in arr1:
			b = arr.count(a)
			if b % 4 != 0:
				print('NO')
				break
			else:
				arr2.append(b)
		if len(arr1) == len(arr2):
			i = 0
			ans = [[] for z in range(n // 2)]
			j = 0
			while j < n // 2:
				k = 0
				while k < n // 2:
					if arr2[i] == 0:
						i += 1
					ans[k].append(str(arr1[i]))
					arr2[i] -= 4
					k += 1
				j += 1
			g = 0
			while g < n // 2:
				ans[g] += ans[g][::-1]
				g += 1
			ans += ans[::-1]
			print('YES')
			for a in ans:
				print(' '.join(a))
else:
	arr1 = list(set(arr))
	arr2 = []
	arr3 = []
	for a in arr1:
		b = arr.count(a)
		arr2.append(b % 4)
		arr3.append(b - b % 4)
	if sum(arr3) < (n - 1) * (n - 1):
		print('NO')
	else:
		i = 0
		ans = [[] for z in range(n // 2)]
		j = 0
		while j < n // 2:
			k = 0
			while k < n // 2:
				while arr3[i] == 0:
					i += 1
				ans[k].append(str(arr1[i]))
				arr3[i] -= 4
				k += 1
			j += 1
		i = 0
		h = 0
		while i < len(arr1):
			arr2[i] = arr2[i] + arr3[i]
			if arr2[i] % 2 == 1:
				h += 1
				p = i
				arr2[i] -= 1
			i += 1
		if h > 1:
			print('NO')
		else:
			print('YES')
			i = 0
			j = 0
			while i < n // 2:
				while arr2[j] == 0:
					j += 1
				ans[i] = ans[i] + [str(arr1[j])] + ans[i][::-1]
				arr2[j] -= 2
				i += 1
			i = 0
			v = []
			while i < n // 2:
				while arr2[j] == 0:
					j += 1
				v.append(str(arr1[j]))
				arr2[j] -= 2
				i += 1
			for el in ans:
				print(' '.join(el))
			print(' '.join(v) + ' ' + str(arr1[p]) + ' ' + ' '.join(v[::-1]))
			for el in ans[::-1]:
				print(' '.join(el))


def print_out():
	for i in range(n):
		for j in range(n):
			print(matrix[i][j], end=' ')
		print()
n = int(input())
matrix = [[0] * n for i in range(n)]
ls = list(map(int, input().split()))
numbers = [0] * 1020
for x in ls:
	numbers[x] += 1
if n % 2 == 0:
	u = n // 2
	tmp = 0
	ptr = 0
	able = True
	for i in range(1020):
		if numbers[i] % 4 > 0:
			print('NO')
			quit()
	print('YES')
	while tmp < u * u:
		if numbers[ptr] == 0:
			ptr += 1
			continue
		else:
			numbers[ptr] -= 4
			matrix[tmp // u][tmp % u] = ptr
			tmp += 1
			continue
	for i in range(u):
		for j in range(u):
			matrix[n - i - 1][n - j - 1] = matrix[i][j]
			matrix[i][n - j - 1] = matrix[i][j]
			matrix[n - i - 1][j] = matrix[i][j]
	print_out()
else:
	u = n // 2
	tmp = 0
	ptr = 0
	while tmp < u * u:
		if ptr > 1000:
			print('NO')
			quit()
		if numbers[ptr] < 4:
			ptr += 1
			continue
		else:
			numbers[ptr] -= 4
			matrix[tmp // u][tmp % u] = ptr
			tmp += 1
			continue
	for i in range(u):
		for j in range(u):
			matrix[n - i - 1][n - j - 1] = matrix[i][j]
			matrix[i][n - j - 1] = matrix[i][j]
			matrix[n - i - 1][j] = matrix[i][j]
	able = 0
	only = 0
	for i in range(1020):
		if numbers[i] % 2 > 0:
			able += 1
			only = i
	if able == 1:
		print('YES')
	else:
		print('NO')
		quit()
	var = u
	numbers[only] -= 1
	matrix[var][var] = only
	tmp = 0
	ptr = 0
	while tmp < u:
		if ptr > 1000:
			print('NO')
			quit()
		elif numbers[ptr] < 2:
			ptr += 1
			continue
		else:
			numbers[ptr] -= 2
			matrix[tmp][var] = ptr
			matrix[n - tmp - 1][var] = ptr
			tmp += 1
			continue
	tmp = 0
	ptr = 0
	while tmp < u:
		if ptr > 1000:
			print('NO')
			quit()
		elif numbers[ptr] < 2:
			ptr += 1
			continue
		else:
			numbers[ptr] -= 2
			matrix[var][tmp] = ptr
			matrix[var][n - tmp - 1] = ptr
			tmp += 1
			continue
	print_out()


n = int(input())
a = list(map(int, input().split()))
d = {}
res = [[0] * n for i in range(n)]
for i in a:
	d[i] = d.get(i, 0) + 1

def put(a, i, j, k, d):
	d[k] -= 4
	a[i][j] = k
	a[n - i - 1][j] = k
	a[i][n - j - 1] = k
	a[n - i - 1][n - j - 1] = k
for i in range(n // 2):
	for j in range(n // 2):
		for k in d:
			if d[k] >= 4:
				put(res, i, j, k, d)
				break
if n % 2 == 1:
	for i in range(n // 2):
		for k in d:
			if d[k] >= 2:
				d[k] -= 2
				res[i][n // 2] = k
				res[n - i - 1][n // 2] = k
				break
		for k in d:
			if d[k] >= 2:
				d[k] -= 2
				res[n // 2][i] = k
				res[n // 2][n - i - 1] = k
				break
if n % 2 == 1:
	for k in d:
		if d[k] >= 1:
			d[k] -= 1
			res[n // 2][n // 2] = k
			break
if any((v for (k, v) in d.items())):
	print('NO')
	exit()
print('YES')
for i in res:
	print(' '.join(map(str, i)))


n = int(input())
d = {}
for x in map(int, input().split()):
	d[x] = d.get(x, 0) + 1
(x, x_1, y, flag) = (0, 0, 0, 1)
a = [[0 for i in range(n)] for i in range(n)]
for z in d:
	if n % 2 == 0:
		while d[z] - 4 >= 0:
			(a[x][y], a[x][n - y - 1], a[n - x - 1][y], a[n - x - 1][n - y - 1]) = (z, z, z, z)
			d[z] -= 4
			x += 1
			(x, y) = (x % (n // 2), y + x // (n // 2))
	else:
		while d[z] - 4 >= 0 and x < n // 2 and (y < n // 2):
			(a[x][y], a[x][n - y - 1], a[n - x - 1][y], a[n - x - 1][n - y - 1]) = (z, z, z, z)
			d[z] -= 4
			x += 1
			(x, y) = (x % (n // 2), y + x // (n // 2))
		while d[z] >= 2 and flag < 3:
			if flag == 1:
				(a[x_1][n // 2], a[n - x_1 - 1][n // 2]) = (z, z)
				d[z] -= 2
				x_1 += 1
				if x_1 == n // 2:
					(flag, x_1) = (2, 0)
			elif flag == 2:
				(a[n // 2][x_1], a[n // 2][n - x_1 - 1]) = (z, z)
				d[z] -= 2
				x_1 += 1
				if x_1 == n // 2:
					(flag, x_1) = (3, 0)
		if d[z] == 1 and a[n // 2][n // 2] == 0:
			a[n // 2][n // 2] = z
			d[z] -= 1
	if d[z] > 0:
		print('NO')
		exit()
print('YES')
for x in a:
	print(*x)


n = int(input())
a = list(map(int, input().split()))
if n == 1:
	print('YES')
	print(a[0])
	exit()
cnt = [0] * 1001
for _ in a:
	cnt[_] += 1
(odd, x) = (0, -1)
for (i, _) in enumerate(cnt):
	if _ % 2:
		odd += 1
		x = i
if odd > 1 or (n % 2 == 0 and odd):
	print('NO')
	exit()
ans = [[0] * n for _ in range(n)]
if n % 2:
	ans[n // 2][n // 2] = x
	cnt[x] -= 1
for i in range(n // 2):
	for j in range(n // 2):
		for (v, _) in enumerate(cnt):
			if _ >= 4:
				ans[i][j] = ans[n - 1 - i][j] = ans[i][n - 1 - j] = ans[n - 1 - i][n - 1 - j] = v
				cnt[v] -= 4
				break
if n % 2:
	for i in range(n // 2):
		for (v, _) in enumerate(cnt):
			if _ >= 2:
				ans[i][n // 2] = ans[n - 1 - i][n // 2] = v
				cnt[v] -= 2
				break
	for j in range(n // 2):
		for (v, _) in enumerate(cnt):
			if _ >= 2:
				ans[n // 2][j] = ans[n // 2][n - 1 - j] = v
				cnt[v] -= 2
				break
y = 0
for i in range(n):
	for j in range(n):
		if ans[i][j] == 0:
			y += 1
if y:
	print('NO')
else:
	print('YES')
	for i in range(n):
		for j in range(n):
			print(ans[i][j], end=' ')
		print()


n = int(input())
a = list(map(int, input().split()))
s = {}
for q in a:
	s[q] = s.get(q, 0) + 1
if n % 2 == 0:
	if all((q % 4 == 0 for q in s.values())):
		print('YES')
		keys1 = []
		for q in s:
			keys1.extend([q] * (s[q] // 4))
		ans1 = []
		for q in range(len(keys1)):
			if q % (n // 2) == 0:
				ans1.append([keys1[q]])
			else:
				ans1[-1].append(keys1[q])
		for q in range(n // 2):
			ans1[q].extend(ans1[q][::-1])
		for q in range(n // 2 - 1, -1, -1):
			ans1.append([])
			for q1 in range(n):
				ans1[-1].append(ans1[q][q1])
		for q in range(n):
			print(*ans1[q])
	else:
		print('NO')
else:
	(center, center2) = (set(), set())
	for q in range(len(a)):
		if s[a[q]] % 2 == 1:
			center.add(a[q])
		if s[a[q]] % 4 > 1:
			center2.add(a[q])
	(center, center2) = (list(center), list(center2))
	if len(center) != 1 or len(center2) > n - 1:
		print('NO')
	else:
		print('YES')
		keys = []
		for q in s:
			keys.extend([q] * (s[q] // 4))
		ans = []
		for q in range(n // 2 * (n // 2)):
			if q % (n // 2) == 0:
				ans.append([keys[q]])
			else:
				ans[-1].append(keys[q])
		(q2, q3) = (0, n // 2 * (n // 2) * 2)
		for q in range(n // 2):
			if q2 < len(center2):
				ans[q].append(center2[q2])
				q2 += 1
			else:
				ans[q].append(keys[q3 // 2])
				q3 += 1
			ans[q].extend(ans[q][:-1][::-1])
		ans.append([])
		for _ in range(n // 2):
			if q2 < len(center2):
				ans[n // 2].append(center2[q2])
				q2 += 1
			else:
				ans[n // 2].append(keys[q3 // 2])
				q3 += 1
		ans[n // 2].append(center[0])
		ans[n // 2].extend(ans[n // 2][:n // 2][::-1])
		for q in range(n // 2 - 1, -1, -1):
			ans.append([])
			for q1 in range(n):
				ans[-1].append(ans[q][q1])
		for q in range(n):
			print(*ans[q])


from sys import stdin, stdout

def getKey(item):
	return item[1]

def inp():
	return stdin.readline()

def minp():
	return map(int, stdin.readline().rstrip().split())

def linp():
	return list(minp())

def main():
	n = int(inp())
	l = linp()
	ll = list(set(l))
	cnt = 0
	a = [[0 for x in range(n)] for y in range(n)]
	if n == 1:
		print('YES')
		print(*l)
		exit()
	if n % 2 == 0:
		if len(ll) <= int(n / 2) * int(n / 2):
			num = []
			for i in ll:
				c = l.count(i)
				if c % 4 == 0:
					x = int(c / 4)
					cnt += x
					for j in range(x):
						num.append(i)
				else:
					print('NO')
					exit()
			if cnt == int(n / 2) * int(n / 2):
				print('YES')
				pos = 0
				for j in range(int(n / 2)):
					for k in range(int(n / 2)):
						a[j][k] = num[pos]
						a[j][n - k - 1] = num[pos]
						a[n - j - 1][k] = num[pos]
						a[n - j - 1][n - k - 1] = num[pos]
						pos += 1
				for j in range(n):
					print(*a[j])
			else:
				print('NO')
				exit()
		else:
			print('NO')
			exit()
	else:
		num = []
		ex = []
		f = 0
		d = []
		f = 0
		for i in ll:
			d.append([i, l.count(i)])
		d = sorted(d, key=getKey, reverse=True)
		for i in range(len(ll)):
			c = int(d[i][1] / 4)
			d[i][1] -= c * 4
			cnt += c
			for j in range(c):
				num.append(d[i][0])
			if cnt >= int(n / 2) * int(n / 2):
				d[i][1] += (cnt - int(n / 2) * int(n / 2)) * 4
				f = 1
				break
		if f == 0:
			print('NO')
			exit()
		pos = 0
		for j in range(int(n / 2)):
			for k in range(int(n / 2)):
				a[j][k] = num[pos]
				a[j][n - k - 1] = num[pos]
				a[n - j - 1][k] = num[pos]
				a[n - j - 1][n - k - 1] = num[pos]
				pos += 1
		f = 0
		pos = 0
		p = 0
		while p < int(n / 2):
			if d[pos][1] % 2 == 0:
				c = int(d[pos][1] / 2)
				for j in range(c):
					a[int(n / 2)][p] = d[pos][0]
					a[int(n / 2)][n - p - 1] = d[pos][0]
					d[pos][1] -= 2
					p += 1
					if p >= int(n / 2):
						break
				pos += 1
			elif f == 0:
				f = 1
				c = int(d[pos][1] / 2)
				for j in range(c):
					a[int(n / 2)][p] = d[pos][0]
					a[int(n / 2)][n - p - 1] = d[pos][0]
					d[pos][1] -= 2
					p += 1
					if p >= int(n / 2):
						break
				a[int(n / 2)][int(n / 2)] = d[pos][0]
				d[pos][1] -= 1
			else:
				print('NO')
				exit()
		p = 0
		pos = 0
		while p < int(n / 2):
			if d[pos][1] % 2 == 0:
				c = int(d[pos][1] / 2)
				for j in range(c):
					a[p][int(n / 2)] = d[pos][0]
					a[n - p - 1][int(n / 2)] = d[pos][0]
					d[pos][1] -= 2
					p += 1
					if p >= int(n / 2):
						break
				pos += 1
			else:
				d[pos][1]
				if f == 0:
					f = 1
					c = int(d[pos][1] / 2)
					for j in range(c):
						a[p][int(n / 2)] = d[pos][0]
						a[n - p - 1][int(n / 2)] = d[pos][0]
						p += 1
						d[pos][1] -= 2
						if p >= int(n / 2):
							break
					a[int(n / 2)][int(n / 2)] = d[pos][0]
					d[pos][1] -= 1
				else:
					print('NO')
					exit()
		if a[int(n / 2)][int(n / 2)] == 0:
			a[int(n / 2)][int(n / 2)] = d[-1][0]
		print('YES')
		for j in range(n):
			print(*a[j])
main()


n = int(input())
arr = list(map(int, input().split()))
temparr = [0] * 1001
for i in range(len(arr)):
	temparr[arr[i]] += 1
flag = 0
count = 0
arr2 = []
arr3 = []
for i in range(1, 1001):
	if temparr[i] % 2 != 0:
		count += 1
	elif temparr[i] % 4 == 0:
		arr2.append(i)
	elif temparr[i] % 2 == 0:
		arr3.append(i)
ansarr = []
for i in range(n):
	ansarr.append([0] * n)
if n % 2 == 0 and count != 0:
	print('NO')
elif n % 2 != 0 and count > 1:
	print('NO')
elif n % 2 == 0:
	if len(arr3) != 0:
		print('NO')
	else:
		print('YES')
		index = 1
		for j in range(n // 2):
			for i in range(n // 2):
				while temparr[index] < 4:
					index += 1
				ansarr[i][j] = index
				ansarr[i][n - j - 1] = index
				ansarr[n - i - 1][j] = index
				ansarr[n - i - 1][n - j - 1] = index
				temparr[index] -= 4
		for i in range(n):
			print(*ansarr[i])
else:
	for j in range(n // 2):
		for i in range(n // 2):
			flag = 0
			for k in range(1, 1001):
				if temparr[k] >= 4:
					ansarr[i][j] = k
					ansarr[i][n - j - 1] = k
					ansarr[n - i - 1][j] = k
					ansarr[n - i - 1][n - j - 1] = k
					temparr[k] -= 4
					flag = 1
					break
			if flag == 0:
				print('NO')
				exit(0)
	for j in range(n // 2):
		flag = 0
		for k in range(1, 1001):
			if temparr[k] >= 2:
				ansarr[n // 2][j] = k
				ansarr[n // 2][n - j - 1] = k
				temparr[k] -= 2
				flag = 1
				break
		if flag == 0:
			print('NO')
			exit(0)
	for i in range(n // 2):
		flag = 0
		for k in range(1, 1001):
			if temparr[k] >= 2:
				ansarr[i][n // 2] = k
				ansarr[n - i - 1][n // 2] = k
				temparr[k] -= 2
				flag = 1
				break
		if flag == 0:
			print('NO')
			exit(0)
	for k in range(1, 1001):
		if temparr[k] == 1:
			ansarr[n // 2][n // 2] = k
			flag = 1
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')
		for i in range(n):
			print(*ansarr[i])


from collections import *
(n, a) = (int(input()), list(map(int, input().split())))
(ans, c) = ([[0 for i in range(n)] for j in range(n)], list(map(list, Counter(a).most_common())))
for i in range(n // 2):
	for j in range(n // 2):
		if c[0][1] >= 4:
			ans[i][j] = ans[i][n - j - 1] = ans[n - i - 1][j] = ans[n - i - 1][n - j - 1] = c[0][0]
			c[0][1] -= 4
		else:
			exit(print('no'))
		c.sort(reverse=True, key=lambda x: x[1])
if n & 1:
	for i in range(n // 2):
		if c[0][1] >= 2:
			ans[n // 2][i] = ans[n // 2][n - i - 1] = c[0][0]
			c[0][1] -= 2
		else:
			exit(print('no'))
		c.sort(reverse=True, key=lambda x: x[1])
		if c[0][1] >= 2:
			ans[i][n // 2] = ans[n - i - 1][n // 2] = c[0][0]
			c[0][1] -= 2
		else:
			exit(print('no'))
		c.sort(reverse=True, key=lambda x: x[1])
	ans[n // 2][n // 2] = c[0][0]
print('YES')
for i in range(n):
	print(*ans[i])


num = int(input().strip())
num_dict = dict()
nums = [int(i) for i in input().strip().split()]
for i in nums:
	if i not in num_dict:
		num_dict[i] = 1
	else:
		num_dict[i] += 1
matrix = [[0 for i in range(num)] for j in range(num)]
mid = num // 2
if num % 2 != 0:
	for key in num_dict:
		if num_dict[key] != 0 and num_dict[key] % 2 != 0:
			matrix[mid][mid] = key
			num_dict[key] -= 1
			break
for row in range(num // 2):
	for col in range(num // 2):
		if matrix[row][col] == 0:
			for key in num_dict:
				if num_dict[key] >= 4 and num_dict[key] % 2 == 0:
					matrix[row][col] = key
					matrix[row][num - col - 1] = key
					matrix[num - row - 1][col] = key
					matrix[num - row - 1][num - col - 1] = key
					num_dict[key] -= 4
					break
if num % 2 != 0:
	for col in range(num):
		if col != mid and matrix[mid][col] == 0:
			for key in num_dict:
				if num_dict[key] != 0 and num_dict[key] % 2 == 0:
					matrix[mid][col] = key
					matrix[mid][num - col - 1] = key
					num_dict[key] -= 2
					break
	for row in range(num):
		if row != mid and matrix[row][mid] == 0:
			for key in num_dict:
				if num_dict[key] != 0 and num_dict[key] % 2 == 0:
					matrix[row][mid] = key
					matrix[num - row - 1][mid] = key
					num_dict[key] -= 2
					break
yes = True
for i in matrix:
	for j in i:
		if j == 0:
			yes = False
			break
if yes:
	print('Yes')
	for row in matrix:
		print(' '.join((str(i) for i in row)))
else:
	print('No')


import os
from io import BytesIO, StringIO
from collections import defaultdict

def input_as_list():
	return list(map(int, input().split()))

def array_of(f, *dim):
	return [array_of(f, *dim[1:]) for _ in range(dim[0])] if dim else f()

def main():
	n = int(input())
	a = input_as_list()
	out = array_of(int, n, n)

	def put(x, i, j):
		out[i][j] = x
		out[n - i - 1][j] = x
		out[i][n - j - 1] = x
		out[n - i - 1][n - j - 1] = x
	d = defaultdict(int)
	for x in a:
		d[x] += 1
	if n % 2 == 0:
		for v in d.values():
			if v % 4 != 0:
				print('NO')
				return
		ix = 0
		for k in d.keys():
			for _ in range(d[k] // 4):
				(i, j) = divmod(ix, n // 2)
				put(k, i, j)
				ix += 1
	else:
		ones = []
		twos = []
		fours = []
		for (k, v) in d.items():
			if v % 2 != 0:
				if ones:
					print('NO')
					return
				else:
					ones.append(k)
					d[k] -= 1
		for (k, v) in d.items():
			if v % 4 != 0:
				if len(twos) >= n:
					print('NO')
					return
				else:
					twos.append(k)
					d[k] -= 2
		for (k, v) in d.items():
			if v % 4 != 0:
				print('NO')
				return
			else:
				for _ in range(v // 4):
					fours.append(k)
		if not ones:
			print('NO')
			return
		while len(twos) < n - 1:
			k = fours.pop()
			twos.append(k)
			twos.append(k)
		ix = 0
		for k in fours:
			(i, j) = divmod(ix, n // 2)
			put(k, i, j)
			ix += 1
		for i in range(n // 2):
			k = twos.pop()
			put(k, i, n // 2)
		for i in range(n // 2):
			k = twos.pop()
			put(k, n // 2, i)
		put(ones[0], n // 2, n // 2)
	out_str = ['YES\n']
	for i in range(n):
		for j in range(n):
			out_str.append(str(out[i][j]) + ' ')
		out_str.append('\n')
	print(''.join(out_str))
main()


n = int(input())
List = list(map(int, input().split()))
d = {}
for i in List:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
List1 = []
i = 0
for i in range(n):
	List2 = []
	for j in range(n):
		List2.append(i)
	List1.append(List2)
cn = n
count = 0
count1 = 0
n //= 2
if n == 0:
	print('YES')
	s = ''.join(map(str, List))
	print(s)
for i in range(n):
	for j in range(n):
		for k in d:
			if d[k] >= 4:
				d[k] -= 4
				List1[i][j] = k
				List1[cn - 1 - i][j] = k
				List1[i][cn - 1 - j] = k
				List1[cn - 1 - i][cn - 1 - j] = k
				count += 1
				break
		if count == 0:
			print('NO')
			count1 = 0
			break
		else:
			count = 0
			count1 += 1
	if count1 == 0:
		break
if count1 != 0:
	if cn % 2 == 0:
		print('YES')
		for i in range(len(List1)):
			s = ' '.join(map(str, List1[i]))
			print(s)
	else:
		j = n
		for i in range(n):
			count = 0
			for k in d:
				if d[k] >= 2:
					d[k] -= 2
					List1[i][j] = k
					List1[cn - 1 - i][j] = k
					count += 1
					break
			if count == 0:
				print('NO')
				count1 = 0
				break
		if count1 != 0:
			i = n
			for j in range(n):
				count = 0
				for k in d:
					if d[k] >= 2:
						d[k] -= 2
						List1[i][j] = k
						List1[i][cn - 1 - j] = k
						count += 1
						break
				if count == 0:
					print('NO')
					count1 = 0
					break
		if count1 != 0:
			i = n
			j = n
			for k in d:
				if d[k] > 0:
					List1[i][j] = k
					break
			print('YES')
			for i in range(len(List1)):
				s = ' '.join(map(str, List1[i]))
				print(s)


def draw(arr, size, i, j, value):
	arr[i][j] = value
	arr[i][size - 1 - j] = value
	arr[size - 1 - i][j] = value
	arr[size - 1 - i][size - 1 - j] = value

def drawRow(arr, size, index, value):
	arr[index][size // 2] = value
	arr[size - 1 - index][size // 2] = value

def drawCol(arr, size, index, value):
	arr[size // 2][index] = value
	arr[size // 2][size - 1 - index] = value

def printt(arr, size):
	for i in range(size):
		print(*arr[i])
size = int(input())
items = list(map(int, input().split()))
log = {}
quads = []
twos = []
one = -1
x = False
for i in items:
	if i in log:
		log[i] += 1
		if log[i] % 4 == 0:
			quads.append(i)
	else:
		log[i] = 1
for (key, value) in log.items():
	if value % 4 == 1:
		one = key
	if value % 4 == 3:
		if one != -1:
			x = True
		else:
			twos.append(key)
			one = key
	elif value % 4 == 2:
		twos.append(key)
if size % 2 == 0:
	if (size / 2) ** 2 == len(quads):
		print('YES')
		drawing = [[0] * size for i in range(size)]
		for i in range(size // 2):
			for j in range(size // 2):
				value = quads.pop()
				draw(drawing, size, i, j, value)
		printt(drawing, size)
	else:
		print('NO')
elif len(quads) < (size // 2) ** 2 or one == -1 or x:
	print('NO')
else:
	temp4 = len(quads) - (size // 2) ** 2
	temp2 = len(twos) + temp4 * 2
	if temp2 == size - 1:
		print('YES')
		drawing = [[0] * size for i in range(size)]
		for i in range(size // 2):
			for j in range(size // 2):
				value = quads.pop()
				draw(drawing, size, i, j, value)
		while len(quads) > 0:
			value = quads.pop()
			twos.append(value)
			twos.append(value)
		for i in range(size // 2):
			value = twos.pop()
			drawRow(drawing, size, i, value)
			value = twos.pop()
			drawCol(drawing, size, i, value)
		drawing[size // 2][size // 2] = one
		printt(drawing, size)
	else:
		print('NO')


n = int(input())
cnt = [0] * 1007
a = [[0] * 20 for i in range(20)]
der = list(map(int, input().split()))
for i in der:
	cnt[i] += 1
cel = []
for i in range((n + 1) // 2):
	for j in range((n + 1) // 2):
		if i != n - i - 1 and j != n - j - 1:
			cel.append((4, (i, j)))
		elif (i != n - i - 1) ^ (j != n - j - 1):
			cel.append((2, (i, j)))
		else:
			cel.append((1, (i, j)))
for cur in [4, 2, 1]:
	lst = 1
	for it in cel:
		if it[0] != cur:
			continue
		i = it[1][0]
		j = it[1][1]
		while lst < 1007 and cnt[lst] < cur:
			lst += 1
		if lst == 1007:
			print('NO')
			exit(0)
		a[i][j] = a[n - i - 1][j] = a[i][n - j - 1] = a[n - i - 1][n - j - 1] = lst
		cnt[lst] -= cur
print('YES')
for i in range(n):
	print(*a[i][:n])


from collections import Counter
n = int(input())
m = list(map(int, input().split()))
r = [[0 for _ in range(n)] for _ in range(n)]
if n % 2 == 0:
	c = Counter(m)
	ans = []
	for x in c:
		if c[x] % 4 != 0:
			print('NO')
			break
		else:
			ans.extend([x] * (c[x] // 4))
	else:
		x = n // 2 * (n // 2)
		i = 0
		j = 0
		for x in ans:
			r[i][j] = x
			r[i][-j - 1] = x
			r[-i - 1][j] = x
			r[-i - 1][-j - 1] = x
			j += 1
			if j == n // 2:
				j = 0
				i += 1
		print('YES')
		for x in r:
			print(*x)
else:
	c = Counter(m)
	cc = 0
	index = 0
	for x in c:
		if c[x] % 2 != 0:
			cc += 1
			index = x
	if cc != 1:
		print('NO')
	else:
		r[n // 2][n // 2] = index
		c[index] -= 1
		if c[index] == 0:
			del c[index]
		count = n // 2 + n // 2
		used = []
		ans = []
		s = sum([c[x] for x in c]) - count * 2
		if s % 4 != 0:
			print('NO')
		else:
			ans = []
			used = []
			for x in c:
				if c[x] % 4 != 0:
					count -= 1
					ans.append(x)
					c[x] -= 2
					if c[x] == 0:
						used.append(x)
				if count == 0:
					break
			for x in used:
				del c[x]
			used = []
			if count > 0:
				for x in c:
					if c[x] <= count * 2:
						used.append(x)
						ans.extend([x] * (c[x] // 2))
						count -= c[x] // 2
					else:
						c[x] -= count * 2
						ans.extend([x] * count)
						count = 0
					if count == 0:
						break
			for x in used:
				del c[x]
			f = False
			i = 0
			for x in ans:
				if not f:
					r[n // 2][i] = x
					r[n // 2][-i - 1] = x
					f = True
				else:
					r[i][n // 2] = x
					r[-i - 1][n // 2] = x
					f = False
					i += 1
			ans = []
			for x in c:
				if c[x] % 4 != 0:
					print('NO')
					break
				else:
					ans.extend([x] * (c[x] // 4))
			else:
				x = n // 2 * (n // 2)
				i = 0
				j = 0
				for x in ans:
					r[i][j] = x
					r[i][-j - 1] = x
					r[-i - 1][j] = x
					r[-i - 1][-j - 1] = x
					j += 1
					if j == n // 2:
						j = 0
						i += 1
				print('YES')
				for x in r:
					print(*x)


from collections import defaultdict, deque
import sys

def input():
	return sys.stdin.readline().rstrip()

def getcnt(LIST):
	d = defaultdict(int)
	for v in LIST:
		d[v] += 1
	return d

def odd_only_1(dic):
	cnt = 0
	res_value = 0
	for (key, value) in dic.items():
		if value % 2 != 0:
			cnt += 1
			res_value = key
	if cnt == 1:
		return res_value
	return 0

def slv():
	n = int(input())
	a = list(map(int, input().split()))
	d = getcnt(a)
	if n % 2 == 0:
		if all((value % 4 == 0 for value in d.values())):
			stack = deque([])
			for (key, value) in d.items():
				for _ in range(value):
					stack.append(key)
			print('YES')
			ans = [[-1] * n for i in range(n)]
			for i in range(n // 2):
				for j in range(n // 2):
					nums = stack[0]
					ans[i][j] = ans[i][-(j + 1)] = ans[-(i + 1)][j] = ans[-(i + 1)][-(j + 1)] = nums
					for _ in range(4):
						stack.popleft()
			for i in range(n):
				print(*ans[i])
			return
		else:
			print('NO')
		return
	else:
		if not odd_only_1(d):
			print('NO')
			return
		val = odd_only_1(d)
		d[val] -= 1
		ans = [[0] * n for i in range(n)]
		ans[n // 2][n // 2] = val
		if sum((value // 4 for value in d.values())) < (n // 2) ** 2:
			print('NO')
			return
		print('YES')
		stack = deque([])
		for (key, value) in d.items():
			(u, v) = divmod(value, 4)
			for _ in range(4 * u):
				stack.appendleft(key)
			for _ in range(v):
				stack.append(key)
		for i in range(n // 2):
			for j in range(n // 2):
				nums = stack[0]
				ans[i][j] = ans[i][-(j + 1)] = ans[-(i + 1)][j] = ans[-(i + 1)][-(j + 1)] = nums
				for _ in range(4):
					stack.popleft()
		for i in range(n // 2):
			num = stack[0]
			ans[n // 2][i] = ans[n // 2][-(i + 1)] = num
			for _ in range(2):
				stack.popleft()
		for i in range(n // 2):
			num = stack[0]
			ans[i][n // 2] = ans[-(i + 1)][n // 2] = num
			for _ in range(2):
				stack.popleft()
		for i in range(n):
			print(*ans[i])
	return

def main():
	t = 1
	for i in range(t):
		slv()
	return
main()


from collections import Counter
n = int(input())
a = [int(o) for o in input().split()]
u = list(set(a))
c = dict(Counter(a))
cm = [0] * n ** 2
lu = len(u)
pk = 0
for i in range(lu):
	cm[i] = [u[i], c[u[i]]]
if n % 2 == 0:
	flag = 0
	for i in range(lu):
		if cm[i][1] % 4 != 0:
			flag = 1
	if flag == 1:
		print('NO')
	else:
		k = 0
		matr = [[0 for i in range(n)] for j in range(n)]
		for i in range(n // 2):
			for j in range(n // 2):
				matr[i][j] = cm[k][0]
				matr[i][n - 1 - j] = cm[k][0]
				matr[n - 1 - i][j] = cm[k][0]
				matr[n - 1 - i][n - 1 - j] = cm[k][0]
				cm[k][1] -= 4
				if cm[k][1] == 0:
					k += 1
		print('YES')
		for i in range(n):
			print(*matr[i])
else:
	fp = []
	tp = []
	op = []
	for i in range(lu):
		if cm[i][1] >= 4:
			fp.append([cm[i][0], 4 * (cm[i][1] // 4)])
			cm[i][1] = cm[i][1] % 4
		if cm[i][1] >= 2:
			tp.append([cm[i][0], 2 * (cm[i][1] // 2)])
			cm[i][1] = cm[i][1] % 2
		if cm[i][1] >= 1:
			op.append([cm[i][0], 1 * (cm[i][1] // 1)])
			cm[i][1] = cm[i][1] % 1
	if len(op) > 1:
		flag = 1
	try:
		flag = 0
		k = 0
		matr = [[0 for i in range(n)] for j in range(n)]
		for i in range(n // 2):
			for j in range(n // 2):
				matr[i][j] = fp[k][0]
				matr[i][n - 1 - j] = fp[k][0]
				matr[n - 1 - i][j] = fp[k][0]
				matr[n - 1 - i][n - 1 - j] = fp[k][0]
				fp[k][1] -= 4
				if fp[k][1] == 0:
					k += 1
	except:
		flag = 1
	if flag == 0:
		try:
			loll = n // 2
			for i in range(n // 2):
				matr[loll][i] = fp[k][0]
				matr[loll][n - 1 - i] = fp[k][0]
				fp[k][1] -= 2
				if fp[k][1] == 0:
					k += 1
		except:
			try:
				k = 0
				for j in range(i, n // 2):
					matr[loll][j] = tp[k][0]
					matr[loll][n - 1 - j] = tp[k][0]
					tp[k][1] -= 2
					if tp[k][1] == 0:
						k += 1
				pk = k
			except:
				flag = 1
		try:
			if pk == 0:
				loll = n // 2
				for i in range(n // 2):
					matr[i][loll] = fp[k][0]
					matr[n - 1 - i][loll] = fp[k][0]
					fp[k][1] -= 2
					if fp[k][1] == 0:
						k += 1
			else:
				k = pk
				try:
					for j in range(i, n // 2):
						matr[j][loll] = tp[k][0]
						matr[n - 1 - j][loll] = tp[k][0]
						tp[k][1] -= 2
						if tp[k][1] == 0:
							k += 1
				except:
					flag = 1
		except:
			try:
				k = 0
				for j in range(i, n // 2):
					matr[j][loll] = tp[k][0]
					matr[n - 1 - j][loll] = tp[k][0]
					tp[k][1] -= 2
					if tp[k][1] == 0:
						k += 1
			except:
				flag = 1
	if flag == 0:
		yoyo = op[0][0]
		matr[n // 2][n // 2] = yoyo
		print('YES')
		for i in range(n):
			print(*matr[i])
	else:
		print('NO')


n = int(input())
a = [int(t) for t in input().split(' ')]
count = {}
for num in a:
	count[num] = count.get(num, 0) + 1

def invalid():
	print('NO')
	exit()
mx = [[0] * n for _ in range(n)]
center = n // 2
left = 0
top = 0
for num in count:
	while count[num] >= 4 and top < center:
		mx[left][top] = mx[-1 - left][top] = mx[left][-1 - top] = mx[-1 - left][-1 - top] = num
		count[num] -= 4
		left += 1
		if left >= center:
			left = 0
			top += 1
	if top >= n:
		break
if n % 2 == 1:
	left = 0
	for num in count:
		while count[num] >= 2 and left < center:
			count[num] -= 2
			mx[center][left] = mx[center][-1 - left] = num
			left += 1
	top = 0
	for num in count:
		while count[num] >= 2 and top < center:
			count[num] -= 2
			mx[top][center] = mx[-1 - top][center] = num
			top += 1
	for num in count:
		if count[num] >= 1:
			count[num] -= 1
			mx[center][center] = num
			break
for num in count:
	if count[num] > 0:
		invalid()
print('YES')
for x in range(n):
	print(' '.join((str(t) for t in mx[x])))


from sys import stdin
n = int(stdin.readline().strip())
s = list(map(int, stdin.readline().strip().split()))
d = dict()
for i in s:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
s = []
for i in d:
	s.append([d[i], i])
s.sort(reverse=True)
mt = [[-1 for i in range(n)] for j in range(n)]
if n % 2 == 0:
	t = True
	y = 0
	for i in d:
		if d[i] % 4 != 0:
			t = False
			break
	if t == False:
		print('NO')
		exit(0)
	for i in range(n):
		for j in range(n):
			n1 = n - 1
			if mt[i][j] != -1:
				continue
			mt[i][j] = s[y][1]
			mt[i][n1 - j] = s[y][1]
			mt[n1 - i][j] = s[y][1]
			mt[n1 - i][n1 - j] = s[y][1]
			s[y][0] -= 4
			if s[y][0] == 0:
				y += 1
else:
	t = False
	cen = -1
	for i in range(len(s)):
		if s[i][0] % 2 != 0:
			cen = s[i][1]
			s[i][0] -= 1
			break
	mt[n // 2][n // 2] = cen
	y = 0
	n1 = n - 1
	for i in range(n):
		if n == 1:
			break
		for j in range(n):
			if mt[i][j] != -1:
				continue
			if j == n // 2 or i == n // 2:
				continue
			mt[i][j] = s[y][1]
			mt[i][n1 - j] = s[y][1]
			mt[n1 - i][j] = s[y][1]
			mt[n1 - i][n1 - j] = s[y][1]
			s[y][0] -= 4
			y1 = y
			if s[y][0] < 4:
				y += 1
			if s[y1][0] < 0:
				print('NO')
				exit(0)
	s.sort(reverse=True)
	y = 0
	for i in range(n):
		if n == 1:
			break
		for j in range(n):
			n1 = n - 1
			if mt[i][j] != -1:
				continue
			if j != n // 2 and i != n // 2:
				continue
			mt[i][j] = s[y][1]
			mt[i][n1 - j] = s[y][1]
			mt[n1 - i][j] = s[y][1]
			mt[n1 - i][n1 - j] = s[y][1]
			s[y][0] -= 2
			if s[y][0] < 0:
				print('NO')
				exit(0)
			if s[y][0] == 0:
				y += 1
print('YES')
for k in mt:
	for k1 in k:
		print(k1, end=' ')
	print()


from collections import Counter
n = int(input())
s = list(map(int, input().split()))
c = Counter(s)
m = {}
two_pos = []
four_pos = []
one_pos = []
if n % 2 == 1:
	one_pos.append((n // 2, n // 2))
	for i in range(n // 2):
		two_pos.append(((i, n // 2), (n - i - 1, n // 2)))
		two_pos.append(((n // 2, i), (n // 2, n - i - 1)))
for i in range(n // 2):
	for j in range(n // 2):
		four_pos.append(((i, j), (i, n - j - 1), (n - i - 1, j), (n - i - 1, n - j - 1)))
IS_POSSIBLE = True
for (k, v) in c.items():
	if v % 2 == 1:
		if len(one_pos) == 0:
			IS_POSSIBLE = False
			break
		pos = one_pos.pop()
		m[pos] = k
		v -= 1
	while v >= 4 and len(four_pos) > 0:
		for e in four_pos.pop():
			m[e] = k
		v -= 4
	while v >= 2 and len(two_pos) > 0:
		for e in two_pos.pop():
			m[e] = k
		v -= 2
	if v > 0:
		IS_POSSIBLE = False
		break
if not IS_POSSIBLE:
	print('NO')
else:
	print('YES')
	for i in range(n):
		for j in range(n):
			print(m[i, j], end=' ')
		print()


def getNum(nums):
	for i in nums.keys():
		if nums[i] >= 4:
			nums[i] -= 4
			if nums[i] == 0:
				del nums[i]
			return i
	return -1

def getNum1(nums):
	for i in nums.keys():
		if nums[i] >= 2:
			nums[i] -= 2
			if nums[i] == 0:
				del nums[i]
			return i
	return -1

def main():
	n = int(input())
	nums = list(map(int, input().split()))
	dist_nums = {}
	for i in nums:
		if i not in dist_nums.keys():
			dist_nums[i] = 1
		else:
			dist_nums[i] += 1
	matrix = [[0 for i in range(n)] for j in range(n)]
	for col in range(n // 2):
		for row in range(n // 2):
			num = getNum(dist_nums)
			if num == -1:
				print('NO')
				return
			matrix[row][col] = num
			matrix[n - row - 1][col] = num
			matrix[row][n - col - 1] = num
			matrix[n - row - 1][n - col - 1] = num
	if n % 2 != 0:
		row = n // 2
		for col in range(n // 2):
			num = getNum1(dist_nums)
			if num == -1:
				print('NO')
				return
			matrix[row][col] = num
			matrix[row][n - 1 - col] = num
		col = n // 2
		for row in range(n // 2):
			num = getNum1(dist_nums)
			if num == -1:
				print('NO')
				return
			matrix[row][col] = num
			matrix[n - 1 - row][col] = num
		num = -1
		for i in dist_nums.keys():
			if dist_nums[i] >= 1:
				num = i
				break
		if num == -1:
			print('NO')
			return
		matrix[n // 2][n // 2] = num
	print('YES')
	for i in matrix:
		for j in i:
			print(j, end=' ')
		print()
main()


n = int(input())
a = [int(x) for x in input().split()]
ct = {}
notfourdiv = 0
nottwodiv = 0
oddnum = -1
twonums = []
fournums = []
for v in a:
	ct[v] = ct.get(v, 0) + 1
for (k, v) in ct.items():
	if v % 4:
		notfourdiv += 1
		if v % 2:
			nottwodiv += 1
			oddnum = k
			if v > 1:
				if (v - 1) % 4 != 0:
					notfourdiv += 1
					twonums.append(k)
				else:
					fournums.append(k)
		else:
			twonums.append(k)
	else:
		fournums.append(k)
if n % 2 == 0:
	if notfourdiv > 0:
		print('NO')
	else:
		print('YES')
		res = [[-1 for i in range(n)] for j in range(n)]
		i = 0
		j = 0
		for (k, v) in ct.items():
			x = 0
			while x < v // 4:
				res[i][j] = k
				res[n - 1 - i][j] = k
				res[i][n - j - 1] = k
				res[n - 1 - i][n - j - 1] = k
				if j == n // 2 - 1:
					i += 1
					j = 0
				else:
					j += 1
				x += 1
		for row in res:
			row = [str(entry) for entry in row]
			print(' '.join(row))
elif nottwodiv > 1:
	print('NO')
elif notfourdiv > n:
	print('NO')
else:
	print('YES')
	res = [[-1 for i in range(n)] for j in range(n)]
	for i in range(n):
		for j in range(n):
			if res[i][j] != -1:
				continue
			if i == j and i == n - i - 1:
				res[i][j] = oddnum
				ct[oddnum] -= 1
			elif i == n - i - 1:
				if twonums:
					val = twonums[-1]
					res[i][j] = val
					res[i][n - j - 1] = val
					ct[val] -= 2
					twonums.pop()
					if ct[val] > 0:
						fournums.insert(0, val)
				else:
					val = fournums[-1]
					res[i][j] = val
					res[i][n - j - 1] = val
					ct[val] -= 2
					fournums.pop()
					twonums.insert(0, val)
			elif j == n - j - 1:
				if twonums:
					val = twonums[-1]
					res[i][j] = val
					res[n - i - 1][j] = val
					ct[val] -= 2
					twonums.pop()
					if ct[val] > 0:
						fournums.insert(0, val)
				else:
					val = fournums[-1]
					res[i][j] = val
					res[n - i - 1][j] = val
					ct[val] -= 2
					fournums.pop()
					twonums.insert(0, val)
	i = 0
	j = 0
	for (k, v) in ct.items():
		if v == 0:
			continue
		x = 0
		while x < v:
			if res[i][j] == -1:
				res[i][j] = k
				x += 1
				if res[n - i - 1][j] == -1:
					res[n - i - 1][j] = k
					x += 1
				if res[i][n - j - 1] == -1:
					res[i][n - j - 1] = k
					x += 1
				if res[n - i - 1][n - j - 1] == -1:
					res[n - i - 1][n - j - 1] = k
					x += 1
			if j == n // 2:
				i += 1
				j = 0
			else:
				j += 1
	for row in res:
		row = [str(entry) for entry in row]
		print(' '.join(row))


import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5:
	from math import gcd
else:
	from fractions import gcd
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def round(x):
	return int((x * 2 + 1) // 2)

def fermat(x, y, MOD):
	return x * pow(y, MOD - 2, MOD) % MOD

def lcm(x, y):
	return x * y // gcd(x, y)

def lcm_list(nums):
	return reduce(lcm, nums, 1)

def gcd_list(nums):
	return reduce(gcd, nums, nums[0])

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
N = INT()
A = LIST()
C = Counter(A)
C2 = Counter()
center = 0
for (k, v) in C.items():
	C2[v % 4] += 1
	if (v % 4 == 1 or v % 4 == 3) and center != 0:
		print('NO')
		exit()
	if v % 4 == 1 or v % 4 == 3:
		center = k
grid = list2d(N, N, 0)
if N % 2 == 0:
	for (k, v) in C2.items():
		if k != 0 and v != 0:
			print('NO')
			exit()
	l = []
	for (k, v) in C.items():
		for _ in range(v // 4):
			l.append(k)
	k = 0
	for i in range(N // 2):
		for j in range(N // 2):
			grid[i][j] = l[k]
			grid[N - 1 - i][N - 1 - j] = l[k]
			grid[i][N - 1 - j] = l[k]
			grid[N - 1 - i][j] = l[k]
			k += 1
	print('YES')
	for i in range(N):
		print(*grid[i])
else:
	for (k, v) in C2.items():
		if k == 2 and v > N - 1:
			print('NO')
			exit()
	C[center] -= 1
	grid[N // 2][N // 2] = center
	l = []
	for (k, v) in C.items():
		if v % 4 == 2:
			l.append(k)
			C[k] -= 2
	k = 0
	for i in range(len(l) // 2):
		grid[N // 2][i] = l[k]
		grid[N // 2][N - 1 - i] = l[k]
		k += 1
		grid[i][N // 2] = l[k]
		grid[N - 1 - i][N // 2] = l[k]
		k += 1
	l = []
	for (k, v) in C.items():
		if v % 4 == 0:
			for _ in range(v // 4):
				l.append(k)
	k = 0
	for i in range(N // 2):
		for j in range(ceil(N, 2)):
			if grid[i][j] == 0:
				grid[i][j] = l[k]
				grid[N - 1 - i][N - 1 - j] = l[k]
				grid[i][N - 1 - j] = l[k]
				grid[N - 1 - i][j] = l[k]
				k += 1
	for i in range(N // 2):
		if grid[N // 2][i] == 0:
			grid[N // 2][i] = grid[i][N // 2]
			grid[N // 2][N - 1 - i] = grid[N - 1 - i][N // 2]
	print('YES')
	for i in range(N):
		print(*grid[i])


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
x = list(set(a))
y = []
one = []
two = []
c = Counter(a)
ans = [[0] * n for _ in range(n)]
if n % 2:
	for i in x:
		if c[i] % 4 == 1 or c[i] % 4 == 3:
			one.append(i)
			if c[i] % 4 == 3:
				two.append(i)
			if len(one) > 1 or len(two) > n - 1:
				print('NO')
				exit()
		elif c[i] % 4 == 2:
			two.append(i)
			if len(two) > n - 1:
				print('NO')
				exit()
		for j in range(c[i] // 4):
			y.append(i)
	k = one.pop()
	ans[n // 2][n // 2] = k
	if len(two) < n - 1:
		m = n - 1 - len(two)
		if m % 2:
			print('NO')
			exit()
		for i in range(m // 2):
			k = y.pop()
			two.append(k)
			two.append(k)
	for i in range(n // 2):
		k = two.pop()
		ans[i][n // 2] = k
		ans[n - 1 - i][n // 2] = k
	for i in range(n // 2):
		k = two.pop()
		ans[n // 2][i] = k
		ans[n // 2][n - 1 - i] = k
	if y:
		for i in range(n // 2):
			for j in range(n // 2):
				k = y.pop()
				ans[i][j] = k
				ans[i][n - 1 - j] = k
				ans[n - 1 - i][j] = k
				ans[n - 1 - i][n - 1 - j] = k
	print('YES')
	for i in range(n):
		print(*ans[i])
else:
	for i in x:
		if c[i] % 4:
			print('NO')
			exit()
		else:
			for j in range(c[i] // 4):
				y.append(i)
	for i in range(n // 2):
		for j in range(n // 2):
			k = y.pop()
			ans[i][j] = k
			ans[i][n - 1 - j] = k
			ans[n - 1 - i][j] = k
			ans[n - 1 - i][n - 1 - j] = k
	print('YES')
	for i in range(n):
		print(*ans[i])


from heapq import heappush as insert, heappop as extract_maximum
from collections import Counter
n = int(input())
count = {}
nums = list(map(int, input().split()))
c = Counter(nums)
hp = []
for (num, counter) in c.items():
	insert(hp, (-counter, num))
m = n // 2
result = True
try:
	res = [[0 for _ in range(n)] for _ in range(n)]
	for i in range(m):
		for j in range(m):
			p = extract_maximum(hp)
			if p[0] > -4:
				raise Exception
			res[i][j] = p[1]
			res[n - i - 1][j] = p[1]
			res[i][n - j - 1] = p[1]
			res[n - i - 1][n - j - 1] = p[1]
			new_p = (p[0] + 4, p[1])
			if new_p[0]:
				insert(hp, new_p)
	if n % 2:
		for i in range(m):
			p = extract_maximum(hp)
			if p[0] > -2:
				raise Exception
			res[i][m] = p[1]
			res[n - i - 1][m] = p[1]
			new_p = (p[0] + 2, p[1])
			if new_p[0]:
				insert(hp, new_p)
			p = extract_maximum(hp)
			if p[0] > -2:
				raise Exception
			res[m][i] = p[1]
			res[m][n - i - 1] = p[1]
			new_p = (p[0] + 2, p[1])
			if new_p[0]:
				insert(hp, new_p)
		res[m][m] = extract_maximum(hp)[1]
except Exception as e:
	print('NO ', e)
	result = False
if result:
	print('YES')
	for r in res:
		print(' '.join(map(str, r)))


from collections import defaultdict

def main():
	n = int(input())
	a = [*map(int, input().split())]
	D = defaultdict(lambda : 0)
	for i in range(n ** 2):
		D[a[i]] += 1
	if n % 2 == 0:
		flag = True
		for x in D.keys():
			if D[x] % 4 != 0:
				flag = False
		print('YES') if flag else print('NO')
		if flag:
			ans = [[0] * n for _ in range(n)]
			path = []
			for i in range(n // 2):
				for j in range(n // 2):
					path.append([(i, j), (n - 1 - i, j), (i, n - 1 - j), (n - 1 - i, n - 1 - j)])
			z = 0
			for x in D.keys():
				while D[x]:
					for i in range(4):
						(nx, ny) = path[z][i]
						ans[nx][ny] = x
					D[x] -= 4
					z += 1
			for i in range(n):
				print(*ans[i])
	else:
		odd = [0, 0]
		two = 0
		for x in D.keys():
			if D[x] % 2:
				odd[0] += 1
				odd[1] = x
			if D[x] % 4 == 2:
				two += 1
		flag = True
		if odd[0] != 1 or two > n - 1:
			flag = False
		print('YES') if flag else print('NO')
		if flag:
			ans = [[0] * n for _ in range(n)]
			ans[n // 2][n // 2] = odd[1]
			D[odd[1]] -= 1
			path1 = []
			path2 = []
			for i in range(n // 2):
				for j in range(n // 2):
					path1.append([(i, j), (n - 1 - i, j), (i, n - 1 - j), (n - 1 - i, n - 1 - j)])
			for i in range(n // 2):
				path2.append([(n // 2, i), (n // 2, n - 1 - i)])
				path2.append([(i, n // 2), (n - 1 - i, n // 2)])
			z = 0
			for x in D.keys():
				if z == len(path1):
					break
				while D[x]:
					if D[x] < 4 or z == len(path1):
						break
					for i in range(4):
						(nx, ny) = path1[z][i]
						ans[nx][ny] = x
					D[x] -= 4
					z += 1
			z = 0
			for x in D.keys():
				while D[x]:
					for i in range(2):
						(nx, ny) = path2[z][i]
						ans[nx][ny] = x
					D[x] -= 2
					z += 1
			for i in range(n):
				print(*ans[i])
main()


import math
import bisect
import itertools
import sys
I = lambda : sys.stdin.readline()
mod = 10 ** 9 + 7

def modu(a, m):
	if a % m:
		return a % m
	return m

def mindiff(a):
	b = a[:]
	b.sort()
	m = 10000000000
	for i in range(len(b) - 1):
		if b[i + 1] - b[i] < m:
			m = b[i + 1] - b[i]
	return m

def lcm(a, b):
	return a * b // math.gcd(a, b)

def merge(a, b):
	i = 0
	j = 0
	c = 0
	ans = []
	while i < len(a) and j < len(b):
		if a[i] < b[j]:
			ans.append(a[i])
			i += 1
		else:
			ans.append(b[j])
			c += len(a) - i
			j += 1
	ans += a[i:]
	ans += b[j:]
	return (ans, c)

def mergesort(a):
	if len(a) == 1:
		return (a, 0)
	mid = len(a) // 2
	(left, left_inversion) = mergesort(a[:mid])
	(right, right_inversion) = mergesort(a[mid:])
	(m, c) = merge(left, right)
	c += left_inversion + right_inversion
	return (m, c)

def is_prime(num):
	if num == 1:
		return False
	if num == 2:
		return True
	if num == 3:
		return True
	if num % 2 == 0:
		return False
	if num % 3 == 0:
		return False
	t = 5
	a = 2
	while t <= int(math.sqrt(num)):
		if num % t == 0:
			return False
		t += a
		a = 6 - a
	return True

def ceil(a, b):
	if a % b == 0:
		return a // b
	else:
		return a // b + 1

def binsearch(arr, b, low, high):
	if low == high:
		return low
	if arr[math.ceil((low + high) / 2)] < b:
		return binsearch(arr, b, low, math.ceil((low + high) / 2) - 1)
	else:
		return binsearch(arr, b, math.ceil((low + high) / 2), high)

def ncr1(n, r):
	s = 1
	for i in range(min(n - r, r)):
		s *= n - i
		s %= mod
		s *= pow(i + 1, mod - 2, mod)
		s %= mod
	return s

def calc(n, m, r):
	s = 0
	for i in range(0, r + 1, 2):
		s += ncr1(n, i) * ncr1(m, i)
		s %= mod
	return s
n = int(input())
d = {}
a = list(map(int, input().split()))
b = []
a.sort()
c = []
p = a[0]
for i in a:
	if i == p and len(c) != 4:
		c.append(i)
	elif i != p or len(c) == 4:
		b.append([len(c)] + c)
		c = [i]
		p = i
b.append([len(c)] + c)
b.sort(reverse=True)
kk = []
ans = [[0 for i in range(n + 1)] for j in range(n + 1)]

def printarr(ans):
	for i in range(1, len(ans)):
		print(*ans[i][1:])
d = {}
for i in b:
	if i[0] == 3:
		d[i[0] - 1] = d.get(i[0] - 1, 0) + 1
	else:
		d[i[0]] = d.get(i[0], 0) + 1
	if i[0] == 3:
		kk += i[1:3]
		p = i[3]
	else:
		kk += i[1:]
try:
	kk += [p]
except:
	p = 1
if n % 2 == 0:
	k = 0
	f = 0
	if d.get(4, 0) < (n // 2) ** 2:
		print('NO')
	else:
		for i in range(1, n // 2 + 1):
			for j in range(1, n // 2 + 1):
				if True:
					ans[i][j] = kk[k]
					k += 1
					ans[n + 1 - i][j] = kk[k]
					k += 1
					ans[i][n - j + 1] = kk[k]
					k += 1
					ans[n - i + 1][n - j + 1] = kk[k]
					k += 1
		print('YES')
		printarr(ans)
elif d.get(4, 0) < (n // 2) ** 2 or (d.get(4, 0) - (n // 2) ** 2) * 2 + d.get(2, 0) < n // 2 * 2:
	print('NO')
else:
	k = 0
	for i in range(1, n // 2 + 1):
		for j in range(1, n // 2 + 1):
			ans[i][j] = kk[k]
			k += 1
			ans[n + 1 - i][j] = kk[k]
			k += 1
			ans[i][n - j + 1] = kk[k]
			k += 1
			ans[n - i + 1][n - j + 1] = kk[k]
			k += 1
	for i in range(1, n // 2 + 1):
		ans[i][math.ceil(n / 2)] = kk[k]
		k += 1
		ans[n - i + 1][math.ceil(n / 2)] = kk[k]
		k += 1
	for j in range(1, n // 2 + 1):
		ans[math.ceil(n / 2)][j] = kk[k]
		k += 1
		ans[math.ceil(n / 2)][n - j + 1] = kk[k]
		k += 1
	ans[math.ceil(n / 2)][math.ceil(n / 2)] = kk[k]
	print('YES')
	printarr(ans)


n = int(input())
a = list(map(int, input().split()))
n2 = (n - 1) * (n - 1)
nn = len(a)
s = [0] * 1001
for i in a:
	s[i] += 1
cnt = 0
cnt1 = 0
cnt2 = 0
cnt3 = 0
for i in range(1, 1001):
	if s[i] % 4 == 0:
		cnt += 1
	if s[i] % 4 == 1:
		cnt1 += 1
	if s[i] % 4 == 2:
		cnt2 += 1
	if s[i] % 4 == 3:
		cnt3 += 1
if n % 2 == 0:
	if cnt1 + cnt2 + cnt3 > 0:
		print('NO')
	else:
		print('YES')
		k = int(n / 2)
		b = [[0 for count in range(n)] for count in range(n)]
		j = 0
		for i in range(1, 1001):
			while s[i] > 0:
				s[i] -= 4
				b[int(j / k)][int(j % k)] = i
				j += 1
		for i in range(k):
			for j in range(k):
				b[n - 1 - i][j] = b[i][j]
				b[i][n - 1 - j] = b[i][j]
				b[n - 1 - i][n - 1 - j] = b[i][j]
		for i in range(n):
			for j in range(n):
				print(b[i][j], end=' ')
			print()
else:
	pos = True
	k = int(n / 2)
	if cnt1 + cnt3 != 1:
		pos = False
	if cnt3 == 1:
		if cnt2 > 2 * k - 1:
			pos = False
	elif cnt2 > 2 * k:
		pos = False
	if pos == False:
		print('NO')
	else:
		print('YES')
		b = [[0 for count in range(n)] for count in range(n)]
		j = 0
		for i in range(1, 1001):
			if s[i] % 2 == 1:
				b[k][k] = i
				s[i] -= 1
			while s[i] >= 4 and j < k * k:
				s[i] -= 4
				b[int(j / k)][int(j % k)] = i
				j += 1
		for i in range(k):
			for j in range(k):
				b[n - 1 - i][j] = b[i][j]
				b[i][n - 1 - j] = b[i][j]
				b[n - 1 - i][n - 1 - j] = b[i][j]
		j = 0
		for i in range(1, 1001):
			if s[i] % 2 == 0:
				while s[i] > 0:
					s[i] -= 2
					if j < k:
						b[k][j] = i
					else:
						b[j - k][k] = i
					j += 1
		for i in range(k):
			b[n - 1 - i][k] = b[i][k]
			b[k][n - 1 - i] = b[k][i]
		for i in range(n):
			for j in range(n):
				print(b[i][j], end=' ')
			print()


n = int(input())
a = list(map(int, input().split(' ')))
mat = [[-1 for x in range(n)] for x in range(n)]
from collections import Counter
count = Counter(a)
notpos = False
chk = 0
if n % 2 != 0:
	for (x, y) in count.items():
		if y % 2 != 0:
			mat[n // 2][n // 2] = x
			count[x] -= 1
			chk = 1
			break
	if chk == 0:
		notpos = True
for x in range(n):
	for y in range(n):
		if mat[x][y] != -1:
			continue
		if n % 2 != 0:
			chk = 0
			if x == n // 2:
				continue
			elif y == n // 2:
				continue
		chk = 0
		for (z, zz) in count.items():
			if zz >= 4:
				count[z] -= 4
				mat[x][y] = z
				mat[n - x - 1][y] = z
				mat[x][n - y - 1] = z
				mat[n - x - 1][n - y - 1] = z
				chk = 1
				break
		if chk == 0:
			notpos = True
for x in range(n):
	for y in range(n):
		if mat[x][y] != -1:
			continue
		if n % 2 != 0:
			chk = 0
			if x == n // 2:
				for (z, zz) in count.items():
					if zz >= 2:
						count[z] -= 2
						mat[x][y] = z
						mat[x][n - y - 1] = z
						chk = 1
						break
				if chk == 0:
					notpos = True
				continue
			elif y == n // 2:
				for (z, zz) in count.items():
					if zz >= 2:
						count[z] -= 2
						mat[x][y] = z
						mat[n - x - 1][y] = z
						chk = 1
						break
				if chk == 0:
					notpos = True
				continue
if notpos:
	print('NO')
else:
	print('YES')
	for x in mat:
		print(*x)


from collections import Counter
from sys import exit
n = int(input())
numbers = list(map(int, input().split()))
num_counter = Counter(numbers)
is_odd = n % 2
size4 = n // 2
size = size4 + n % 2
res = [[None] * size for i in range(size)]
pushed4 = 0
pushed2 = 0
pushed = 0
for (num, count) in num_counter.items():
	if pushed4 < size4 ** 2:
		for i in range(count // 4):
			if pushed4 == size4 ** 2:
				break
			res[pushed4 // size4][pushed4 % size4] = num
			pushed4 += 1
			num_counter[num] -= 4
			count -= 4
	if count and count // 2 and is_odd and (pushed2 < 2 * size4):
		for i in range(count // 2):
			if pushed2 == 2 * size4:
				break
			if pushed2 < size4:
				res[pushed2][size - 1] = num
				pushed2 += 1
				num_counter[num] -= 2
				count -= 2
			else:
				res[size - 1][pushed2 % size4] = num
				pushed2 += 1
				num_counter[num] -= 2
				count -= 2
	if count and is_odd and (not pushed):
		res[size - 1][size - 1] = num
		pushed += 1
		num_counter[num] -= 1
		count -= 1
	if count:
		print('NO')
		exit(0)
print('YES')
for s in res:
	print(' '.join(map(str, s)), ' '.join(map(str, s[:size - is_odd][::-1])))
for s in res[:size - is_odd][::-1]:
	print(' '.join(map(str, s)), ' '.join(map(str, s[:size - is_odd][::-1])))


n = int(input())
a = list(map(int, input().split()))
dp = [[0] * n for i in range(n)]
d = dict()
for i in range(n * n):
	if a[i] in d:
		d[a[i]] += 1
	else:
		d[a[i]] = 1
if n % 2 == 0:
	a.sort()
	ct = 0
	for i in range(n // 2):
		for j in range(n // 2):
			if a[ct] != a[ct + 3]:
				print('NO')
				exit()
			else:
				dp[i][j] = dp[n - i - 1][j] = dp[i][n - j - 1] = dp[n - i - 1][n - j - 1] = a[ct]
				ct = ct + 4
	print('YES')
	for i in range(n):
		for j in range(n):
			print(dp[i][j], end=' ')
		print()
else:
	flag = 0
	for i in d:
		if d[i] % 2 == 1:
			dp[n // 2][n // 2] = i
			d[i] -= 1
			if d[i] == 0:
				del d[i]
			flag = 1
			break
	if flag == 0:
		print('NO')
		exit()
	else:
		for i in d:
			if d[i] % 2 == 1:
				print('NO')
				exit()
	s = list(set(a))
	lt = len(s)
	ct = 0
	for i in range(n // 2):
		for j in range(n // 2):
			while True:
				if ct == lt:
					print('NO')
					exit()
				if s[ct] not in d or d[s[ct]] == 2 or d[s[ct]] % 2 != 0 or (d[s[ct]] == 0):
					ct += 1
					continue
				else:
					d[s[ct]] -= 4
					if d[s[ct]] == 0:
						del d[s[ct]]
					break
			dp[i][j] = dp[n - i - 1][j] = dp[i][n - j - 1] = dp[n - i - 1][n - j - 1] = s[ct]
	ct = 0
	for i in range(n // 2):
		while True:
			if ct == lt:
				print('NO')
				exit()
			if s[ct] not in d or d[s[ct]] % 2 != 0 or d[s[ct]] == 0:
				ct += 1
				continue
			else:
				d[s[ct]] -= 2
				if d[s[ct]] == 0:
					del d[s[ct]]
				break
		dp[n // 2][i] = dp[n // 2][n - i - 1] = s[ct]
	ct = 0
	for i in range(n // 2):
		while True:
			if ct == lt:
				print('NO')
				exit()
			if s[ct] not in d or d[s[ct]] % 2 != 0 or d[s[ct]] == 0:
				ct += 1
				continue
			else:
				d[s[ct]] -= 2
				if d[s[ct]] == 0:
					del d[s[ct]]
				break
		dp[i][n // 2] = dp[n - i - 1][n // 2] = s[ct]
	print('YES')
	for i in range(n):
		for j in range(n):
			print(dp[i][j], end=' ')
		print()


from collections import *
n = int(input())
a = list(map(int, input().split()))
cnt = Counter(a)
ans = [[-1] * n for _ in range(n)]
q = deque([])
if n % 2 == 0:
	for (k, v) in cnt.items():
		if v % 4 != 0:
			print('NO')
			exit()
		for _ in range(v // 4):
			q.append(k)
	for i in range(n // 2):
		for j in range(n // 2):
			v = q.popleft()
			ans[i][j] = v
			ans[n - 1 - i][j] = v
			ans[i][n - 1 - j] = v
			ans[n - 1 - i][n - 1 - j] = v
else:
	flag = False
	for (k, v) in cnt.items():
		if v % 2 == 1:
			if flag:
				print('NO')
				exit()
			flag = True
			ans[n // 2][n // 2] = k
			cnt[k] -= 1
		for _ in range(v // 4):
			if len(q) == (n // 2) ** 2:
				break
			q.append(k)
			cnt[k] -= 4
	if len(q) < (n // 2) ** 2:
		print('NO')
		exit()
	for (k, v) in cnt.items():
		for _ in range(v // 2):
			q.append(k)
	for i in range(n // 2):
		for j in range(n // 2):
			v = q.popleft()
			ans[i][j] = v
			ans[n - 1 - i][j] = v
			ans[i][n - 1 - j] = v
			ans[n - 1 - i][n - 1 - j] = v
	for i in range(n // 2):
		v = q.popleft()
		ans[i][n // 2] = v
		ans[n - 1 - i][n // 2] = v
	for i in range(n // 2):
		v = q.popleft()
		ans[n // 2][i] = v
		ans[n // 2][n - 1 - i] = v
print('YES')
for ans_i in ans:
	print(*ans_i)


def print_mat(n, l):
	lst = [[[0] for _ in range(int(n / 2))]] * int(n / 2)
	z = 1
	for i in range(int(n / 2)):
		for j in range(int(n / 2)):
			while not z in l or l[z] == 0:
				z += 1
			lst[i] = lst[i][:j] + [z] + lst[i][j + 1:]
			l[z] -= 4
	for i in lst:
		print(' '.join(list(map(str, i + i[::-1]))))
	for i in lst[::-1]:
		print(' '.join(list(map(str, i + i[::-1]))))

def print_mat_odd(n, l):
	lst = [[[0] for _ in range(n)]] * n
	z = 1
	for i in range(int((n - 1) / 2)):
		for j in range(int((n - 1) / 2)):
			while not z in l or l[z] < 4:
				z += 1
			lst[i] = lst[i][:j] + [z] + lst[i][j + 1:]
			lst[n - i - 1] = lst[n - i - 1][:j] + [z] + lst[n - i - 1][j + 1:]
			lst[i] = lst[i][:n - j - 1] + [z] + lst[i][n - j:]
			lst[n - i - 1] = lst[n - i - 1][:n - j - 1] + [z] + lst[n - i - 1][n - j:]
			l[z] -= 4
	z = 1
	for i in range(int((n - 1) / 2)):
		while not z in l or l[z] < 2:
			z += 1
		lst[int((n - 1) / 2)] = lst[int((n - 1) / 2)][:i] + [z] + lst[int((n - 1) / 2)][i + 1:]
		lst[int((n - 1) / 2)] = lst[int((n - 1) / 2)][:n - i - 1] + [z] + lst[int((n - 1) / 2)][n - i:]
		l[z] -= 2
	z = 1
	for i in range(int((n - 1) / 2)):
		while not z in l or l[z] < 2:
			z += 1
		lst[i] = lst[i][:int((n - 1) / 2)] + [z] + lst[i][int((n - 1) / 2) + 1:]
		lst[n - i - 1] = lst[n - i - 1][:int((n - 1) / 2)] + [z] + lst[n - i - 1][int((n - 1) / 2) + 1:]
		l[z] -= 2
	z = 1
	for i in range(2000):
		if i in l and l[i] == 1:
			lst[int((n - 1) / 2)] = lst[int((n - 1) / 2)][:int((n - 1) / 2)] + [i] + lst[int((n - 1) / 2)][int((n - 1) / 2) + 1:]
			break
	for i in lst:
		print(' '.join(list(map(str, i))))
n = int(input())
a = list(map(int, input().split()))
l = {}
for i in a:
	if i in l:
		l[i] = l[i] + 1
	else:
		l[i] = 1
c = [0, 0, 0, 0]
for i in l:
	c[l[i] % 4] += 1
if n % 2 == 0:
	if c[1] == 0 and c[2] == 0 and (c[3] == 0):
		print('YES')
		print_mat(n, l)
	else:
		print('NO')
elif c[1] == 1 and c[3] == 0 and (c[2] + c[3] <= n) or (c[1] == 0 and c[3] == 1 and (c[2] + c[3] <= n)):
	print('YES')
	print_mat_odd(n, l)
else:
	print('NO')


from collections import Counter
n = int(input())
c = Counter(map(int, input().split()))
for (_, i) in c.most_common():
	if i % 2 != 0 and n % 2 == 0:
		print('NO')
		exit(0)
	if i == 2 and n % 2 == 0 and (n > 2):
		print('NO')
		exit(0)
if n == 2:
	(e, count) = c.most_common()[0]
	if count == 4:
		print('YES')
		print('{} {}\n{} {}'.format(e, e, e, e))
	elif count == 3:
		print('NO')
	elif count == 2:
		(d, count2) = c.most_common()[1]
		if count2 == 1:
			print('NO')
		else:
			print('YES')
			print('{} {}\n{} {}'.format(e, e, d, d))
	exit(0)
a = [[0] * n for i in range(n)]
for i in range(n // 2):
	for j in range(n // 2):
		(e, count) = c.most_common()[0]
		if count < 4 and n > 2:
			print('NO')
			exit(0)
		a[i][j] = e
		a[n - 1 - i][j] = e
		a[i][n - 1 - j] = e
		a[n - 1 - i][n - j - 1] = e
		c[e] = count - 4
if n % 2 != 0:
	for i in range(n // 2):
		(e, count) = c.most_common()[0]
		if count <= 1:
			print('NO')
			exit(0)
		a[n // 2][i] = e
		a[n // 2][n - 1 - i] = e
		c[e] = count - 2
	for i in range(n // 2):
		(e, count) = c.most_common()[0]
		if count <= 1:
			print('NO')
			exit(0)
		a[i][n // 2] = e
		a[n - 1 - i][n // 2] = e
		c[e] = count - 2
	m = c.most_common()[0]
	if m[1] <= 0:
		print('NO')
		exit(0)
	a[n // 2][n // 2] = m[0]
print('YES')
for i in range(n):
	print(*a[i])


import sys

def print_mat(m, n):
	for row in m:
		str = '%s ' * n
		print(str % tuple(row))

def calculate_quadruplas(l, ret=[]):
	if len(l) < 4:
		return ret
	if l[0] == l[1] == l[2] == l[3]:
		ret.append(l[0])
		return calculate_quadruplas(l[4:], ret=ret)
	else:
		return calculate_quadruplas(l[1:], ret=ret)

def calcu_tuples(l, ret=[]):
	if len(l) < 2:
		return ret
	if l[0] == l[1]:
		ret.append(l[0])
		return calcu_tuples(l[2:], ret=ret)
	else:
		return calcu_tuples(l[1:], ret=ret)
n = int(input())
A = list(map(int, input().split()))
m = [[0 for i in range(n)] for j in range(n)]
if n % 2 == 0:
	for i in range(n // 2):
		for j in range(n // 2):
			a = A[0]
			m[i][j] = a
			try:
				for k in range(4):
					A.remove(a)
			except ValueError:
				print('NO')
				sys.exit(0)
else:
	try:
		A.sort()
		nmbrs_to_be_used_four_time = calculate_quadruplas(A[:])
		for i in nmbrs_to_be_used_four_time:
			for j in range(4):
				A.remove(i)
		for i in range(n // 2):
			for j in range(n // 2):
				a = nmbrs_to_be_used_four_time[0]
				m[i][j] = a
				nmbrs_to_be_used_four_time.remove(a)
		nmbrs_to_be_used_two_time = calcu_tuples(A[:])
		for i in nmbrs_to_be_used_two_time:
			A.remove(i)
			A.remove(i)
		nmbrs_to_be_used_two_time += nmbrs_to_be_used_four_time * 2
		for i in range(n // 2):
			m[i][n // 2] = nmbrs_to_be_used_two_time.pop(0)
			m[n // 2][i] = nmbrs_to_be_used_two_time.pop(0)
		m[n // 2][n // 2] = A.pop(0)
	except:
		print('NO')
		sys.exit(0)
for i in range(0, n // 2):
	for j in range(n // 2, n):
		jj = n - j - 1
		m[i][j] = m[i][jj]
for i in range(n // 2, n):
	for j in range(n // 2):
		ii = n - i - 1
		m[i][j] = m[ii][j]
for i in range(n // 2, n):
	for j in range(n // 2, n):
		jj = n - j - 1
		ii = n - i - 1
		m[i][j] = m[ii][jj]
print('YES')
print_mat(m, n)


from sys import stdin, stdout
from collections import Counter as co
inp = lambda : (int(o) for o in stdin.readline().split())
sinp = lambda : (o for o in stdin.readline().split())
out = lambda : stdout.write('YES\n')
out2 = lambda : stdout.write('NO\n')
I = lambda : map(int, input().split())
Y = lambda : int(input())
x = 100
for i in range(100):
	x += 1.2
x = 0
n = Y()
d = co(list(I()))
ans = [[0] * n for i in range(n)]
st = []
c = 0
for i in d.keys():
	st.append(i)
	if d[i] % 2:
		c += 1
		if c == 2 or (c == 1 and n % 2 == 0):
			out2()
			exit(0)
for i in range(n // 2):
	for j in range(n // 2):
		try:
			while len(st) > 0 and d[st[-1]] == 0:
				st.pop()
			while len(st) > 0 and d[st[-1]] < 4:
				st.pop()
			if ans[i][n - j - 1] == 0:
				ans[i][n - j - 1] = st[-1]
				d[st[-1]] -= 1
			if ans[n - i - 1][n - j - 1] == 0:
				ans[n - i - 1][n - j - 1] = st[-1]
				d[st[-1]] -= 1
			if ans[i][j] == 0:
				ans[i][j] = st[-1]
				d[st[-1]] -= 1
			if ans[n - i - 1][j] == 0:
				ans[n - i - 1][j] = st[-1]
				d[st[-1]] -= 1
		except:
			out2()
			exit(0)
st = list(d.keys())
for i in range(n // 2):
	try:
		while len(st) > 0 and d[st[-1]] == 0:
			st.pop()
		while len(st) > 0 and d[st[-1]] < 2:
			st.pop()
		if n % 2:
			ans[i][n // 2] = st[-1]
			ans[n - 1 - i][n // 2] = st[-1]
			d[st[-1]] -= 2
	except:
		out2()
		exit()
r = list(d.keys())
for i in range(n // 2):
	try:
		while len(r) > 0 and d[r[-1]] == 0:
			r.pop()
		while len(r) > 0 and d[r[-1]] < 2:
			r.pop()
		if n % 2:
			ans[n // 2][i] = r[-1]
			ans[n // 2][n - i - 1] = r[-1]
			d[r[-1]] -= 2
	except:
		out2()
		exit(0)
for i in d.keys():
	if d[i] != 0 and n % 2:
		ans[n // 2][n // 2] = i
		break
for i in range(n):
	for j in range(n):
		if ans[i][j] == 0:
			out2()
			exit(0)
out()
for i in range(n):
	print(*ans[i])


import os
import sys
from io import BytesIO, IOBase
import math
from queue import Queue
import collections
import itertools
import bisect
import heapq
import random

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countcon(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def maxfac(n):
	root = int(n ** 0.5)
	for i in range(2, root + 1):
		if n % i == 0:
			return n // i
	return n

def p2(n):
	c = 0
	while n % 2 == 0:
		n //= 2
		c += 1
	return c

def seive(n):
	primes = [True] * (n + 1)
	primes[1] = primes[0] = False
	i = 2
	while i * i <= n:
		if primes[i] == True:
			for j in range(i * i, n + 1, i):
				primes[j] = False
		i += 1
	pr = []
	for i in range(0, n + 1):
		if primes[i]:
			pr.append(i)
	return pr

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def denofactinverse(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return pow(fac, m - 2, m)

def numofact(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return fac

def sod(n):
	s = 0
	while n > 0:
		s += n % 10
		n //= 10
	return s

def getXor(n):
	xor = 1
	for i in range(2, n + 1):
		xor = xor ^ i
	return xor
n = int(input())
l = list(map(int, input().split()))
cnt = [0] * (max(l) + 1)
for i in l:
	cnt[i] += 1
if n % 2 == 0:
	f = True
	for i in cnt:
		if i % 4:
			f = False
			break
	if f:
		print('YES')
		ele = []
		for i in range(0, len(cnt)):
			ele += [i] * (cnt[i] // 4)
		mat = []
		ptr = 0
		for i in range(0, n // 2):
			cl = []
			for j in range(0, n // 2):
				cl.append(ele[ptr])
				ptr += 1
			mat.append(cl)
		for i in range(0, n // 2):
			mat[i] += mat[i][::-1]
		for i in range(0, n // 2):
			mat.append(mat[n // 2 - 1 - i])
		for i in mat:
			print(*i)
	else:
		print('NO')
else:
	odd = []
	for i in range(0, len(cnt)):
		if cnt[i] % 2:
			odd.append(i)
	if len(odd) != 1:
		print('NO')
	else:
		cnt[odd[0]] -= 1
		ele = []
		mid = []
		for i in range(0, len(cnt)):
			ele += [i] * (cnt[i] // 4)
			cnt[i] %= 4
			mid += [i] * (cnt[i] // 2)
		if len(ele) < n // 2 * (n // 2):
			print('NO')
		else:
			for i in range(n // 2 * (n // 2), len(ele)):
				mid += [ele[i]] * 2
			ele = ele[:n // 2 * (n // 2)]
			mat = [[] for i in range(0, n // 2)]
			ptr = 0
			for i in range(0, n // 2):
				for j in range(0, n // 2):
					mat[i].append(ele[ptr])
					ptr += 1
			mr = mid[:len(mid) // 2]
			mc = mid[len(mid) // 2:]
			for i in range(0, n // 2):
				mat[i] += mat[i][::-1].copy()
			for i in range(0, n // 2):
				mat.append(mat[n // 2 - 1 - i].copy())
			mat.insert(n // 2, mr + odd + mr[::-1])
			for i in range(0, n // 2):
				colval = mc[i]
				mat[i].insert(n // 2, colval)
				mat[n - 1 - i].insert(n // 2, colval)
			print('YES')
			for i in mat:
				print(*i)


from collections import Counter
n = int(input())
a = map(int, input().split())
c = Counter(a)
r = []
for _ in range(n):
	r.append([0] * n)
flag = True
j = 0
h = n // 2
while True:
	x = c.most_common(1)[0]
	if x[1] == 0:
		break
	if j < (n - n % 2) ** 2:
		if x[1] < 4:
			flag = False
			break
		(b, a) = (int(j // 4 // h), int(j // 4 % h))
		r[b][a] = x[0]
		r[n - b - 1][a] = x[0]
		r[b][n - a - 1] = x[0]
		r[n - b - 1][n - a - 1] = x[0]
		j += 4
		c[x[0]] -= 4
	elif j < n * n - 1:
		if x[1] < 2:
			flag = False
			break
		j += 2
		c[x[0]] -= 2
		if j < n * n - n + 2:
			a = (j - 2 - (n - 1) ** 2) // 2
			r[h][a] = x[0]
			r[h][n - a - 1] = x[0]
		else:
			a = (j - 1 - n - (n - 1) ** 2) // 2
			r[a][h] = x[0]
			r[n - a - 1][h] = x[0]
	else:
		r[h][h] = x[0]
		c[x[0]] -= 1
if flag:
	print('YES')
	for i in range(n):
		print(*r[i])
else:
	print('NO')


N = int(input())
M = [[0 for _ in range(N)] for _ in range(N)]
A = {}
for a in map(int, input().split(' ')):
	if a in A:
		A[a] += 1
	else:
		A[a] = 1
C = []
E = []
X = []
for (k, v) in A.items():
	while v >= 4:
		C.append(k)
		v -= 4
	if v >= 2:
		E.append(k)
		v -= 2
	if v:
		X.append(k)
if N % 2:
	if len(X) != 1:
		print('NO')
		exit()
	while C and len(E) < N - 1:
		x = C.pop()
		E.append(x)
		E.append(x)
	if len(E) != N - 1:
		print('NO')
		exit()
	M[N // 2][N // 2] = X.pop()
	for i in range(N // 2):
		M[N // 2][i] = M[N // 2][-i - 1] = E.pop()
		M[i][N // 2] = M[-i - 1][N // 2] = E.pop()
	for i in range(N // 2):
		for j in range(N // 2):
			M[i][j] = M[-i - 1][j] = M[i][-j - 1] = M[-i - 1][-j - 1] = C.pop()
else:
	if E or X:
		print('NO')
		exit()
	for i in range(N // 2):
		for j in range(N // 2):
			M[i][j] = M[-i - 1][j] = M[i][-j - 1] = M[-i - 1][-j - 1] = C.pop()
print('YES')
print('\n'.join((' '.join(map(str, l)) for l in M)))


n = int(input())
ar = list(map(int, input().split()))
kek = [0] * 1001
for elem in ar:
	kek[elem] += 1
ans = [[0] * n for i in range(n)]
lol = True
for i in range(n // 2):
	for j in range(n // 2):
		flag = True
		for z in range(1001):
			if kek[z] >= 4:
				ans[i][j] = z
				ans[i][n - j - 1] = z
				ans[n - i - 1][j] = z
				ans[n - i - 1][n - j - 1] = z
				flag = False
				kek[z] -= 4
				break
		if flag:
			lol = False
if n % 2 == 0:
	if lol:
		print('YES')
		for elem in ans:
			print(*elem)
	else:
		print('NO')
else:
	for j in range(n // 2):
		flag = True
		for z in range(1001):
			if kek[z] >= 2:
				ans[n // 2][j] = z
				ans[n // 2][n - j - 1] = z
				flag = False
				kek[z] -= 2
				break
		if flag:
			lol = False
	for i in range(n // 2):
		flag = True
		for z in range(1001):
			if kek[z] >= 2:
				ans[i][n // 2] = z
				ans[n - i - 1][n // 2] = z
				flag = False
				kek[z] -= 2
				break
		if flag:
			lol = False
	if lol and sum(kek) == 1:
		ans[n // 2][n // 2] = kek.index(1)
		print('YES')
		for elem in ans:
			print(*elem)
	else:
		print('NO')


n = int(input())
cl = sorted(list(map(int, input().split())))
k = n ** 2
if n % 2 == 0:
	st = list(set(cl))
	dic = {}
	for x in st:
		dic.update({x: cl.count(x)})
	res = [[0 for _ in range(n // 2)] for _ in range(n // 2)]
	i = 0
	j = 0
	t = n // 2
	for x in dic.keys():
		while dic[x] >= 4 and i < t:
			res[i][j] = x
			j += 1
			dic[x] -= 4
			if j == t:
				j = 0
				i += 1
	if i < t or j != 0:
		print('NO')
	else:
		print('YES')
		for line in res:
			s = ''
			for c in line:
				s += str(c) + ' '
			for c in line[::-1]:
				s += str(c) + ' '
			print(s + ' ')
		for line in res[::-1]:
			s = ''
			for c in line:
				s += str(c) + ' '
			for c in line[::-1]:
				s += str(c) + ' '
			print(s + ' ')
else:
	st = list(set(cl))
	dic = {}
	for x in st:
		dic.update({x: cl.count(x)})
	res = [[0 for _ in range(n // 2)] for _ in range(n // 2)]
	i = 0
	j = 0
	t = n // 2
	for x in dic.keys():
		if i == t:
			break
		while dic[x] >= 4 and i < t:
			res[i][j] = x
			j += 1
			dic[x] -= 4
			if j == t:
				j = 0
				i += 1
	count1 = 0
	count2 = 0
	res1 = []
	res2 = []
	for x in dic.keys():
		while dic[x] >= 2:
			if count1 < n // 2:
				res1.append(x)
				dic[x] -= 2
				count1 += 1
			else:
				res2.append(x)
				dic[x] -= 2
				count2 += 1
	if i < t or j != 0 or count1 != n // 2 or (count2 != n // 2):
		print('NO')
	else:
		ost = 0
		for x in dic.keys():
			if dic[x] != 0:
				ost = x
				break
		print('YES')
		i = 0
		for line in res:
			s = ''
			for c in line:
				s += str(c) + ' '
			s += str(res1[i]) + ' '
			i += 1
			for c in line[::-1]:
				s += str(c) + ' '
			print(s + ' ')
		ss = ''
		for i in range(n // 2):
			ss += str(res2[i]) + ' '
		ss += str(ost) + ' '
		for i in range(n // 2):
			ss += str(res2[::-1][i]) + ' '
		print(ss + ' ')
		i = 0
		for line in res[::-1]:
			s = ''
			for c in line:
				s += str(c) + ' '
			s += str(res1[::-1][i]) + ' '
			i += 1
			for c in line[::-1]:
				s += str(c) + ' '
			print(s + ' ')


n = int(input())
a = []
cnt_num = dict()
for i in map(int, input().split()):
	cnt_num[i] = cnt_num.get(i, 0) + 1
	a.append(i)
if n == 1:
	print('YES')
	print(*a)
	exit(0)
matrix = [[0] * n for _ in range(n)]
for i in range(n // 2):
	for j in range(n // 2):
		for (k, am) in cnt_num.items():
			if am >= 4:
				matrix[i][j] = k
				matrix[i][n - j - 1] = k
				matrix[n - i - 1][j] = k
				matrix[n - i - 1][n - j - 1] = k
				cnt_num[k] -= 4
				break
		else:
			print('no')
			exit(0)
if n % 2:
	for i in range(n // 2):
		for (k, am) in cnt_num.items():
			if am >= 2:
				matrix[i][n // 2] = k
				matrix[n - i - 1][n // 2] = k
				cnt_num[k] -= 2
				break
		else:
			print('no')
			exit(0)
	for i in range(n // 2):
		for (k, am) in cnt_num.items():
			if am >= 2:
				matrix[n // 2][i] = k
				matrix[n // 2][n - i - 1] = k
				cnt_num[k] -= 2
				break
		else:
			print('no')
			exit(0)
	for (k, am) in cnt_num.items():
		if am >= 1:
			matrix[n // 2][n // 2] = k
			break
	else:
		print('no')
		exit(0)
print('YES')
for i in matrix:
	print(*i)


n = int(input())
a = list(map(int, input().split()))
d = {}
for i in a:
	d[i] = d.get(i, 0) + 1
ans = [[0] * n for i in range(n)]
st = []
for i in d.keys():
	st.append(i)
for i in range(n // 2):
	for j in range(n // 2):
		try:
			while len(st) > 0 and d[st[-1]] == 0:
				st.pop()
			while len(st) > 0 and d[st[-1]] < 4:
				st.pop()
			if ans[i][j] == 0:
				ans[i][j] = st[-1]
				d[st[-1]] -= 1
			if ans[n - i - 1][j] == 0:
				ans[n - i - 1][j] = st[-1]
				d[st[-1]] -= 1
			if ans[i][n - j - 1] == 0:
				ans[i][n - j - 1] = st[-1]
				d[st[-1]] -= 1
			if ans[n - i - 1][n - j - 1] == 0:
				ans[n - i - 1][n - j - 1] = st[-1]
				d[st[-1]] -= 1
		except:
			exit(print('NO'))
st = list(d.keys())
for i in range(n // 2):
	try:
		while len(st) > 0 and d[st[-1]] == 0:
			st.pop()
		while len(st) > 0 and d[st[-1]] < 2:
			st.pop()
		if n % 2:
			ans[i][n // 2] = st[-1]
			ans[n - 1 - i][n // 2] = st[-1]
			d[st[-1]] -= 2
	except:
		exit(print('NO'))
r = list(d.keys())
for i in range(n // 2):
	try:
		while len(r) > 0 and d[r[-1]] == 0:
			r.pop()
		while len(r) > 0 and d[r[-1]] < 2:
			r.pop()
		if n % 2:
			ans[n // 2][i] = r[-1]
			ans[n // 2][n - i - 1] = r[-1]
			d[r[-1]] -= 2
	except:
		exit(print('NO'))
for i in d.keys():
	if d[i] != 0 and n % 2:
		ans[n // 2][n // 2] = i
		break
for i in range(n):
	for j in range(n):
		if ans[i][j] == 0:
			exit(print('NO'))
print('YES')
for i in range(n):
	print(*ans[i])


_ = input()
n = int(_)
_ = input()
a = _.split()
a = [int(_) for _ in a]
a_dict = {}
for i in a:
	if i in a_dict:
		a_dict[i] = a_dict[i] + 1
	else:
		a_dict[i] = 1
if n % 2 == 0:
	answer = [[0] * n for _ in range(n)]
	for i in a_dict.values():
		if i % 4 != 0:
			print('NO')
			break
	else:
		print('YES')
		(a, b) = (0, 0)
		for (i, value) in a_dict.items():
			for j in range(0, value // 4):
				if b >= n // 2:
					a = a + 1
					b = 0
				answer[a][b] = str(i)
				answer[n - 1 - a][b] = str(i)
				answer[a][n - 1 - b] = str(i)
				answer[n - 1 - a][n - 1 - b] = str(i)
				b = b + 1
		for k in answer:
			print(' '.join(k))
else:
	answer = [[0] * n for _ in range(n)]
	one = 0
	four = 0
	for i in a_dict.values():
		if i % 2 == 1:
			one = one + 1
			if i > 4:
				four = four + i // 4
		else:
			four = four + i // 4
	if one != 1 or four < n // 2 * (n // 2):
		print('NO')
	else:
		print('YES')
		(a, b) = (0, 0)
		(c, d) = (0, 0)
		for (i, value) in a_dict.items():
			if value % 2 == 1:
				answer[n // 2][n // 2] = str(i)
				value = value - 1
				if value >= 4:
					k = 0
					for j in range(0, value // 4):
						if a < n // 2 and b <= n // 2:
							if b >= n // 2:
								a = a + 1
								b = 0
							if a >= n // 2:
								continue
							answer[a][b] = str(i)
							answer[n - 1 - a][b] = str(i)
							answer[a][n - 1 - b] = str(i)
							answer[n - 1 - a][n - 1 - b] = str(i)
							b = b + 1
							k = k + 4
					value = value - k
				if value >= 2:
					for j in range(0, value // 2):
						if c < n // 2:
							answer[n // 2][c] = str(i)
							answer[n // 2][n - 1 - c] = str(i)
						else:
							answer[c + 1][n // 2] = str(i)
							answer[n - 1 - c - 1][n // 2] = str(i)
						c = c + 1
			else:
				if value >= 4:
					k = 0
					for j in range(0, value // 4):
						if a < n // 2 and b <= n // 2:
							if b >= n // 2:
								a = a + 1
								b = 0
							if a >= n // 2:
								continue
							answer[a][b] = str(i)
							answer[n - 1 - a][b] = str(i)
							answer[a][n - 1 - b] = str(i)
							answer[n - 1 - a][n - 1 - b] = str(i)
							b = b + 1
							k = k + 4
					value = value - k
				if value >= 2:
					for j in range(0, value // 2):
						if c < n // 2:
							answer[n // 2][c] = str(i)
							answer[n // 2][n - 1 - c] = str(i)
						else:
							answer[c + 1][n // 2] = str(i)
							answer[n - 1 - c - 1][n // 2] = str(i)
						c = c + 1
		for k in answer:
			print(' '.join(k))


n = int(input())
K = list(map(int, input().split()))
A = {}
for i in range(len(K)):
	A[K[i]] = A.get(K[i], 0) + 1
B = [[0 for _ in range(n)] for __ in range(n)]
i1 = 0
j1 = 0
i2 = 0
k = 1
for j in A:
	if n % 2 == 0:
		while A[j] - 4 >= 0:
			B[i1][j1] = j
			B[i1][n - j1 - 1] = j
			B[n - i1 - 1][j1] = j
			B[n - i1 - 1][n - j1 - 1] = j
			A[j] -= 4
			i1 += 1
			(i1, j1) = (i1 % (n // 2), j1 + i1 // (n // 2))
	else:
		while A[j] - 4 >= 0 and i1 < n // 2 and (j1 < n // 2):
			B[i1][j1] = j
			B[i1][n - j1 - 1] = j
			B[n - i1 - 1][j1] = j
			B[n - i1 - 1][n - j1 - 1] = j
			A[j] -= 4
			i1 += 1
			(i1, j1) = (i1 % (n // 2), j1 + i1 // (n // 2))
		while A[j] >= 2 and k < 3:
			if k == 1:
				B[i2][n // 2] = j
				B[n - i2 - 1][n // 2] = j
				A[j] -= 2
				i2 += 1
				if i2 == n // 2:
					k = 2
					i2 = 0
			elif k == 2:
				B[n // 2][i2] = j
				B[n // 2][n - i2 - 1] = j
				A[j] -= 2
				i2 += 1
				if i2 == n // 2:
					k = 3
					i2 = 0
		if A[j] == 1 and B[n // 2][n // 2] == 0:
			B[n // 2][n // 2] = j
			A[j] -= 1
	if A[j] > 0:
		print('NO')
		exit(0)
print('YES')
for i in B:
	print(*i)


n = int(input())
arr = list(map(int, input().strip().split()))
mp = {}
for i in range(n * n):
	if arr[i] in mp:
		mp[arr[i]] += 1
	else:
		mp[arr[i]] = 1
ans = [[0] * n for i in range(n)]
if n % 2 == 0:
	for i in range(n // 2):
		for j in range(n // 2):
			x = 0
			for y in mp:
				if mp[y] >= 4:
					mp[y] -= 4
					x = y
					break
			ans[i][j] = x
			ans[n - i - 1][j] = x
			ans[i][n - j - 1] = x
			ans[n - 1 - i][n - 1 - j] = x
else:
	for i in range(n // 2):
		for j in range(n // 2):
			x = 0
			for y in mp:
				if mp[y] >= 4:
					mp[y] -= 4
					x = y
					break
			ans[i][j] = x
			ans[n - i - 1][j] = x
			ans[i][n - j - 1] = x
			ans[n - 1 - i][n - 1 - j] = x
	for i in range(n // 2):
		x = 0
		for y in mp:
			if mp[y] >= 2:
				mp[y] -= 2
				x = y
				break
		ans[n // 2][i] = x
		ans[n // 2][n - i - 1] = x
	for i in range(n // 2):
		x = 0
		for y in mp:
			if mp[y] >= 2:
				mp[y] -= 2
				x = y
				break
		ans[i][n // 2] = x
		ans[n - i - 1][n // 2] = x
	x = 0
	for y in mp:
		if mp[y] % 2 == 1:
			mp[y] -= 1
			x = y
			break
	ans[n // 2][n // 2] = x
zs = 0
for i in range(n):
	for j in range(n):
		if ans[i][j] == 0:
			zs = 1
if zs == 0:
	print('YES')
	for i in range(n):
		print(*ans[i])
else:
	print('NO')


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from collections import Counter as C
(n,) = I()
l = I()
l.sort()
c = C(l)
if n == 1:
	print('YES')
	print(l[0])
	exit()
if n % 2 == 0:
	for i in c:
		if c[i] % 4:
			print('NO')
			exit()
	print('YES')
	ans = []
	i = 0
	while i < n ** 2:
		ans.append(l[i])
		i += 4
	res = []
	for i in range(n // 2):
		res.append(ans[i * n // 2:i * n // 2 + n // 2])
	for i in res:
		print(*i, *reversed(i))
	for i in reversed(res):
		print(*i, *reversed(i))
if n % 2:
	temp = l[:]
	l = []
	k = []
	s = []
	n -= 1
	for i in c:
		while c[i] >= 4 and len(l) < n ** 2:
			for x in range(4):
				l.append(i)
			c[i] -= 4
		while c[i] >= 2:
			for x in range(2):
				s.append(i)
			c[i] -= 2
		while c[i] >= 1:
			k.append(i)
			c[i] = 0
	if len(k) != 1 or len(s) > 2 * n or len(l) < n ** 2:
		print('NO')
		exit()
	print('YES')
	l.sort()
	ans = []
	i = 0
	while i < n ** 2:
		ans.append(l[i])
		i += 4
	res = []
	aiyo = []
	i = 0
	while i < len(s):
		aiyo.append(s[i])
		i += 2
	for i in range(n // 2):
		res.append(ans[i * n // 2:i * n // 2 + n // 2])
	j = 0
	zz = []
	el = aiyo[j]
	for i in res:
		print(*i, el, *reversed(i))
		zz.append(el)
		j += 1
		el = aiyo[j]
	kkk = aiyo[j:]
	print(*kkk, k[0], *reversed(kkk))
	j = 0
	zz = list(reversed(zz))
	el = zz[j]
	for i in reversed(res):
		print(*i, el, *reversed(i))
		j += 1
		if j < len(zz):
			el = zz[j]


def p(l, n):
	for i in range(n):
		for j in range(n):
			print(l[i][j], end=' ')
		print('')
n = int(input())
l1 = list(map(int, input().split()))
str1 = 'YES'
l2 = [[0 * i for i in range(1, n + 1)] for i in range(1, n + 1)]
d = {}
for i in range(n ** 2):
	if l1[i] not in d:
		d[l1[i]] = 1
	else:
		d[l1[i]] += 1
lis = [[x, y] for (x, y) in d.items()]
lis.sort(key=lambda x: x[1], reverse=True)
for i in range(0, n // 2):
	for j in range(0, n // 2):
		if lis[0][1] >= 4:
			l2[i][j] = lis[0][0]
			l2[n - i - 1][j] = lis[0][0]
			l2[i][n - j - 1] = lis[0][0]
			l2[n - i - 1][n - j - 1] = lis[0][0]
			lis[0][1] -= 4
			if lis[0][1] < 4:
				lis.sort(key=lambda x: x[1], reverse=True)
		else:
			str1 = 'NO'
			break
if str1 == 'YES' and n % 2 != 0:
	lis.sort(key=lambda x: x[1], reverse=True)
	for i in range(n // 2):
		if lis[0][1] >= 2:
			l2[i][n // 2] = lis[0][0]
			l2[n - i - 1][n // 2] = lis[0][0]
			lis[0][1] -= 2
			if lis[0][1] < 2:
				lis.sort(key=lambda x: x[1], reverse=True)
		else:
			str1 = 'NO'
			break
	for i in range(n // 2):
		if lis[0][1] >= 2:
			l2[n // 2][i] = lis[0][0]
			l2[n // 2][n - i - 1] = lis[0][0]
			lis[0][1] -= 2
			if lis[0][1] < 2:
				lis.sort(key=lambda x: x[1], reverse=True)
		else:
			str1 = 'NO'
			break
if str1 == 'YES' and n % 2 != 0:
	lis.sort(key=lambda x: x[1], reverse=True)
	if lis[0][1] >= 1:
		l2[n // 2][n // 2] = lis[0][0]
print(str1)
if str1 == 'YES':
	p(l2, n)


__author__ = 'Esfandiar'
import sys
from collections import defaultdict
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
for i in range(n * n):
	d[a[i]] += 1
res = [[0 for i in range(n)] for _ in range(n)]
if n % 2 == 0:
	ke = list(d.keys())
	ind = 0
	for i in range(n // 2):
		for j in range(n // 2):
			v = ke[ind]
			if d[v] % 4 != 0:
				print('NO')
				exit()
			else:
				res[i][j] = v
				res[i][n - j - 1] = v
				res[n - i - 1][j] = v
				res[n - i - 1][n - j - 1] = v
			d[v] -= 4
			if d[v] == 0:
				ind += 1
	print('YES')
	for i in range(n):
		print(*res[i])
else:

	def check(i, j, n, d, res):
		for v in d.keys():
			if d[v] >= 4:
				res[i][j] = v
				res[i][n - j - 1] = v
				res[n - i - 1][j] = v
				res[n - i - 1][n - j - 1] = v
				d[v] -= 4
				return 1
		return 0
	for i in range(n // 2):
		for j in range(n // 2):
			if check(i, j, n, d, res) == 0:
				print('NO')
				exit()
	f = 0
	keys = -1
	for v in d.keys():
		if d[v] % 2 == 1:
			f += 1
			keys = v
	if f != 1:
		print('NO')
		exit()
	klid = list(d.keys())
	cou = 0
	yy = n // 2
	i = 0
	while i < n // 2 and cou < len(klid):
		if klid[cou] != keys and d[klid[cou]] != 0:
			res[yy][i] = klid[cou]
			res[yy][n - i - 1] = klid[cou]
			d[klid[cou]] -= 2
			if d[klid[cou]] == 0:
				cou += 1
			i += 1
		else:
			cou += 1
	cou = 0
	i = 0
	while i < n // 2 and cou < len(klid):
		if klid[cou] != keys and d[klid[cou]] != 0:
			res[i][yy] = klid[cou]
			res[n - i - 1][yy] = klid[cou]
			d[klid[cou]] -= 2
			if d[klid[cou]] == 0:
				cou += 1
			i += 1
		else:
			cou += 1
	res[yy][yy] = keys
	d[keys] -= 1
	for i in range(n // 2):
		if res[i][yy] == 0:
			res[i][yy] = keys
			res[n - i - 1][yy] = keys
	for i in range(n // 2):
		if res[yy][i] == 0:
			res[yy][i] = keys
			res[yy][n - i - 1] = keys
	print('YES')
	for i in range(n):
		print(*res[i])


inp_int = int(input())
inp = list(map(int, input().split()))
inp.sort()
indices = []
matrix = []
for i in range(inp_int):
	temp = []
	for j in range(inp_int):
		temp.append(0)
	matrix.append(temp)
for i in range(1001):
	indices.append(0)
flag = 0
for i in range(len(inp)):
	indices[inp[i]] += 1
if inp_int % 2 == 0:
	temp = []
	for i in range(1, 1001):
		if indices[i] % 4 != 0:
			flag = 1
			break
		elif indices[i] > 0:
			for j in range(indices[i] // 4):
				temp.append(i)
	if flag == 1:
		print('NO')
	else:
		temp_index = 0
		for i in range(inp_int // 2):
			for j in range(inp_int // 2):
				matrix[i][j] = temp[temp_index]
				matrix[inp_int - 1 - i][j] = temp[temp_index]
				matrix[i][inp_int - 1 - j] = temp[temp_index]
				matrix[inp_int - 1 - i][inp_int - 1 - j] = temp[temp_index]
				temp_index += 1
		print('YES')
		for i in range(inp_int):
			for j in range(inp_int):
				print(matrix[i][j], end=' ')
			print()
else:
	temp = []
	temp2 = []
	special = 0
	for i in range(1, 1001):
		if indices[i] % 4 != 0:
			if indices[i] % 4 == 1 and flag == 0:
				for j in range(indices[i] // 4):
					temp.append(i)
				flag = 1
				special = i
			elif indices[i] % 4 == 3 and flag == 0:
				for j in range(indices[i] // 4):
					temp.append(i)
				temp2.append(i)
				flag = 1
				special = i
			elif indices[i] % 4 == 2:
				for j in range(indices[i] // 4):
					temp.append(i)
				temp2.append(i)
			else:
				flag = 2
				break
		elif indices[i] > 0:
			for j in range(indices[i] // 4):
				temp.append(i)
	if flag != 1 or len(temp) < ((inp_int - 1) // 2) ** 2:
		print('NO')
	else:
		temp_index = 0
		for i in range(inp_int // 2):
			for j in range(inp_int // 2):
				matrix[i][j] = temp[temp_index]
				matrix[inp_int - 1 - i][j] = temp[temp_index]
				matrix[i][inp_int - 1 - j] = temp[temp_index]
				matrix[inp_int - 1 - i][inp_int - 1 - j] = temp[temp_index]
				temp_index += 1
		temp2_index = 0
		for i in range(inp_int // 2):
			if temp2_index >= len(temp2):
				matrix[i][inp_int // 2] = temp[temp_index]
				matrix[inp_int - i - 1][inp_int // 2] = temp[temp_index]
				matrix[inp_int // 2][i] = temp[temp_index]
				matrix[inp_int // 2][inp_int - i - 1] = temp[temp_index]
				temp_index += 1
			else:
				matrix[i][inp_int // 2] = temp2[temp2_index]
				matrix[inp_int - i - 1][inp_int // 2] = temp2[temp2_index]
				temp2_index += 1
				matrix[inp_int // 2][i] = temp2[temp2_index]
				matrix[inp_int // 2][inp_int - i - 1] = temp2[temp2_index]
				temp2_index += 1
		matrix[inp_int // 2][inp_int // 2] = special
		print('YES')
		for i in range(inp_int):
			for j in range(inp_int):
				print(matrix[i][j], end=' ')
			print()


from collections import Counter
n = int(input())
A = Counter(map(int, input().split()))

def reflections(i, j, n):
	return [(i, j), (n - 1 - i, j), (i, n - 1 - j), (n - 1 - i, n - 1 - j)]
possible = True
odd_val = -1
pairs = []
if n % 2 == 1:
	for (k, v) in A.items():
		if v % 2 != 0:
			if odd_val == -1 and v % 2 != 0:
				odd_val = k
				A[k] = v - 1
				v -= 1
			else:
				possible = False
		if v % 4 == 2:
			pairs += [k]
			A[k] = v - 2
			v -= 2
	if len(pairs) > n - 1:
		possible = False
else:
	for (k, v) in A.items():
		if v % 4 != 0:
			possible = False
if possible:
	print('YES')
	R = [[0] * n for _ in range(n)]
	k = 0
	vals = list(A.items())
	if odd_val != -1:
		while len(pairs) != n - 1:
			while vals[k][1] == 0:
				k += 1
			pairs += [vals[k][0]] * 2
			vals[k] = (vals[k][0], vals[k][1] - 4)
		R[n // 2][n // 2] = odd_val
		p = 0
		for i in range(n // 2):
			R[i][n // 2] = pairs[p]
			R[n - 1 - i][n // 2] = pairs[p]
			p += 1
		for i in range(n // 2):
			R[n // 2][i] = pairs[p]
			R[n // 2][n - 1 - i] = pairs[p]
			p += 1
	for i in range(n // 2):
		for j in range(n // 2):
			while vals[k][1] == 0:
				k += 1
			for (x, y) in reflections(i, j, n):
				R[x][y] = vals[k][0]
			vals[k] = (vals[k][0], vals[k][1] - 4)
	for row in R:
		print(' '.join(map(str, row)))
else:
	print('NO')


from collections import Counter

def find_num(counter, mod_num):
	for (k, v) in counter.items():
		if v >= mod_num:
			return (True, k)
	return (False, -1)

def main():
	n = int(input())
	a = list(map(int, input().split()))
	counter = Counter(a)
	grid = [[0] * n for _ in range(n)]
	for i in range(n // 2):
		for j in range(n // 2):
			(flag, val) = find_num(counter, 4)
			if not flag:
				print('NO')
				return
			counter[val] -= 4
			grid[i][j] = grid[n - i - 1][j] = grid[i][n - j - 1] = grid[n - i - 1][n - j - 1] = val
	if n % 2 == 1:
		mid = n // 2
		for i in range(n // 2):
			(flag, val) = find_num(counter, 2)
			if not flag:
				print('NO')
				return
			counter[val] -= 2
			grid[mid][i] = grid[mid][n - i - 1] = val
		for i in range(n // 2):
			(flag, val) = find_num(counter, 2)
			if not flag:
				print('NO')
				return
			counter[val] -= 2
			grid[i][mid] = grid[n - i - 1][mid] = val
		(_, val) = find_num(counter, 1)
		grid[mid][mid] = val
	print('YES')
	for i in range(n):
		for j in range(n):
			print(grid[i][j], end=' ')
		print()
main()


from itertools import groupby as gb
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
g = gb(a)
pr = (n // 2) ** 2
(one, two, four) = ([], [], [])
for (k, v) in g:
	ln = len(list(v))
	if ln % 2 == 1:
		if n % 2 == 0 or len(one) != 0:
			print('NO')
			exit()
		one.append(k)
		ln -= 1
	if ln % 4 == 2:
		two.append(k)
		ln -= 2
	while len(four) < pr and ln > 0:
		four.append(k)
		ln -= 4
	while ln > 0:
		two.append(k)
		ln -= 2
res = [[0 for _ in range(n)] for _ in range(n)]
(_1, _2, _4) = (len(one), len(two), len(four))
if n % 2 == 1:
	if _1 != 1:
		print('NO')
		exit()
	res[n // 2][n // 2] = one[0]
	piv = 0
	for i in range(n // 2):
		if piv >= _2:
			print('NO')
			exit()
		res[n // 2][i] = res[n // 2][n - 1 - i] = two[piv]
		piv += 1
	for i in range(n // 2):
		if piv >= _2:
			print('NO')
			exit()
		res[i][n // 2] = res[n - 1 - i][n // 2] = two[piv]
		piv += 1
	piv = 0
	for i in range(n // 2):
		for j in range(n // 2):
			if piv >= _4:
				print('NO')
				exit()
			res[i][j] = res[n - 1 - i][j] = res[i][n - 1 - j] = res[n - 1 - i][n - 1 - j] = four[piv]
			piv += 1
else:
	piv = 0
	for i in range(n // 2):
		for j in range(n // 2):
			if piv >= _4:
				print('NO')
				exit()
			res[i][j] = res[n - 1 - i][j] = res[i][n - 1 - j] = res[n - 1 - i][n - 1 - j] = four[piv]
			piv += 1
print('YES')
for l in res:
	print(*l)


n = int(input())
l = list(map(int, input().split()))
if n == 1:
	print('YES')
	print(l[0])
else:
	d = {}
	for i in l:
		try:
			d[i] += 1
		except KeyError:
			d[i] = 1
	if n % 2 != 0:
		o = 0
		t = 0
		for i in d.values():
			if i % 2 != 0:
				o += 1
				if (i - 1) % 4 == 2:
					t += 1
			elif i % 4 == 2:
				t += 1
		if o > 1:
			print('NO')
		elif t > n - 1:
			print('NO')
		else:
			print('YES')
			l1 = []
			for i in range(n):
				l2 = []
				for j in range(n):
					l2.append(0)
				l1.append(l2)
			for i in range(n // 2 + 1):
				for j in range(n // 2 + 1):
					if i != n // 2:
						if j != n // 2:
							a = 0
							for k in d.keys():
								if d[k] != 0:
									if d[k] // 4 >= 1:
										a = k
										d[k] -= 4
										break
							l1[i][j] = a
							l1[n - i - 1][j] = a
							l1[n - i - 1][n - j - 1] = a
							l1[i][n - j - 1] = a
						else:
							a = 0
							for k in d.keys():
								if d[k] != 0:
									if d[k] % 4 == 2 or (d[k] - 1) % 4 == 2:
										a = k
										d[k] -= 2
										break
							if a == 0:
								for k in d.keys():
									if d[k] != 0 and d[k] - 1 != 0:
										if d[k] % 4 == 0 or (d[k] - 1) % 4 == 0:
											a = k
											d[k] -= 2
											break
							l1[i][j] = a
							l1[n - i - 1][j] = a
					elif j != n // 2:
						a = 0
						for k in d.keys():
							if d[k] != 0:
								if d[k] % 4 == 2 or (d[k] - 1) % 4 == 2:
									a = k
									d[k] -= 2
									break
						if a == 0:
							for k in d.keys():
								if d[k] != 0 and d[k] - 1 != 0:
									if d[k] % 4 == 0 or (d[k] - 1) % 4 == 0:
										a = k
										d[k] -= 2
										break
						l1[i][j] = a
						l1[i][n - j - 1] = a
					else:
						a = 0
						for k in d.keys():
							if d[k] != 0:
								if d[k] % 2 != 0:
									a = k
									d[k] -= 1
									break
						l1[i][j] = a
			for i in l1:
				s = ''
				for j in i:
					s += str(j) + ' '
				print(s)
	else:
		c = 0
		for i in d.values():
			if i % 4 != 0:
				c = 1
				break
		if c == 1:
			print('NO')
		else:
			print('YES')
			l1 = []
			for i in range(n):
				l2 = []
				for j in range(n):
					l2.append(0)
				l1.append(l2)
			for i in range(n // 2):
				for j in range(n // 2):
					a = 0
					for k in d.keys():
						if d[k] != 0:
							a = k
							d[k] -= 4
							break
					l1[i][j] = a
					l1[i][n - j - 1] = a
					l1[n - i - 1][j] = a
					l1[n - i - 1][n - j - 1] = a
			for i in l1:
				s = ''
				for j in i:
					s += str(j) + ' '
				print(s)


class Solution:

	def __init__(self):
		n = int(input())
		num = []
		mat = []
		res = []
		for i in range(0, 1001):
			num.append(0)
		m = input().split()
		for i in range(n * n):
			if num[int(m[i])] == 0:
				res.append(int(m[i]))
			num[int(m[i])] += 1
		len = int(n / 2)
		f = True
		for i in range(len):
			for j in range(len):
				f = False
				for k in res:
					if num[k] >= 4:
						num[k] -= 4
						mat.append(k)
						f = True
						break
				if not f:
					print('No')
					return
		if n & 1:
			colum = []
			row = []
			for i in range(len):
				f = False
				for k in res:
					if num[k] >= 2:
						num[k] -= 2
						colum.append(k)
						f = True
						break
				if not f:
					print('No')
					return
			for i in range(len):
				f = False
				for k in res:
					if num[k] >= 2:
						num[k] -= 2
						row.append(k)
						f = True
						break
				if not f:
					print('No')
					return
			center = -1
			for i in res:
				if num[i] == 1:
					num[i] = 0
					center = i
					break
			if center == -1:
				print('No')
				return
			print('Yes')
			for i in range(len):
				for j in range(len * i, len * i + len):
					print(mat[j], end=' ')
				k = len * i + len - 1
				print(colum[i], end=' ')
				for j in range(len):
					print(mat[k], end='')
					if j == len - 1:
						print()
					else:
						print(end=' ')
					k -= 1
			i = len - 1
			for j in row:
				print(j, end=' ')
			print(center, end='')
			for j in row:
				print(' ' + str(row[i]), end='')
				i -= 1
			print()
			l = len - 1
			for i in range(len):
				result = []
				for j in range(len * len - (i + 1) * len, len * len - (i + 1) * len + len):
					result.append(mat[j])
					print(mat[j], end=' ')
				k = len - 1
				print(colum[l], end=' ')
				l -= 1
				for j in range(len):
					print(result[k], end='')
					if j == len - 1:
						print()
					else:
						print(end=' ')
					k -= 1
		else:
			print('Yes')
			for i in range(len):
				for j in range(len * i, len * i + len):
					print(mat[j], end=' ')
				k = len * i + len - 1
				for j in range(len):
					print(mat[k], end='')
					if j == len - 1:
						print()
					else:
						print(end=' ')
					k -= 1
			l = len - 1
			for i in range(len):
				for j in range(len * len - len * i - len, len * len - len * i):
					print(mat[j], end=' ')
				k = len * len - len * i - 1
				for j in range(len):
					print(mat[k], end='')
					if j == len - 1:
						print()
					else:
						print(end=' ')
					k -= 1
Solution()


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations

def li():
	return list(map(int, input().split()))

def num():
	return map(int, input().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def solve():
	t = 1
	for it in range(t):
		n = nu()
		a = li()
		ff = [0] * 1001
		qq = -1
		for i in a:
			ff[i] += 1
		zz = 0
		for i in range(len(ff)):
			if ff[i] % 2 == 1:
				zz += 1
				qq = i
		py = -1
		for i in range(n):
			if a[i] == qq:
				py = i
		if n % 2 == 0:
			if zz > 0:
				print('NO')
			else:
				xx = [0] * n
				for i in range(n):
					xx[i] = [0] * n
				cc = 0
				fl = True
				for i in range(n // 2):
					for j in range(n // 2):
						zp = False
						for k in range(len(ff)):
							if ff[k] >= 4:
								xx[i][j] = k
								zp = True
								xx[i][n - 1 - j] = k
								xx[n - 1 - i][j] = k
								xx[n - 1 - i][n - 1 - j] = k
								ff[k] -= 4
								break
						if zp == False:
							fl = False
				if fl == False:
					print('NO')
					continue
				print('YES')
				for i in range(n):
					for j in range(n):
						print(xx[i][j], end=' ')
					print()
		elif zz > 1:
			print('NO')
		else:
			fl = True
			if zz == 0:
				print('NO')
				continue
			xx = [0] * n
			for i in range(n):
				xx[i] = [0] * n
			rr = a[py]
			xx[n // 2][n // 2] = qq
			ff[qq] -= 1
			cc = 0
			for i in range(n // 2):
				for j in range(n // 2):
					zp = False
					for k in range(len(ff)):
						if ff[k] >= 4:
							xx[i][j] = k
							xx[i][n - 1 - j] = k
							xx[n - 1 - i][j] = k
							xx[n - 1 - i][n - 1 - j] = k
							ff[k] -= 4
							zp = True
							break
					if zp == False:
						fl = False
			for i in range(n // 2):
				zp = False
				for j in range(len(ff)):
					if ff[j] >= 2:
						xx[n // 2][i] = j
						xx[n // 2][n - 1 - i] = j
						zp = True
						ff[j] -= 2
						break
				if zp == False:
					fl = False
			for i in range(n // 2):
				zp = True
				for j in range(len(ff)):
					if ff[j] >= 2:
						xx[i][n // 2] = j
						zp = True
						xx[n - 1 - i][n // 2] = j
						ff[j] -= 2
						break
				if zp == False:
					fl = False
			if fl == False:
				print('NO')
				continue
			print('YES')
			for i in range(n):
				for j in range(n):
					print(xx[i][j], end=' ')
				print()
solve()


import sys
from collections import defaultdict as dd
from itertools import permutations as pp
from itertools import combinations as cc
from collections import Counter as ccd
from random import randint as rd
from bisect import bisect_left as bl
import heapq
mod = 10 ** 9 + 7

def ri(flag=0):
	if flag == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
n = ri(1)
a = ri()
check = dd(int)
for i in a:
	check[i] += 1
take = []
two = []
one = []
done = 0
for i in check:
	if check[i] % 4 == 0:
		for j in range(check[i] // 4):
			take.append(i)
	elif check[i] % 2 == 0:
		for j in range(check[i] // 4):
			take.append(i)
		two.append(i)
	elif check[i] % 2 == 1:
		if check[i] > 4:
			keep = i
			cooo = check[i] // 4
			if check[i] % 4 == 3:
				two.append(i)
			one.append(i)
		elif check[i] > 2:
			two.append(i)
			one.append(i)
		else:
			one.append(i)
	else:
		print('NO')
		done = 1
try:
	for i in range(cooo):
		take.append(keep)
except:
	pass
if n % 2 == 0 and done == 0:
	if len(two) == 0 and len(one) == 0:
		vis = [[0 for i in range(n)] for j in range(n)]
		for i in range(n):
			for j in range(n):
				if vis[i][j] == 0:
					if take:
						k = take.pop(0)
						vis[i][j] = k
						vis[n - i - 1][j] = k
						vis[i][n - j - 1] = k
						vis[n - i - 1][n - j - 1] = k
		done = 1
		for i in range(n):
			for j in range(n):
				if vis[i][j] == 0:
					done = 0
		if done:
			print('YES')
			for i in vis:
				print(*i)
		else:
			print('NO')
	else:
		print('NO')
if n % 2 == 1 and done == 0:
	if len(one) == 1:
		vis = [[0 for i in range(n)] for j in range(n)]
		for i in range(n // 2):
			for j in range(n // 2):
				if vis[i][j] == 0 and take:
					k = take.pop(0)
					vis[i][j] = k
					vis[n - i - 1][j] = k
					vis[i][n - j - 1] = k
					vis[n - i - 1][n - j - 1] = k
		x = 0
		y = n // 2
		x1 = n // 2
		y1 = n // 2
		for i in range(n // 2 + 1):
			for j in range(n // 2 + 1):
				if vis[i][j] == 0 and take:
					k = take.pop(0)
					vis[i][j] = k
					vis[j][i] = k
					vis[n - j - 1][n - i - 1] = k
					vis[n - i - 1][n - j - 1] = k
		for i in range(n // 2):
			x = n // 2
			if vis[i][x] == 0:
				if two:
					k = two.pop(0)
					vis[i][x] = k
					vis[n - i - 1][x] = k
		for i in range(n // 2):
			x = n // 2
			if vis[x][i] == 0:
				if two:
					k = two.pop(0)
					vis[x][i] = k
					vis[x][n - i - 1] = k
		vis[n // 2][n // 2] = one[0]
		done = 1
		for i in range(n):
			for j in range(n):
				if vis[i][j] == 0:
					done = 0
		if done:
			print('YES')
			for i in vis:
				print(*i)
		else:
			print('NO')
	else:
		print('NO')


from collections import Counter
n = int(input().strip())
entries = list(map(int, input().strip().split()))
if n == 1:
	print('Yes')
	print(entries[0])
	exit()
size_4_entries = n // 2 * (n // 2)
size_2_entries = 2 * (n // 2) * (n % 2)
size_1_entries = n % 2
counts = Counter(entries)
size_1 = []
size_2 = []
size_4 = []
digits = list(counts.keys())
dcounts = list(counts.values())
has_one = size_1_entries
for c in dcounts:
	if c % 2 == 1:
		has_one -= 1
		if has_one < 0:
			print('No')
			exit()
has_two = size_1_entries + size_2_entries
for c in dcounts:
	if c % 4 != 0:
		has_two -= 1
		if has_two < 0:
			print('No')
			exit()

def get_assign(s4, s2, s1, dcounts):
	if s4 == s2 == s1 == 0:
		res = dict()
		res['4'] = []
		res['2'] = []
		res['1'] = []
		yield res
		return
	if s4 != 0:
		for (idx, count) in enumerate(dcounts):
			if count >= 4:
				dcounts[idx] -= 4
				for sol in get_assign(s4 - 1, s2, s1, dcounts):
					if sol is not None:
						sol['4'].append(digits[idx])
						yield sol
				dcounts[idx] += 4
	if s2 != 0:
		for (idx, count) in enumerate(dcounts):
			if count >= 2:
				dcounts[idx] -= 2
				for sol in get_assign(s4, s2 - 1, s1, dcounts):
					if sol is not None:
						sol['2'].append(digits[idx])
						yield sol
				dcounts[idx] += 2
	if s1 != 0:
		for (idx, count) in enumerate(dcounts):
			if count >= 1:
				dcounts[idx] -= 1
				for sol in get_assign(s4, s2, s1 - 1, dcounts):
					if sol is not None:
						sol['1'].append(digits[idx])
						yield sol
				dcounts[idx] += 1
	yield None
for res in get_assign(size_4_entries, size_2_entries, size_1_entries, dcounts):
	break
if res is None:
	print('No')
	exit()
else:
	size_4 = res['4']
	size_2 = res['2']
	size_1 = res['1']
print('Yes')
low = n // 2
if n % 2 == 0:
	high = n // 2
else:
	high = n // 2 + 1
for i in range(n):
	row = []
	for j in range(n):
		if i < low and j < low:
			row.append(size_4[j + n // 2 * i])
		elif i < low and j >= high:
			row.append(size_4[n - 1 - j + n // 2 * i])
		elif i >= high and j < low:
			row.append(size_4[j + n // 2 * (n - 1 - i)])
		elif i >= high and j >= high:
			row.append(size_4[n - 1 - j + n // 2 * (n - 1 - i)])
		elif n % 2 == 1 and i == n // 2:
			if j < low:
				row.append(size_2[j])
			elif j == n // 2:
				row.append(size_1[0])
			else:
				row.append(size_2[n - 1 - j])
		elif n % 2 == 1 and j == n // 2:
			if i < low:
				row.append(size_2[n // 2 + i])
			else:
				row.append(size_2[n - 1 - (n // 2 + i)])
	print(' '.join(map(str, row)))


import sys
import math
from collections import defaultdict

def do():
	print('NO')
	sys.exit()
n = int(sys.stdin.readline())
nums = list(map(int, sys.stdin.readline().split()))
dic = defaultdict(int)
if n == 1:
	print('YES')
	print(nums[0])
	sys.exit()
m = n * n
for i in range(m):
	dic[nums[i]] += 1
(count2, count0) = (0, 0)
ans = [[-1 for _ in range(n)] for x in range(n)]
(four, two, one) = ([], [], [])
for i in dic:
	if dic[i] % 4 == 0:
		for j in range(dic[i]):
			four.append(i)
		continue
	if dic[i] % 2 == 0:
		two.append(i)
		two.append(i)
		dic[i] -= 2
		if dic[i] >= 4:
			for j in range(dic[i]):
				four.append(i)
		continue
	if dic[i] % 2 == 1:
		one.append(i)
		dic[i] -= 1
		if dic[i] % 2 == 0 and dic[i] % 4 != 0:
			two.append(i)
			two.append(i)
			dic[i] -= 2
		if dic[i] >= 4:
			for j in range(dic[i]):
				four.append(i)
		continue
	print(dic, 'dic')
	print('NO')
	sys.exit()
four.sort()
one.sort()
two.sort()
(o, t, f) = (len(one), len(two), len(four))
if n % 2 != 0:
	(ind1, ind2, ind4) = (0, 0, 0)
	for i in range(n // 2):
		for j in range(n // 2):
			if ind4 >= f:
				do()
			ans[i][j] = four[ind4]
			ind4 += 1
			if ind4 >= f:
				do()
			ans[i][n - 1 - j] = four[ind4]
			ind4 += 1
			if ind4 >= f:
				do()
			ans[n - i - 1][j] = four[ind4]
			ind4 += 1
			if ind4 >= f:
				do()
			ans[n - i - 1][n - 1 - j] = four[ind4]
			ind4 += 1
	for x in range(ind4, f):
		two.append(four[x])
	t = len(two)
	for i in range(n // 2):
		if ind2 >= t:
			do()
		ans[i][n // 2] = two[ind2]
		ind2 += 1
		if ind2 >= t:
			do()
		ans[n - i - 1][n // 2] = two[ind2]
		ind2 += 1
	for i in range(n // 2):
		if ind2 >= t:
			do()
		ans[n // 2][i] = two[ind2]
		ind2 += 1
		if ind2 >= t:
			do()
		ans[n // 2][n - i - 1] = two[ind2]
		ind2 += 1
	if ind1 >= o:
		do()
	ans[n // 2][n // 2] = one[ind1]
	print('YES')
	for i in range(n):
		print(*ans[i])
else:
	if o > 0 or t > 0:
		do()
	ind4 = 0
	for i in range(n // 2):
		for j in range(n // 2):
			if ind4 >= f:
				do()
			ans[i][j] = four[ind4]
			ind4 += 1
			if ind4 >= f:
				do()
			ans[i][n - 1 - j] = four[ind4]
			ind4 += 1
			if ind4 >= f:
				do()
			ans[n - i - 1][j] = four[ind4]
			ind4 += 1
			if ind4 >= f:
				do()
			ans[n - i - 1][n - 1 - j] = four[ind4]
			ind4 += 1
	print('YES')
	for i in range(n):
		print(*ans[i])


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
from itertools import permutations
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
a = list(map(int, input().split()))
d = dict()
for i in a:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
four = list()
two = list()
one = list()
for i in d:
	c = d[i]
	for j in range(c // 4):
		four.append(i)
	c %= 4
	for j in range(c // 2):
		two.append(i)
	c %= 2
	if c > 0:
		one.append(i)
if n % 2 == 0:
	if len(four) != n // 2 * (n // 2):
		print('NO')
	else:
		print('YES')
		r = [[0 for i in range(n)] for j in range(n)]
		k = 0
		for i in range(n // 2):
			for j in range(n // 2):
				r[i][j] = four[k]
				r[i][n - 1 - j] = four[k]
				r[n - 1 - i][j] = four[k]
				r[n - 1 - i][n - 1 - j] = four[k]
				k += 1
		for i in range(n):
			print(*r[i])
elif len(one) > 1 or len(two) > n // 2 * 2:
	print('NO')
else:
	print('YES')
	r = [[0 for i in range(n)] for j in range(n)]
	k = 0
	for i in range(n // 2):
		for j in range(n // 2):
			r[i][j] = four[k]
			r[i][n - 1 - j] = four[k]
			r[n - 1 - i][j] = four[k]
			r[n - 1 - i][n - 1 - j] = four[k]
			k += 1
	while k < len(four):
		two.append(four[k])
		two.append(four[k])
		k += 1
	r[n // 2][n // 2] = one[0]
	k = 0
	for i in range(n // 2):
		r[i][n // 2] = two[k]
		r[n - 1 - i][n // 2] = two[k]
		k += 1
	for j in range(n // 2):
		r[n // 2][j] = two[k]
		r[n // 2][n - 1 - j] = two[k]
		k += 1
	for i in range(n):
		print(*r[i])


def print_mat(m):
	n = len(m)
	for i in range(n):
		print(' '.join([str(j) for j in m[i]]))

def mat_unity4(b):
	global n
	(b1, b2, b3, b4) = (b, tr_mat(b, 2), tr_mat(b, 3), tr_mat(b, 4))
	r = [['' for i in range(n)] for j in range(n)]
	for i in range(n // 2):
		for j in range(n):
			if j < n // 2:
				r[i][j] = b1[i][j]
			else:
				r[i][j] = b2[i][j % (n // 2)]
	for i in range(n // 2):
		for j in range(n):
			if j < n // 2:
				r[i + n // 2][j] = b4[i][j]
			else:
				r[i + n // 2][j] = b3[i][j % (n // 2)]
	return r

def mat_unity9(b, m, c):
	global n
	(b1, b2, b3, b4) = (b, tr_mat(b, 2), tr_mat(b, 3), tr_mat(b, 4))
	(b5, b6, b7, b8) = (m[0], m[1], m[0][::-1], m[1][::-1])
	b9 = c
	r = [['' for i in range(n)] for j in range(n)]
	for i in range(n // 2):
		for j in range(n):
			if j < n // 2:
				r[i][j] = b1[i][j]
			elif j == n // 2:
				r[i][j] = b5[i]
			else:
				r[i][j] = b2[i][j % (n // 2 + 1)]
	for j in range(n):
		if j < n // 2:
			r[n // 2][j] = b8[j]
		elif j == n // 2:
			r[n // 2][j] = b9
		else:
			r[n // 2][j] = b6[j % (n // 2 + 1)]
	for i in range(n // 2):
		for j in range(n):
			if j < n // 2:
				r[i + n // 2 + 1][j] = b4[i][j]
			elif j == n // 2:
				r[i + n // 2 + 1][j] = b7[i]
			else:
				r[i + n // 2 + 1][j] = b3[i][j % (n // 2 + 1)]
	return r

def tr_mat(m, t):
	n = len(m)
	if n == 1:
		return m
	r = [['' for i in range(n)] for j in range(n)]
	if t == 2:
		for i in range(n):
			for j in range(n):
				r[i][j] = m[i][n - j - 1]
	elif t == 4:
		for j in range(n):
			for i in range(n):
				r[i][j] = m[n - i - 1][j]
	else:
		r = tr_mat(tr_mat(m, 2), 4)
	return r

def test(m):
	for i in range(2, 5):
		if m != tr_mat(m, i):
			return False
	return True
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
d = Counter(a)
if n % 2 == 0:
	i = 0
	c = list(d.keys())
	while i < len(d) and d[c[i]] % 4 == 0:
		i += 1
	else:
		if i < len(d):
			print('NO')
		else:
			print('YES')
			b = [['' for i in range(n // 2)] for j in range(n // 2)]
			sc = 0
			for i in c:
				d[i] //= 4
				for j in range(d[i]):
					b[sc // (n // 2)][sc % (n // 2)] = i
					sc += 1
			print_mat(mat_unity4(b))
else:
	c = list(d.keys())
	(k1, k2, k4) = ([], [], [])
	b = 0
	for i in range(len(c)):
		it = d[c[i]]
		if it % 4 == 1:
			k1.append(c[i])
		elif it % 4 == 2:
			k2.append(c[i])
		elif it % 4 == 3:
			k2.append(c[i])
			k1.append(c[i])
		for j in range(it // 4):
			k4.append(c[i])
	s = len(k4) - (n // 2) ** 2
	for i in range(s):
		k2.append(k4[0])
		k2.append(k4[0])
		del k4[0]
	if len(k1) != 1 or len(k2) != 2 * (n // 2) or len(k4) != (n // 2) ** 2:
		print('NO')
	else:
		print('YES')
		b1 = [['' for i in range(n // 2)] for j in range(n // 2)]
		b2 = [['' for i in range(n // 2)] for j in range(2)]
		b3 = k1[0]
		sc = 0
		for i in k4:
			b1[sc // (n // 2)][sc % (n // 2)] = i
			sc += 1
		sc = 0
		for i in k2:
			b2[sc // (n // 2)][sc % (n // 2)] = i
			sc += 1
		print_mat(mat_unity9(b1, b2, b3))


n = int(input())
a = list(map(int, input().split()))
ans = [[-1] * n for i in range(n)]
dp = [0] * 1001
for i in a:
	dp[i] += 1
flag = 1
ire = []
ni = []
for i in range(1001):
	if dp[i]:
		if dp[i] % 4 == 0:
			dp[i] //= 4
			for j in range(dp[i]):
				ire.append(i)
		elif dp[i] % 4 == 1 and flag and (n % 2 == 1):
			flag = 0
			ans[n // 2][n // 2] = i
			dp[i] //= 4
			for j in range(dp[i]):
				ire.append(i)
		elif dp[i] % 4 == 2 and n % 2 == 1:
			ni.append(i)
			dp[i] //= 4
			for j in range(dp[i]):
				ire.append(i)
		elif dp[i] % 4 == 3 and flag and (n % 2 == 1):
			flag = 0
			ans[n // 2][n // 2] = i
			ni.append(i)
			dp[i] //= 4
			for j in range(dp[i]):
				ire.append(i)
		else:
			print('NO')
			exit()
if len(ni) > n - 1:
	print('NO')
	exit()
print('YES')
if n % 2 == 0:
	for i in range(n // 2):
		for j in range(n // 2):
			b = ire.pop()
			ans[i][j] = ans[n - i - 1][j] = ans[i][n - j - 1] = ans[n - i - 1][n - j - 1] = b
else:
	for i in range(n // 2):
		for j in range(n // 2):
			b = ire.pop()
			ans[i][j] = ans[n - i - 1][j] = ans[i][n - j - 1] = ans[n - i - 1][n - j - 1] = b
	while ire:
		b = ire.pop()
		ni.append(b)
		ni.append(b)
	for i in range(n // 2):
		b = ni.pop()
		ans[i][n // 2] = ans[n - 1 - i][n // 2] = b
	for i in range(n // 2):
		b = ni.pop()
		ans[n // 2][i] = ans[n // 2][n - 1 - i] = b
for i in ans:
	print(*i)


def is_palindromic(lst, n):
	len_set = len(set(lst))
	set_ = set(lst)
	if n % 2 == 0:
		a = n * n / 4
	else:
		a = (n + 1) * (n + 1) / 4
	if len_set > a:
		print('NO')
		return
	if len(lst) != n * n:
		print('no')
		return
	dict_ = {}
	for i in lst:
		if i not in dict_:
			dict_[i] = 1
		else:
			dict_[i] += 1
	if n == 1:
		print('YES')
		matrix = print_matrix(dict_, n)
		return matrix
	elif n == 2:
		print('YES')
		for i in range(n):
			matrix = print_matrix(dict_, n)
			return matrix
	elif n % 2 == 0 and n != 2:
		for (key, value) in enumerate(dict_.items()):
			if value[1] % 4 != 0:
				print('NO')
				return
		else:
			print('yes')
			matrix = print_matrix(dict_, n)
			return matrix
	elif n % 2 != 0:
		ksi = n - 1
		psi = 0
		for (key, value) in enumerate(dict_.items()):
			if value[1] % 4 != 0 and value[1] % 2 == 0:
				psi += 1
		if psi > ksi:
			print('NO')
			return
		else:
			odd = 0
			two = 0
			for (key, value) in enumerate(dict_.items()):
				if value[1] % 2 != 0:
					odd += 1
					if odd > 1:
						print('NO')
						return
				elif value[1] == 2:
					two += 1
					if two > n - 1:
						print('no')
						return
			else:
				print('yes')
				matrix = print_matrix(dict_, n)
				return matrix

def print_matrix(dict_, n):
	Matrix = [[0 for x in range(n)] for y in range(n)]
	lst_2 = []
	lst_2_2 = []
	lst_2_2_2 = []
	lst_4 = []
	odd_num = 0
	pairs_without_quarters = 0
	for (key, value) in enumerate(dict_.items()):
		if value[1] % 2 == 0 and value[1] % 4 != 0:
			lst_2.append(value[0])
			pairs_without_quarters += 1
		elif value[1] % 4 == 0:
			lst_4.append(value[0])
		else:
			odd_num += value[0]
	if n % 2 != 0:
		odd_num_num = dict_[odd_num]
		if odd_num != 0:
			Matrix[n // 2][n // 2] = odd_num
			dict_[odd_num] -= 1
		if dict_[odd_num] == 0:
			odd_num = 0
		elif dict_[odd_num] % 4 != 0:
			Matrix[n // 2][n // 2 - 1] = odd_num
			Matrix[n // 2][n // 2 + 1] = odd_num
			if dict_[odd_num] == 2:
				odd_num = 0
			else:
				dict_[odd_num] -= 2
		if len(lst_2) != 0:
			if len(lst_2) >= n // 2:
				for i in range(n // 2):
					Matrix[i][n // 2] = lst_2[i]
					Matrix[n - 1 - i][n // 2] = lst_2[i]
					dict_[lst_2[i]] -= 2
					if dict_[lst_2[i]] == 0:
						lst_2[i] = 0
			else:
				for i in range(len(lst_2)):
					Matrix[i][n // 2] = lst_2[i]
					Matrix[n - 1 - i][n // 2] = lst_2[i]
					dict_[lst_2[i]] -= 2
			for item in lst_2:
				if item > 0 and dict_[item] % 4 == 0:
					lst_4.append(item)
				elif item > 0:
					lst_2_2.append(item)
		if len(lst_2_2) != 0:
			if len(lst_2_2) >= n // 2:
				for j in range(n // 2):
					Matrix[n // 2][j] = lst_2_2[j]
					Matrix[n // 2][n - 1 - j] = lst_2_2[j]
					dict_[lst_2_2[j]] -= 2
					if dict_[lst_2_2[j]] == 0:
						lst_2_2[j] = 0
			else:
				for j in range(len(lst_2_2)):
					Matrix[n // 2][j] = lst_2_2[j]
					Matrix[n // 2][n - 1 - j] = lst_2_2[j]
					dict_[lst_2_2[j]] -= 2
			for item in lst_2_2:
				if item > 0 and dict_[item] % 4 == 0:
					lst_4.append(item)
				elif item > 0:
					lst_2_2_2.append(item)
	for i in range(n):
		if len(lst_4) == 0 and odd_num == 0:
			break
		for j in range(n // 2 + 1):
			if len(lst_4) == 0 and odd_num == 0:
				break
			if Matrix[i][j] == 0 and len(lst_4) != 0 and (n % 2 == 0):
				z = dict_[lst_4[0]] // 4
				ii = i
				jj = j
				while z:
					if Matrix[i][j] == 0:
						Matrix[i][j] = lst_4[0]
						Matrix[i][n - j - 1] = lst_4[0]
						Matrix[n - i - 1][j] = lst_4[0]
						Matrix[n - i - 1][n - j - 1] = lst_4[0]
						z -= 1
					if j == (n - 1) // 2:
						i += 1
						j = 0
					else:
						j += 1
				del lst_4[0]
				i = ii
				j = jj
			elif Matrix[i][j] == 0 and len(lst_4) != 0:
				b = dict_[lst_4[0]]
				z = b // 4
				ii = i
				jj = j
				while z:
					if Matrix[i][j] == 0 and i != (n - 1) // 2 and (j != (n - 1) // 2):
						Matrix[i][j] = lst_4[0]
						Matrix[i][n - 1 - j] = lst_4[0]
						Matrix[n - i - 1][j] = lst_4[0]
						Matrix[n - i - 1][n - 1 - j] = lst_4[0]
						z -= 1
					elif Matrix[i][j] == 0 and j == (n - 1) // 2 and (i != (n - 1) // 2 - 1):
						Matrix[i][j] = lst_4[0]
						Matrix[i + 1][j] = lst_4[0]
						Matrix[n - i - 1][j] = lst_4[0]
						Matrix[n - i - 2][j] = lst_4[0]
						z -= 1
					elif Matrix[i][j] == 0 and i == (n - 1) // 2:
						Matrix[i][j] = lst_4[0]
						Matrix[i][n - j - 1] = lst_4[0]
						if j + 1 != n - j - 2:
							Matrix[i][j + 1] = lst_4[0]
							Matrix[i][n - j - 2] = lst_4[0]
							j += 1
						else:
							Matrix[i - 1][n // 2] = lst_4[0]
							Matrix[i + 1][n // 2] = lst_4[0]
						z -= 1
					if j == (n - 1) // 2:
						i += 1
						j = 0
					else:
						j += 1
				i = ii
				j = jj
				del lst_4[0]
			elif Matrix[i][j] == 0 and odd_num != 0:
				b = dict_[odd_num]
				k = 0
				i = 0
				j = 0
				while b:
					if Matrix[i][j] == 0:
						Matrix[i][j] = odd_num
						b -= 1
					if j == n - 1:
						i += 1
						j = 0
					else:
						j += 1
				odd_num = 0
	for rows in Matrix:
		rows = str(rows).replace(', ', ' ')
		rows = rows.strip(']')
		rows = rows.strip('[')
		print(rows)
n = int(input())
lst = list(map(int, input().split()))
is_palindromic(lst, n)


n = int(input())
count = [0] * 1000
numbers = list(map(int, input().split()))
for i in numbers:
	count[i - 1] += 1
possible = True
middleFoundOrEven = n % 2 == 0
middle = -1
countFour = 0
four = []
countEight = 0
eight = []
for i in range(len(count)):
	if count[i] != 0 and count[i] % 2 == 0:
		count[i] //= 2
		countEight += count[i] // 2
		eight += [i + 1] * (count[i] // 2)
		countFour += count[i] % 2
		four += [i + 1] * (count[i] % 2)
	elif not middleFoundOrEven and count[i] % 2:
		middleFoundOrEven = True
		middle = i + 1
		count[i] //= 2
		countEight += count[i] // 2
		eight += [i + 1] * (count[i] // 2)
		countFour = count[i] % 2
		four += [i + 1] * (count[i] % 2)
	elif count[i] != 0:
		possible = False
		break
if not middleFoundOrEven:
	possible = False
if possible and n % 2 == 0:
	minEight = n * n / 4
	if countEight < minEight:
		possible = False
elif possible and n % 2 == 1:
	minEight = (n ** 2 - 2 * n - 1) / 4
	if countEight < minEight:
		possible = False
if possible:
	print('YES')
	matrix = [[0] * n for i in range(n)]
	ind = 0
	for i in range(n ** 2):
		x = i // n
		y = i % n
		if matrix[x][y] == 0 and (n % 2 == 0 or (x != n // 2 and y != n // 2)):
			matrix[x][y] = eight[ind]
			matrix[n - x - 1][y] = eight[ind]
			matrix[x][n - y - 1] = eight[ind]
			matrix[n - x - 1][n - y - 1] = eight[ind]
			eight.pop(ind)
	four += 2 * eight
	even = n % 2 == 0
	ind = 0
	for i in range(n ** 2):
		x = i // n
		y = i % n
		if matrix[x][y] == 0:
			if x == y and even or (not even and x != n // 2) or y != n // 2:
				matrix[x][y] = four[ind]
				matrix[n - x - 1][y] = four[ind]
				matrix[x][n - y - 1] = four[ind]
				matrix[n - x - 1][n - y - 1] = four[ind]
				four.pop(ind)
	if not even:
		matrix[n // 2][n // 2] = middle
	for i in range(n):
		for j in range(n):
			print(matrix[i][j], end=' ')
		print('')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
e = dict()
for i in range(n ** 2):
	if a[i] in e:
		e[a[i]] += 1
	else:
		e[a[i]] = 1
m = [[0] * n for _ in range(n)]
if n % 2 == 0:
	if set(map(lambda n: n % 4, e.values())) != {0}:
		print('NO')
	else:
		for y in range(n // 2):
			for x in range(n // 2):
				z = list(e.keys())[0]
				(m[y][x], m[n - y - 1][x], m[y][n - x - 1], m[n - y - 1][n - x - 1]) = (z, z, z, z)
				e[z] -= 4
				if not e[z]:
					del e[z]
		print('YES', *map(lambda l: ' '.join(map(str, l)), m), sep='\n')
elif list(map(lambda i: i % 2, e.values())).count(1) != 1:
	print('NO')
else:
	for z in set(a):
		if a.count(z) % 2 == 1:
			e[z] -= 1
			if not e[z]:
				del e[z]
			m[n // 2][n // 2] = z
			break
	x = 0
	y = 0
	while 2 in map(lambda i: i % 4, e.values()) and x < n // 2:
		for z in set(e.keys()):
			if e[z] % 4 == 2:
				(m[n // 2][x], m[n // 2][n - x - 1]) = (z, z)
				e[z] -= 2
				if not e[z]:
					del e[z]
				break
		x += 1
	while 2 in map(lambda i: i % 4, e.values()) and y < n // 2:
		for z in set(e.keys()):
			if e[z] % 4 == 2:
				(m[y][n // 2], m[n - y - 1][n // 2]) = (z, z)
				e[z] -= 2
				if not e[z]:
					del e[z]
				break
		y += 1
	if x < n // 2 or y < n // 2:
		while x < n // 2:
			z = list(e.keys())[0]
			(m[n // 2][x], m[n // 2][n - x - 1]) = (z, z)
			e[z] -= 2
			if not e[z]:
				del e[z]
			x += 1
		while y < n // 2:
			z = list(e.keys())[0]
			(m[y][n // 2], m[n - y - 1][n // 2]) = (z, z)
			e[z] -= 2
			if not e[z]:
				del e[z]
			y += 1
	if 2 in map(lambda i: i % 4, e.values()):
		print('NO')
	else:
		for y in range(n // 2):
			for x in range(n // 2):
				z = list(e.keys())[0]
				(m[y][x], m[n - y - 1][x], m[y][n - x - 1], m[n - y - 1][n - x - 1]) = (z, z, z, z)
				e[z] -= 4
				if not e[z]:
					del e[z]
		print('YES', *map(lambda l: ' '.join(map(str, l)), m), sep='\n')


n = int(input())
arr = list(map(int, input().split()))
field = []
for i in range(n):
	field.append([-1] * n)
count = [0] * (max(arr) + 1)
for i in range(int(n ** 2)):
	count[arr[i]] += 1
x = 0
y = 0
i = 0
while i < len(count):
	fl = False
	while count[i] >= 4:
		count[i] -= 4
		field[y][x] = i
		field[n - y - 1][x] = i
		field[y][n - x - 1] = i
		field[n - y - 1][n - x - 1] = i
		x += 1
		y += x // (n // 2)
		x %= n // 2
		if y == n // 2:
			fl = True
			break
	if fl:
		break
	i += 1
if n % 2:
	x = n // 2
	y = 0
	i = 0
	while i < len(count):
		fl = False
		while count[i] >= 2:
			count[i] -= 2
			field[y][x] = i
			field[n - y - 1][x] = i
			y += 1
			if y == n // 2:
				fl = True
				break
		if fl:
			break
		i += 1
	x = 0
	y = n // 2
	i = 0
	while i < len(count):
		fl = False
		while count[i] >= 2:
			count[i] -= 2
			field[y][x] = i
			field[y][n - x - 1] = i
			x += 1
			if x == n // 2:
				fl = True
				break
		if fl:
			break
		i += 1
	for i in range(len(count)):
		if count[i] == 1:
			field[n // 2][n // 2] = i
fl = False
for i in range(n):
	for g in range(n):
		if field[i][g] == -1:
			fl = True
if fl:
	print('NO')
else:
	print('YES')
	for i in range(n):
		print(*field[i])


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
if n == 1:
	print('YES')
	print(a[0])
else:
	d = {}
	d = defaultdict(lambda : 0, d)
	for i in a:
		d[i] += 1
	arr = []
	for i in d.keys():
		arr.append([d[i], i])
	arr = sorted(arr, reverse=True)
	arr1 = []
	x11 = n // 2
	matrix = [[0 for i in range(n)] for j in range(n)]
	for i in arr:
		x = i[0] // 4
		flag = 0
		if x >= 1:
			for j in range(n // 2):
				for k in range(n // 2):
					if matrix[j][k] == 0:
						matrix[j][k] = i[1]
						matrix[n - j - 1][k] = i[1]
						matrix[j][n - k - 1] = i[1]
						matrix[n - j - 1][n - k - 1] = i[1]
						x -= 1
					if x == 0:
						break
				if x == 0:
					break
		y = i[0] % 4
		if y + x * 4 > 0:
			arr1.append([y + x * 4, i[1]])
	if len(arr1) == 0:
		print('YES')
		for i in range(n):
			for j in range(n):
				print(matrix[i][j], end=' ')
			print()
	elif n % 2 == 0:
		print('NO')
	elif matrix[n // 2 - 1][n // 2 - 1] == 0:
		print('NO')
	else:
		arr1 = sorted(arr1, reverse=True)
		flag = 0
		start = -1
		k = 0
		ex = -1
		for i in arr1:
			if i[0] % 2 != 0 and flag == 0:
				flag = 1
				if i[0] == 1:
					start = i[1]
					ex = k
				else:
					start = i[1]
					i[0] -= 1
			elif i[0] % 2 != 0 and flag == 1:
				flag = 2
				break
			k += 1
		if ex != -1:
			arr.pop(ex)
		if flag == 2 or len(arr1) == 0:
			print('NO')
		else:
			arr1 = sorted(arr1, reverse=True)
			i = 0
			k = 0
			while i < n // 2 and len(arr1) > 0:
				matrix[i][n // 2] = arr1[k][1]
				matrix[n - i - 1][n // 2] = arr1[k][1]
				arr1[k][0] -= 2
				if arr1[k][0] <= 0:
					k += 1
				i += 1
			i = 0
			while i < n // 2 and len(arr1) > 0:
				matrix[n // 2][i] = arr1[k][1]
				matrix[n // 2][n - i - 1] = arr1[k][1]
				arr1[k][0] -= 2
				if arr1[k][0] <= 0:
					k += 1
				i += 1
			if i != n // 2:
				print('NO')
			else:
				matrix[n // 2][n // 2] = start
				print('YES')
				for i in range(n):
					for j in range(n):
						print(matrix[i][j], end=' ')
					print()


from collections import Counter
from heapq import heappush, heappop
N = int(input())
counter = Counter(map(int, input().split()))
heap = sorted([(-cnt, n) for (n, cnt) in counter.items()])
matrix = [[0] * N for _ in [0] * N]

def no():
	print('NO')
	exit()
if N % 2 == 1:
	need_4 = (N ** 2 - (N - 1) * 2 - 1) // 4
else:
	need_4 = N ** 2 // 4
(y, x) = (0, 0)
for _ in [0] * need_4:
	(count, n) = heappop(heap)
	if count > -4:
		no()
	heappush(heap, (count + 4, n))
	matrix[y][x] = matrix[N - y - 1][x] = matrix[y][N - x - 1] = matrix[N - y - 1][N - x - 1] = n
	x += 1
	if x >= N // 2:
		y += 1
		x = 0
if N % 2 == 1:
	(y, x) = (0, N // 2)
	for _ in [0] * (N // 2):
		(count, n) = heappop(heap)
		if count > -2:
			no()
		heappush(heap, (count + 2, n))
		matrix[y][x] = matrix[N - y - 1][x] = n
		y += 1
	(y, x) = (N // 2, 0)
	for _ in [0] * (N // 2):
		(count, n) = heappop(heap)
		if count > -2:
			no()
		heappush(heap, (count + 2, n))
		matrix[y][x] = matrix[y][N - x - 1] = n
		x += 1
	matrix[N // 2][N // 2] = heappop(heap)[1]
print('YES')
for row in matrix:
	print(*row)


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, sin, cos, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(1000000000)
INF = float('inf')
(YES, Yes, yes, NO, No, no) = ('YES', 'Yes', 'yes', 'NO', 'No', 'no')
(dy4, dx4) = ([0, 1, 0, -1], [1, 0, -1, 0])
(dy8, dx8) = ([0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1])

def inside(y, x, H, W):
	return 0 <= y < H and 0 <= x < W

def ceil(a, b):
	return (a + b - 1) // b

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	g = gcd(a, b)
	return a / g * b

def euclidean_distance(y1, x1, y2, x2):
	return sqrt((y1 - y2) ** 2 + (x1 - x2) ** 2)

def manhattan_distance(y1, x1, y2, x2):
	return abs(y1 - y2) + abs(x1 - x2)

def main():
	N = int(input())
	D = list(map(int, input().split()))
	(f, t, o) = ([], [], [])
	C = Counter(D)
	for (k, v) in C.items():
		while v >= 4:
			v -= 4
			f.append(k)
		while v >= 2:
			v -= 2
			t.append(k)
		if v:
			o.append(k)
	ans = [[0] * N for _ in range(N)]
	if N % 2 == 0:
		if len(t) > 0 or len(o) > 0:
			print(NO)
			return
		i = 0
		for y in range(N // 2):
			for x in range(N // 2):
				ans[y][x] = ans[-y - 1][x] = ans[y][-x - 1] = ans[-y - 1][-x - 1] = f[i]
				i += 1
	else:
		if len(f) < N // 2 * (N // 2) or len(o) != 1:
			print(NO)
			return
		i = 0
		for y in range(N // 2):
			for x in range(N // 2):
				ans[y][x] = ans[-y - 1][x] = ans[y][-x - 1] = ans[-y - 1][-x - 1] = f[i]
				i += 1
		while i < len(f):
			t.append(f[i])
			t.append(f[i])
			i += 1
		i = 0
		for k in range(N // 2):
			ans[N // 2][k] = ans[N // 2][-k - 1] = t[i]
			i += 1
		for k in range(N // 2):
			ans[k][N // 2] = ans[-k - 1][N // 2] = t[i]
			i += 1
		ans[N // 2][N // 2] = o[0]
	print(YES)
	for line in ans:
		print(*line, sep=' ')
main()


n = int(input())
a = list(map(int, input().split()))
c = [0] * 1001
for i in range(len(a)):
	c[a[i]] += 1
sym = 0
sin = 0
for i in range(1001):
	sym += c[i] // 4
	if c[i] % 2 == 1:
		sin += 1
if n % 2 == 0 and sym == n * n // 4:
	mat = [[0] * (n // 2) for i in range(n // 2)]
	ar = []
	for i in range(1001):
		while c[i] >= 4:
			ar.append(i)
			c[i] -= 4
	k = 0
	for i in range(n // 2):
		for j in range(n // 2):
			mat[i][j] = ar[k]
			k += 1
	newm = [[0] * n for i in range(n)]
	for i in range(n // 2):
		for j in range(n // 2):
			newm[i][j] = mat[i][j]
			newm[n - i - 1][j] = mat[i][j]
			newm[n - i - 1][n - j - 1] = mat[i][j]
			newm[i][n - j - 1] = mat[i][j]
	print('YES')
	for i in range(n):
		for j in range(n):
			print(newm[i][j], end=' ')
		print()
elif n % 2 == 1 and (sym >= n // 2 * (n // 2) and sin == 1):
	mat = [[0] * (n // 2) for i in range(n // 2)]
	ar = []
	for i in range(1001):
		while c[i] >= 4:
			ar.append(i)
			c[i] -= 4
	k = 0
	for i in range(n // 2):
		for j in range(n // 2):
			mat[i][j] = ar[k]
			ar.pop(k)
	newm = [[0] * n for i in range(n)]
	for i in range(n // 2):
		for j in range(n // 2):
			newm[i][j] = mat[i][j]
			newm[n - i - 1][j] = mat[i][j]
			newm[n - i - 1][n - j - 1] = mat[i][j]
			newm[i][n - j - 1] = mat[i][j]
	na = len(ar)
	ar2 = []
	for i in range(na):
		ar2.append(ar[i])
		ar2.append(ar[i])
	for i in range(1001):
		while c[i] >= 2:
			ar2.append(i)
			c[i] -= 2
	for i in range(n // 2):
		newm[n // 2][i] = ar2[0]
		newm[n // 2][n - i - 1] = ar2[0]
		ar2.pop(0)
		newm[i][n // 2] = ar2[0]
		newm[n - i - 1][n // 2] = ar2[0]
		ar2.pop(0)
	for i in range(1001):
		if c[i] == 1:
			newm[n // 2][n // 2] = i
	print('YES')
	for i in range(n):
		for j in range(n):
			print(newm[i][j], end=' ')
		print()
else:
	print('NO')


n = int(input())
a = map(int, input().split())
d = {}
for v in a:
	d[v] = d.get(v, 0) + 1
q = []
e = []
o = []
for v in d:
	k = d[v]
	if k % 2:
		o.append(v)
	k //= 2
	if k % 2:
		e.append(v)
	for _ in range(k // 2):
		q.append(v)
lq = n // 2 * (n // 2)
if len(o) != n % 2:
	print('NO')
elif len(q) < lq:
	print('NO')
else:
	print('YES')
	if n % 2 and len(e) < n - 1:
		e.extend(q[lq:])
		e.extend(q[lq:])
	m = []
	for i in range(n):
		if i < n - 1 - i:
			mi = [0] * n
			for k in range(n):
				if k < n - 1 - k:
					mi[k] = q.pop(0)
				elif k == n - 1 - k:
					mi[k] = e.pop(0)
				else:
					mi[k] = mi[n - 1 - k]
			print(*mi)
			m.append(mi)
		elif i == n - 1 - i:
			mi = [0] * n
			for k in range(n):
				if k < n - 1 - k:
					mi[k] = e.pop(0)
				elif k == n - 1 - k:
					mi[k] = o.pop(0)
				else:
					mi[k] = mi[n - 1 - k]
			print(*mi)
			m.append(mi)
		else:
			print(*m[n - 1 - i])


n = int(input())
lst = list(map(int, input().split()))
d = {}
for (i, x) in enumerate(lst):
	if d.get(x) == None:
		d[x] = 0
	d[x] += 1
a = (n // 2) ** 2
amount = 0
area1 = []
mat = [[0 for i in range(n)] for i in range(n)]
half = n // 2
shablon = [[0 for j in range(half)] for i in range(half)]
for (i, p) in enumerate(d):
	x = d[p]
	if x // 4 + amount < a:
		amount += x // 4
		d[p] = x % 4
		for i in range(x // 4):
			area1.append(p)
	else:
		d[p] = x - (a - amount) * 4
		for i in range(a - amount):
			area1.append(p)
		amount = a
		break
from sys import exit
if amount != a:
	print('NO')
	exit()
for i in range(half):
	for j in range(half):
		item = area1[i * half + j]
		mat[i][j] = item
		mat[i][n - j - 1] = item
		mat[n - i - 1][j] = item
		mat[n - i - 1][n - j - 1] = item
if n % 2 == 0:
	print('YES')
	for i in range(n):
		print(*mat[i])
	exit()
(amount, a) = (0, n - 1)
area2 = []
for (i, p) in enumerate(d):
	x = d[p]
	if x // 2 + amount < a:
		amount += x // 2
		d[p] = x % 2
		for i in range(x // 2):
			area2.append(p)
	else:
		d[p] = x - (a - amount) * 2
		for i in range(a - amount):
			area2.append(p)
		amount = a
		break
if amount != a:
	print('NO')
	exit()
for i in range(half):
	x = area2[i]
	mat[half][i] = x
	mat[half][n - i - 1] = x
q = i + 1
for i in range(half):
	x = area2[q]
	mat[i][half] = x
	mat[n - i - 1][half] = x
	q += 1
(amount, a) = (0, 1)
area3 = 0
for (i, p) in enumerate(d):
	if d[p] == 1:
		amount = 1
		area3 = p
if amount != a:
	print('NO')
	exit()
mat[half][half] = area3
print('YES')
for i in range(n):
	print(*mat[i])


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)

def printv(v, n, stri=[], mid=[]):
	if n % 2 == 0:
		ans = []
		for i in range(n // 2):
			string = []
			for j in range(n // 2):
				string.append(v[i * (n // 2) + j])
			ans.append(string + string[::-1])
		ans = ans + ans[::-1]
		return ans
	else:
		ans = []
		for i in range(n // 2):
			string = []
			for j in range(n // 2):
				string.append(v[i * (n // 2) + j])
			ans.append(string + [stri[i]] + string[::-1])
		middle = stri[n // 2:] + mid + list(reversed(stri[n // 2:]))
		ans = ans + [middle] + ans[::-1]
		return ans

def solve(n, c):
	vals = []
	for key in c:
		if c[key] >= 4:
			vals.extend([key] * (c[key] // 4))
			c[key] = c[key] % 4
	if n % 2 == 1:
		mid = []
		stri = []
		for key in c:
			if c[key] != 0:
				if c[key] >= 2:
					stri.append(key)
					c[key] = c[key] % 2
				if c[key] == 1:
					mid.append(key)
		if len(vals) > (n // 2) ** 2:
			k = 0
			for i in range(len(vals) - (n // 2) ** 2):
				stri.extend([vals[i]] * 2)
				k = i
			vals = vals[k + 1:]
		if len(vals) != (n // 2) ** 2:
			return (0, 1, 0, 0)
		if len(stri) != n - 1:
			return (0, 2, 0, 0)
		if len(mid) > 1:
			return (0, 3, 0, 0)
		return (2, vals, stri, mid)
	elif sum(c.values()) > 0:
		return (0, 0, 0, 0)
	else:
		return (1, vals, 0, 0)
(r, v, s, m) = solve(n, c)
if r > 0:
	print('YES')
	v = printv(v, n, s, m)
	for i in v:
		for j in i:
			print(j, end=' ')
		print()
else:
	print('NO')


from collections import Counter

def solve(n, nums):
	if n == 1:
		return False if len(nums) < 1 else [[nums.pop()]]
	counts = Counter(nums)
	if n % 2 == 0:
		keys = []
		for (num, count) in counts.items():
			if count >= 4 and count % 4 == 0:
				while count > 0:
					keys.append(num)
					count -= 4
			else:
				return False
		matrix = [None for _ in range(n)]
		for r in range(0, n // 2):
			row = [0] * n
			for c in range(0, n // 2):
				key = keys.pop()
				row[c] = key
				row[n - c - 1] = key
			matrix[r] = row
			matrix[n - r - 1] = row
		return matrix
	else:
		num_fours_needed = n // 2 * (n // 2)
		keys = []
		for (key, count) in counts.items():
			while count >= 4 and len(keys) < num_fours_needed:
				keys.append(key)
				count -= 4
			counts[key] = count
			if len(keys) == num_fours_needed:
				break
		if len(keys) != num_fours_needed:
			return False
		count_nums = {1: [], 2: []}
		for (key, count) in counts.items():
			while count >= 4:
				count_nums[2].append(key)
				count -= 2
			while count >= 2:
				count_nums[2].append(key)
				count -= 2
			if count != 0:
				count_nums[count].append(key)
		matrix = [[] for _ in range(n)]
		for r in range(0, n // 2):
			row = [0] * n
			for c in range(0, n // 2):
				key = keys.pop()
				row[c] = key
				row[n - c - 1] = key
			matrix[r] = row
			matrix[n - r - 1] = row
		try:
			row = [0] * n
			matrix[n // 2] = row
			for i in range(0, n // 2):
				key = count_nums[2].pop()
				row[i] = key
				row[n - i - 1] = key
			row[n // 2] = count_nums[1].pop()
			mid_col = n // 2
			for i in range(0, n // 2):
				key = count_nums[2].pop()
				matrix[i][mid_col] = key
				matrix[n - i - 1][mid_col] = key
		except Exception as E:
			return False
		return matrix
n = int(input())
nums = list(map(int, input().split()))
res = solve(n, nums)
if res:
	print('YES')
	for r in res:
		print(*map(str, r))
else:
	print('NO')


from sys import stdin, stdout
import operator

def main():
	n = int(stdin.readline())
	arr = [int(k) for k in stdin.readline().split()]
	freq = [0] * 1001
	for i in range(n * n):
		freq[arr[i]] += 1
	matrix = []
	counter = 0
	for i in range(n):
		lis = []
		for j in range(n):
			lis.append(0)
		matrix.append(lis)
	for i in range((n + 1) // 2):
		for j in range((n + 1) // 2):
			b1 = (i, j)
			b2 = (i, n - j - 1)
			b3 = (n - i - 1, j)
			b4 = (n - i - 1, n - j - 1)
			if b1[1] == b2[1] and b1[0] == b3[0]:
				for k in range(1, 1001):
					if freq[k] == 1:
						matrix[i][j] = k
						break
			elif b1[1] == b2[1] and b1[0] != b3[0]:
				mx = 0
				ind = -1
				filled = 0
				for k in range(1, 1001):
					if freq[k] == 2:
						matrix[i][j] = k
						matrix[n - i - 1][j] = k
						freq[k] -= 2
						filled = 1
						break
					if freq[k] > mx:
						mx = freq[k]
						ind = k
				if filled == 0:
					if mx > 2:
						matrix[i][j] = ind
						matrix[n - i - 1][j] = ind
						freq[ind] -= 2
					else:
						counter = 1
						break
			elif b1[0] == b3[0] and b1[1] != b2[1]:
				mx = 0
				filled = 0
				ind = -1
				for k in range(1, 1001):
					if freq[k] == 2:
						matrix[i][j] = k
						matrix[i][n - j - 1] = k
						freq[k] -= 2
						filled = 1
						break
					if freq[k] > mx:
						mx = freq[k]
						ind = k
				if filled == 0:
					if mx >= 2:
						matrix[i][j] = ind
						matrix[i][n - j - 1] = ind
						freq[ind] -= 2
					else:
						counter = 1
						break
			else:
				filled = 0
				for k in range(1, 1001):
					if freq[k] >= 4:
						el = k
						matrix[i][j] = el
						matrix[i][n - j - 1] = el
						matrix[n - i - 1][j] = el
						matrix[n - i - 1][n - j - 1] = el
						freq[k] -= 4
						filled = 1
						break
				if filled == 0:
					counter = 1
					break
			if counter == 1:
				break
		if counter == 1:
			break
	if counter == 1:
		print('No')
	else:
		print('Yes')
		for i in range(n):
			for j in range(n):
				print(matrix[i][j], end=' ')
			print()
main()


N = int(input())
data = [[0] * N for _ in range(N)]
arr = input()
arr = [int(x) for x in arr.split(' ')]
arr.sort()
freq = {}
for num in arr:
	if num not in freq:
		freq[num] = 1
	else:
		freq[num] += 1
for k in range(25):
	up = k
	down = N - k - 1
	if up > down:
		break
	left_c = k
	right_c = N - k - 1
	while up < down:
		require = 4
		r = [up, down]
		c = [left_c, right_c]
		fill = -1
		for key in freq:
			if freq[key] >= require:
				fill = key
				freq[key] -= require
				break
		if fill == -1:
			print('NO')
			quit()
		for i in r:
			for j in c:
				data[i][j] = fill
		up += 1
		down -= 1
	up = k
	down = N - k - 1
	left = k + 1
	right = N - k - 2
	while left < right:
		require = 4
		r = [up, down]
		c = [left, right]
		fill = -1
		for key in freq:
			if freq[key] >= require:
				fill = key
				freq[key] -= require
				break
		if fill == -1:
			print('NO')
			quit()
		for i in r:
			for j in c:
				data[i][j] = fill
		left += 1
		right -= 1
if N % 2 == 1:
	left = 0
	right = N - 1
	while left < right:
		fill = -1
		c = [left, right]
		r = [(N - 1) // 2]
		require = 2
		for key in freq:
			if freq[key] >= require:
				fill = key
				freq[key] -= require
				break
		if fill == -1:
			print('NO')
			quit()
		for i in r:
			for j in c:
				data[i][j] = fill
		left += 1
		right -= 1
	up = 0
	down = N - 1
	while up < down:
		fill = -1
		r = [up, down]
		c = [(N - 1) // 2]
		require = 2
		for key in freq:
			if freq[key] >= require:
				fill = key
				freq[key] -= require
				break
		if fill == -1:
			print('NO')
			quit()
		for i in r:
			for j in c:
				data[i][j] = fill
		up += 1
		down -= 1
	fill = -1
	require = 1
	for key in freq:
		if freq[key] >= require:
			fill = key
			freq[key] -= require
			break
	if fill == -1:
		print('NO')
		quit()
	data[(N - 1) // 2][(N - 1) // 2] = fill
print('YES')
for i in range(N):
	for j in range(N):
		if j == N - 1:
			print(data[i][j])
		else:
			print(data[i][j], end=' ')


import time
n = int(input())
a = [int(i) for i in input().split()]
start = time.time()
d = {i: 0 for i in set(a)}
for i in a:
	d[i] += 1
q = []
l = []
c = []
ans = 'YES'
for i in d.keys():
	while d[i] >= 4:
		q.append(i)
		d[i] -= 4
	if d[i] >= 2:
		l.append(i)
		d[i] -= 2
	if d[i] >= 1:
		c.append(i)
		d[i] -= 0
if n % 2 == 0 and (len(l) > 0 or len(c) > 0) or (n % 2 == 1 and (len(c) != 1 or len(l) > n - 1)):
	print('NO')
else:
	h = len(q) - 1
	while n % 2 == 1 and len(l) < n - 1:
		l.append(q[h])
		l.append(q[h])
		h -= 1
	m = [[0 for i in range(n)] for j in range(n)]
	now = 0
	nowl = 0
	if n % 2 == 1:
		m[n // 2][n // 2] = c[0]
	for i in range(n // 2):
		for j in range(n // 2):
			m[i][j] = q[now]
			m[i][n - j - 1] = q[now]
			m[n - i - 1][j] = q[now]
			m[n - i - 1][n - j - 1] = q[now]
			now += 1
		if n % 2 == 1:
			m[n // 2][i] = l[nowl]
			m[n // 2][n - i - 1] = l[nowl]
			nowl += 1
			m[i][n // 2] = l[nowl]
			m[n - i - 1][n // 2] = l[nowl]
			nowl += 1
	print('YES')
	for i in range(n):
		for j in range(n):
			print(m[i][j], end=' ')
		print()
finish = time.time()


import os
import sys
from math import *
from collections import *
from heapq import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz/'
M = 1000000007
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
a = array()
C = Counter(a)
have = [(-C[i], i) for i in C]
heapify(have)
ans = [[-1 for i in range(n)] for j in range(n)]
for i in range(n // 2):
	for j in range(n // 2):
		ele = heappop(have)
		heappush(have, (ele[0] + 4, ele[1]))
		ans[i][j] = ele[1]
		ans[n - i - 1][j] = ele[1]
		ans[i][n - j - 1] = ele[1]
		ans[n - i - 1][n - j - 1] = ele[1]
if n % 2:
	r = n // 2
	c = n // 2
	for i in range(n // 2):
		ele = heappop(have)
		heappush(have, (ele[0] + 2, ele[1]))
		ans[r][i] = ele[1]
		ans[r][n - i - 1] = ele[1]
		ele = heappop(have)
		heappush(have, (ele[0] + 2, ele[1]))
		ans[i][c] = ele[1]
		ans[n - i - 1][c] = ele[1]
	ele = heappop(have)
	heappush(have, (ele[0] + 1, ele[1]))
	ans[r][c] = ele[1]
for (c, _) in have:
	if c:
		print('NO')
		exit()
print('YES')
for i in ans:
	print(*i)


from collections import Counter
import math
n = int(input())
a = [int(x) for x in input().split()]

def unfold_matrix(mat, odd=False):
	if not odd:
		for row in mat:
			row += list(reversed(row))
		mat += list(reversed(mat))
	else:
		for row in mat:
			row += list(reversed(row[:-1]))
		mat += list(reversed(mat[:-1]))
freq = Counter(a)
keys = freq.keys()
if n % 2 == 0:
	keys4 = []
	for key in keys:
		while freq[key] >= 4:
			keys4.append(key)
			freq[key] -= 4
		if freq[key] > 0:
			print('No')
			exit()
	size = n // 2
	mat = [keys4[size * i:size * (i + 1)] for i in range(size)]
	unfold_matrix(mat)
else:
	keys4 = []
	keys2 = []
	keys1 = []
	count4 = 0
	count2 = 0
	mx4 = ((n - 1) // 2) ** 2
	mx2 = n - 1
	for key in keys:
		while freq[key] >= 4 and count4 < mx4:
			keys4.append(key)
			freq[key] -= 4
			count4 += 1
		while freq[key] >= 2 and count2 < mx2:
			keys2.append(key)
			freq[key] -= 2
			count2 += 1
		if freq[key] == 1:
			keys1.append(key)
		elif freq[key] > 1:
			print('No')
			exit()
	if len(keys2) != n - 1:
		print('No')
		exit()
	if len(keys1) != 1:
		print('No')
		exit()
	size = n // 2
	mat = [keys4[size * i:size * (i + 1)] + [keys2[i]] for i in range(size)]
	mat += [keys2[size:] + keys1]
	unfold_matrix(mat, True)
print('Yes')
for row in mat:
	for elem in row:
		print(elem, end=' ')
	print()


from collections import Counter
from itertools import product
n = int(input())
A = [int(i) for i in input().split()]
C = list((list(t) for t in Counter(A).items()))
ans = [[0] * n for i in range(n)]
m = n // 2

def no(cur):
	if cur >= len(C):
		print('NO')
		exit()
cur = 0
for i in range(m):
	for j in range(m):
		while C[cur][1] < 4:
			cur += 1
			no(cur)
		C[cur][1] -= 4
		for (k, l) in product((i, n - i - 1), (j, n - j - 1)):
			ans[k][l] = C[cur][0]
if n % 2 == 1:
	for (k, v) in C:
		if v % 2 == 1:
			ans[m][m] = k
	cur = 0
	for i in range(m):
		while C[cur][1] < 2:
			cur += 1
			no(cur)
		C[cur][1] -= 2
		ans[i][m] = C[cur][0]
		ans[n - i - 1][m] = C[cur][0]
		while C[cur][1] < 2:
			cur += 1
			no(cur)
		C[cur][1] -= 2
		ans[m][i] = C[cur][0]
		ans[m][n - i - 1] = C[cur][0]
print('YES')
for a in ans:
	print(*a)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	n = int(inp())
	a = lis()
	cnt = {}
	for i in range(n * n):
		if a[i] not in cnt:
			cnt[a[i]] = 1
		else:
			cnt[a[i]] += 1
	if n % 2 == 0:
		for i in cnt:
			if cnt[i] % 4 != 0:
				print('NO')
				return
		grid = [[0] * n for i in range(n)]
		for i in range(n // 2):
			for j in range(n // 2):
				for ii in cnt:
					if cnt[ii] != 0:
						grid[i][j] = ii
						grid[i][n - j - 1] = ii
						grid[n - i - 1][j] = ii
						grid[n - i - 1][n - j - 1] = ii
						cnt[ii] -= 4
						break
		print('YES')
		for i in range(n):
			print(*grid[i])
	else:
		basic = []
		temp = []
		for i in cnt:
			if cnt[i] % 4 == 0 or cnt[i] > 4:
				for j in range(cnt[i] // 4):
					basic.append(i)
				cnt[i] = cnt[i] % 4
		twos = []
		if len(basic) > ((n - 1) // 2) ** 2:
			ind = ((n - 1) // 2) ** 2
			for i in range(ind, len(basic)):
				twos.append(basic[i])
				twos.append(basic[i])
		chck = 0
		for i in cnt:
			if cnt[i] % 2 == 0 or cnt[i] > 2:
				for j in range(cnt[i] // 2):
					twos.append(i)
				cnt[i] = cnt[i] % 2
			if cnt[i] % 2 == 1:
				chck += 1
		if chck != 1 or len(twos) != n - 1:
			print('NO')
			return
		curr = 0
		grid = [[0] * n for i in range(n)]
		for i in range((n - 1) // 2):
			for j in range((n - 1) // 2):
				grid[i][j] = basic[curr]
				grid[i][n - j - 1] = basic[curr]
				grid[n - i - 1][j] = basic[curr]
				grid[n - i - 1][n - j - 1] = basic[curr]
				curr += 1
		curr = 0
		for i in range(n // 2):
			grid[n // 2][i] = twos[curr]
			grid[n // 2][n - i - 1] = twos[curr]
			curr += 1
		for i in range(n // 2):
			grid[i][n // 2] = twos[curr]
			grid[n - i - 1][n // 2] = twos[curr]
			curr += 1
		for i in cnt:
			if cnt[i] == 1:
				grid[n // 2][n // 2] = i
				break
		print('YES')
		for i in range(n):
			print(*grid[i])
testcase(1)


from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')

def solve():
	n = ii()
	a = li()
	x = [[0] * n for i in range(n)]
	a.sort()
	m = dd(int)
	for i in a:
		m[i] += 1
	if n % 2 == 0:
		(r, c) = (0, 0)
		for i in m.keys():
			if m[i] % 4:
				print('NO')
				exit(0)
			while m[i]:
				(x[r][c], x[r][n - c - 1], x[n - r - 1][c], x[n - r - 1][n - c - 1]) = (i, i, i, i)
				m[i] -= 4
				c += 1
				if c == n // 2:
					r += 1
					c = 0
		print('YES')
		for i in range(n):
			print(*x[i])
	else:
		(r, c) = (0, 0)
		for i in m.keys():
			while m[i] >= 4:
				if r == n // 2:
					break
				(x[r][c], x[r][n - c - 1], x[n - r - 1][c], x[n - r - 1][n - c - 1]) = (i, i, i, i)
				m[i] -= 4
				c += 1
				if c == n // 2:
					r += 1
					c = 0
		(r, c) = (0, 0)
		for i in m.keys():
			while m[i] >= 2:
				if r == n // 2:
					break
				(x[r][n // 2], x[n - r - 1][n // 2]) = (i, i)
				m[i] -= 2
				r += 1
		for i in m.keys():
			while m[i] >= 2:
				if c == n // 2:
					break
				(x[n // 2][c], x[n // 2][n - c - 1]) = (i, i)
				m[i] -= 2
				c += 1
		for i in m.keys():
			if m[i] > 0:
				x[n // 2][n // 2] = i
		for i in x:
			if 0 in i:
				print('NO')
				exit(0)
		print('YES')
		for i in range(n):
			print(*x[i])
solve()


n = int(input())
num = [0 for j in range(1000)]
a = [int(j) for j in input().split()]
var = 0
arr = [[0 for j in range(n)] for j in range(n)]
count = 0
t = 0
count1 = 0
count2 = 0
count3 = 0
count4 = 0
for i in range(n * n):
	num[a[i] - 1] += 1
if n % 2 == 0:
	i = 0
	for x in num:
		if x % 4 != 0:
			var = 1
			break
	if var == 1:
		print('NO')
	else:
		print('YES')
		for x in range(n // 2):
			for y in range(n // 2):
				if num[i] == 0:
					while num[i] == 0:
						i += 1
				arr[x][y] = i + 1
				arr[n - x - 1][y] = i + 1
				arr[x][n - y - 1] = i + 1
				arr[n - x - 1][n - y - 1] = i + 1
				num[i] -= 4
		for x in arr:
			print(*x)
else:
	for x in num:
		if x % 4 == 0:
			count4 += 1
		elif x % 4 == 2:
			count2 += 1
		elif x % 4 == 1:
			count1 += 1
		elif x % 4 == 3:
			count2 += 1
			count1 += 1
	if count2 > 2 * (n // 2) or count1 > 1:
		print('NO')
	else:
		print('YES')
		i = 0
		for x in range(n // 2):
			for y in range(n // 2):
				if num[i] < 4:
					while num[i] < 4:
						i += 1
				arr[x][y] = i + 1
				arr[n - x - 1][y] = i + 1
				arr[x][n - y - 1] = i + 1
				arr[n - x - 1][n - y - 1] = i + 1
				num[i] -= 4
		i = 0
		for x in range(n // 2):
			y = n // 2
			if num[i] < 2:
				while num[i] < 2:
					i += 1
			arr[x][y] = i + 1
			arr[n - x - 1][y] = i + 1
			num[i] -= 2
		i = 0
		for y in range(n // 2):
			x = n // 2
			if num[i] < 2:
				while num[i] < 2:
					i += 1
			arr[x][y] = i + 1
			arr[x][n - y - 1] = i + 1
			num[i] -= 2
		for i in range(1000):
			if num[i] == 1:
				arr[n // 2][n // 2] = i + 1
		for x in arr:
			print(*x)


def main():
	n = int(input())
	corner = []
	middle = []
	centre = []
	arr = input().split()
	cat = []
	for x in range(n * n):
		hold = int(arr[x])
		bo = False
		for y in range(len(cat)):
			if hold == cat[y][0]:
				cat[y][1] += 1
				bo = True
				break
		if not bo:
			cat.append([hold, 1])
	if n % 2 == 1:
		for x in range(len(cat)):
			if cat[x][1] % 2 == 1:
				centre.append(cat[x][0])
				cat[x][1] -= 1
		if len(centre) != 1:
			print('NO')
			return 0
		for x in range(len(cat)):
			if cat[x][1] % 4 == 2:
				middle.append(cat[x][0])
				cat[x][1] -= 2
		if len(middle) > n // 2 * 2:
			print('NO')
			return 0
	else:
		for x in range(len(cat)):
			if cat[x][1] % 4 != 0:
				print('NO')
				return 0
	print('YES')
	x = 0
	while len(corner) < n // 2 * (n // 2) and x < len(cat):
		if cat[x][1] > 0:
			cat[x][1] -= 4
			corner.append(cat[x][0])
		else:
			x += 1
	while x < len(cat):
		if cat[x][1] > 0:
			cat[x][1] -= 2
			middle.append(cat[x][0])
		else:
			x += 1
	arr = [[0 for x in range(n)] for y in range(n)]
	if n % 2 == 1:
		arr[n // 2][n // 2] = centre[0]
		for x in range(n // 2):
			arr[n // 2][x] = middle[x]
			arr[n // 2][n - 1 - x] = middle[x]
			arr[x][n // 2] = middle[n - 2 - x]
			arr[n - 1 - x][n // 2] = middle[n - 2 - x]
	x = 0
	for y in range(n // 2):
		for z in range(n // 2):
			arr[y][z] = corner[x]
			arr[y][n - 1 - z] = corner[x]
			arr[n - 1 - y][z] = corner[x]
			arr[n - 1 - y][n - 1 - z] = corner[x]
			x += 1
	for x in range(n):
		for y in range(n - 1):
			print(arr[x][y], end=' ')
		print(arr[x][n - 1])
main()


import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
t = int(input())
b = sorted(list(map(int, input().split())))
c = dict()
if t % 2 == 0:
	for j in b:
		if j in c.keys():
			c[j] += 1
		else:
			c[j] = 1
	k = list(set(b))
	f = 0
	for j in k:
		if c[j] % 4 != 0:
			f = 1
			break
	if f == 1:
		print('No')
	else:
		a = []
		for j in range(t):
			p = [0] * t
			a.append(p)
		l = 0
		for j in range(t // 2):
			for p in range(t // 2):
				q = b[l]
				a[j][p] = q
				a[t - 1 - j][p] = q
				a[j][t - p - 1] = q
				a[t - 1 - j][t - 1 - p] = q
				l += 4
		print('YES')
		for j in a:
			print(*j)
else:
	for j in b:
		if j in c.keys():
			c[j] += 1
		else:
			c[j] = 1
	k = list(set(b))
	f = 0
	d = []
	h = 0
	r = (t - 1) * (t - 1)
	for j in k:
		if c[j] // 4 >= 1:
			m = c[j] - c[j] % 4
			h += m
			for p in range(min(r, m)):
				d.append(j)
			if len(d) >= r:
				break
	if h < r:
		print('No')
	else:
		a = []
		for j in range(t):
			p = [0] * t
			a.append(p)
		l = 0
		for j in range(t // 2):
			for p in range(t // 2):
				q = d[l]
				a[j][p] = q
				a[t - 1 - j][p] = q
				a[j][t - p - 1] = q
				a[t - 1 - j][t - 1 - p] = q
				c[d[l]] += -4
				l += 4
		d = []
		g = t // 2
		r = (t - 1) * 2
		h = 0
		for j in k:
			if c[j] // 2 > 0:
				m = c[j] - c[j] % 2
				h += m
				for p in range(min(r, m)):
					d.append(j)
				if len(d) >= r:
					break
		if h < r:
			print('No')
		else:
			l = 0
			for j in range(t // 2):
				q = d[l]
				a[j][t // 2] = q
				a[t - 1 - j][t // 2] = q
				c[d[l]] += -2
				l += 2
				q = d[l]
				a[t // 2][j] = q
				a[t // 2][t - 1 - j] = q
				c[d[l]] += -2
				l += 2
			f = 0
			for j in k:
				if c[j] > 0:
					a[t // 2][t // 2] = j
					f = 1
					break
			if f == 0:
				print('No')
			else:
				print('Yes')
				for j in a:
					print(*j)


n = int(input())
numbers = list(map(int, input().split()))
num = [0] * 1001
matrix = [[0 for i in range(n)] for j in range(n)]
numbers_set = set()
for i in numbers:
	numbers_set.add(i)
	num[i] += 1
ones = 0
one = -1
twos = 0
for i in num:
	if i % 2 == 1:
		ones += 1
		one = num.index(i)
	elif i % 4 == 2:
		twos += 1
if n % 2 == 0:
	if ones or twos:
		print('NO')
		exit()
elif ones != 1 or twos >= n:
	print('NO')
	exit()
iterate = sorted(list(numbers_set))
current_num = iterate[0]
current_pos = 0
for i in range(n // 2):
	for j in range(n // 2):
		if num[current_num] < 4:
			while num[current_num] < 4:
				current_pos += 1
				current_num = iterate[current_pos]
		matrix[i][j] = matrix[i][n - j - 1] = matrix[n - i - 1][j] = matrix[n - i - 1][n - j - 1] = current_num
		num[current_num] -= 4
if n % 2 == 1:
	current_num = iterate[0]
	current_pos = 0
	num[one] -= 1
	matrix[n // 2][n // 2] = one
	for i in range(n // 2):
		if num[current_num] < 2:
			while num[current_num] < 2:
				current_pos += 1
				current_num = iterate[current_pos]
		matrix[i][n // 2] = matrix[n - i - 1][n // 2] = current_num
		num[current_num] -= 2
		if num[current_num] < 2:
			while num[current_num] < 2:
				current_pos += 1
				current_num = iterate[current_pos]
		matrix[n // 2][i] = matrix[n // 2][n - i - 1] = current_num
		num[current_num] -= 2
print('YES')
for i in range(n):
	for j in range(n):
		print(matrix[i][j], end=' ')
	print()


(n, d, remainders) = (int(input()), {}, [0] * 4)
(arr, matrix) = (sorted([int(x) for x in input().split()]), [[0] * n for _ in range(n)])
for number in arr:
	d[number] = d.get(number, 0) + 1
for i in d:
	remainders[d[i] % 4] += 1
if not n % 2 and remainders[0] != sum(remainders) or (n % 2 and remainders[1] + remainders[3] > 1 or remainders[2] > n - 1):
	print('NO')
else:
	(i, j, x, y) = (0, 0, 0, 0)
	if not n % 2:
		for element in arr[::4]:
			(matrix[i][j], matrix[i][n - j - 1], matrix[n - i - 1][n - j - 1], matrix[n - i - 1][j]) = 4 * [element]
			if i < n // 2 - 1:
				i += 1
			else:
				(i, j) = (0, j + 1)
	else:
		arr.sort(key=lambda x: d[x] % 2 == 0)
		(matrix[n // 2][n // 2], d[arr[0]]) = (arr[0], d[arr[0]] - 1)
		for element in arr:
			if d[element] and d[element] % 4 == 0 and (not (i == n // 2 or j == n // 2)):
				d[element] -= 4
				(matrix[i][j], matrix[i][n - j - 1], matrix[n - i - 1][n - j - 1], matrix[n - i - 1][j]) = 4 * [element]
				if i < n // 2 - 1:
					i += 1
				else:
					(i, j) = (0, j + 1)
			elif d[element]:
				d[element] -= 2
				if x < y:
					(matrix[x][n // 2], matrix[-x - 1][n // 2], x) = (element, element, x + 1)
				else:
					(matrix[n // 2][-y - 1], matrix[n // 2][y], y) = (element, element, y + 1)
	print('YES')
	for i in matrix:
		print(*i)


from collections import Counter

def is_possible(n, counter):
	dup_4_arr = []
	dup_2_arr = []
	only_one_value = None
	if n & 1 == 0:
		for v in counter.values():
			if v % 4 != 0:
				return (False, dup_4_arr, dup_2_arr, only_one_value)
	else:
		count_4 = 0
		min_count_4 = (n // 2) ** 2
		for (k, v) in counter.items():
			while v >= 4:
				v = v - 4
				count_4 += 1
				counter[k] -= 4
				dup_4_arr.append(k)
				if count_4 == min_count_4:
					break
			if count_4 == min_count_4:
				break
		if count_4 < min_count_4:
			return (False, dup_4_arr, dup_2_arr, only_one_value)
		count_2 = 0
		min_count_2 = n // 2 * 2
		for (k, v) in counter.items():
			while v >= 2:
				v = v - 2
				count_2 += 1
				counter[k] -= 2
				dup_2_arr.append(k)
				if count_2 == min_count_2:
					break
			if count_2 == min_count_2:
				break
		if count_2 < min_count_2:
			return (False, dup_4_arr, dup_2_arr, only_one_value)
		for (k, v) in counter.items():
			if v == 1:
				only_one_value = k
	return (True, dup_4_arr, dup_2_arr, only_one_value)

def make_matrix(n, arr, counter, dup_4_arr, dup_2_arr, only_one_value):
	ret = [['-1'] * n for _ in range(n)]
	arr = sorted(arr)
	if n & 1 == 0:
		current = 0
		for i in range(n // 2):
			for j in range(n // 2):
				ret[i][j] = str(arr[current])
				current += 1
				ret[i][n - 1 - j] = str(arr[current])
				current += 1
				ret[n - 1 - i][j] = str(arr[current])
				current += 1
				ret[n - 1 - i][n - 1 - j] = str(arr[current])
				current += 1
	else:
		current_4 = 0
		for i in range(n // 2):
			for j in range(n // 2):
				ret[i][j] = str(dup_4_arr[current_4])
				ret[i][n - 1 - j] = str(dup_4_arr[current_4])
				ret[n - 1 - i][j] = str(dup_4_arr[current_4])
				ret[n - 1 - i][n - 1 - j] = str(dup_4_arr[current_4])
				current_4 += 1
		current_2 = 0
		center = n // 2
		for i in range(n // 2):
			ret[center][i] = str(dup_2_arr[current_2])
			ret[center][n - 1 - i] = str(dup_2_arr[current_2])
			current_2 += 1
		for i in range(n // 2):
			ret[i][center] = str(dup_2_arr[current_2])
			ret[n - 1 - i][center] = str(dup_2_arr[current_2])
			current_2 += 1
		ret[center][center] = str(only_one_value)
	return ret
n = int(input())
arr = tuple(map(int, input().split(' ')))
counter = Counter(arr)
(possible, dup_4_arr, dup_2_arr, only_one_value) = is_possible(n, counter)
if possible:
	print('YES')
	mat = make_matrix(n, arr, counter, dup_4_arr, dup_2_arr, only_one_value)
	for i in range(n):
		print(' '.join(mat[i]))
else:
	print('NO')