You are given $4n$ sticks, the length of the $i$-th stick is $a_i$.

You have to create $n$ rectangles, each rectangle will consist of exactly $4$ sticks from the given set. The rectangle consists of four sides, opposite sides should have equal length and all angles in it should be right. Note that each stick can be used in only one rectangle. Each stick should be used as a side, you cannot break the stick or use it not to the full length.

You want to all rectangles to have equal area. The area of the rectangle with sides $a$ and $b$ is $a \cdot b$.

Your task is to say if it is possible to create exactly $n$ rectangles of equal area or not.

You have to answer $q$ independent queries.


-----Input-----

The first line of the input contains one integer $q$ ($1 \le q \le 500$) — the number of queries. Then $q$ queries follow.

The first line of the query contains one integer $n$ ($1 \le n \le 100$) — the number of rectangles.

The second line of the query contains $4n$ integers $a_1, a_2, \dots, a_{4n}$ ($1 \le a_i \le 10^4$), where $a_i$ is the length of the $i$-th stick.


-----Output-----

For each query print the answer to it. If it is impossible to create exactly $n$ rectangles of equal area using given sticks, print "NO". Otherwise print "YES".


-----Example-----
Input
5
1
1 1 10 10
2
10 5 2 10 1 1 2 5
2
10 5 1 10 5 1 1 1
2
1 1 1 1 1 1 1 1
1
10000 10000 10000 10000

Output
YES
YES
NO
YES
YES

Difficulty: EASY
Tags: Mathematics

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
q = int(input())
for i in range(0, q):
	n = int(input())
	p = [int(x) for x in input().split()]
	if n == 1 and p[0] == p[1] and (p[2] == p[3]):
		print('YES')
	else:
		p = sorted(p)
		s = p[0] * p[4 * n - 1]
		e = 0
		for j in range(0, n):
			if p[2 * j] == p[2 * j + 1] and p[4 * n - 2 * j - 2] == p[4 * n - 2 * j - 1] and (p[2 * j] * p[4 * n - 2 * j - 1] == s):
				e += 1
		if e == n:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	input()
	timeToGrab = sorted(map(int, input().split()))
	if len({runner2 * runner3 for (runner2, runner3) in zip(timeToGrab, timeToGrab[::-1])}) == 1 and timeToGrab[::2] == timeToGrab[1::2]:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	p.sort()
	l = []
	j = 0
	k = 4 * n - 1
	flag = 0
	while j < k:
		l.append(p[j] * p[k])
		j = j + 1
		k = k - 1
	for z in range(0, 4 * n, 2):
		if p[z] != p[z + 1]:
			flag = 1
			break
	if len(set(l)) == 1 and flag == 0:
		print('YES')
	else:
		print('NO')


from collections import Counter, defaultdict
try:
	for q in range(int(input())):
		n = int(input())
		s = list(map(int, input().split()))
		s.sort()
		ok = True
		for i in range(0, len(s), 2):
			if s[i] != s[i + 1]:
				ok = False
		if ok:
			area = s[0] * s[4 * n - 1]
			for i in range(len(s) // 2):
				if s[i] * s[len(s) - i - 1] != area:
					ok = False
		print('YES' if ok else 'NO')
except Exception as e:
	print(e)
	exit(1)


q = int(input())
for _ in range(q):
	n = int(input())
	a_list = list(map(int, input().split()))
	a_list.sort()
	area_list = []
	flag = 0
	for i in range(n):
		if a_list[2 * i] == a_list[2 * i + 1] and a_list[-2 * i - 1] == a_list[-2 * (i + 1)]:
			area_list.append(a_list[2 * i] * a_list[-2 * i - 1])
		else:
			flag = 1
			break
	if len(set(area_list)) == 1 and flag == 0:
		print('YES')
	else:
		print('NO')


from sys import stdin
q = int(stdin.readline().strip())
for _ in range(q):
	n = int(stdin.readline().strip())
	arr = list(map(int, stdin.readline().split()))
	arr.sort()
	flag = True
	area = arr[0] * arr[-1]
	i = 0
	j = len(arr) - 1
	while i < j:
		first = arr[i]
		second = arr[i + 1]
		third = arr[j]
		fourth = arr[j - 1]
		if first == second and third == fourth:
			if first * third == area:
				i += 2
				j -= 2
				continue
			else:
				flag = False
				break
		else:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	count = 1
	raju = True
	for k in range(0, len(a) - 1):
		if a[k] == a[k + 1]:
			count += 1
		else:
			if count % 2 != 0:
				raju = False
			count = 1
	if raju:
		for i in range(0, 2 * n - 1):
			if a[i] * a[4 * n - 1 - i] == a[i + 1] * a[4 * n - i - 2]:
				continue
			else:
				break
		if i == 2 * n - 2:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import sys
input = sys.stdin.readline
read_tuple = lambda _type: map(_type, input().split(' '))
from collections import deque

def solve():
	q = int(input())
	for _ in range(q):
		n = int(input())
		sticks = deque(sorted(read_tuple(int)))
		correct_shapes = True
		squares = set()
		while sticks:
			a = sticks.popleft()
			b = sticks.popleft()
			c = sticks.pop()
			d = sticks.pop()
			squares.add(a * c)
			correct_shapes = min(correct_shapes, a == b and c == d)
		if correct_shapes and len(squares) == 1:
			print('YES')
		else:
			print('NO')
solve()


for _ in range(int(input())):
	n = 4 * int(input())
	a = list(map(int, input().split(' ')))
	a = sorted(a)
	i1 = 0
	i2 = 1
	j1 = n - 1
	j2 = n - 2
	f = 0
	if a[i1] != a[i2]:
		f = 1
	if a[j1] != a[j2]:
		f = 1
	area = a[i1] * a[j1]
	while i2 < j2:
		if a[i1] != a[i2]:
			f = 1
		if a[j1] != a[j2]:
			f = 1
		ar = a[i1] * a[j1]
		if area != ar:
			f = 1
		i1 += 2
		i2 += 2
		j1 -= 2
		j2 -= 2
		if f:
			break
	if f:
		print('NO')
	else:
		print('YES')


import sys

def main():
	q = int(sys.stdin.readline())
	for z in range(q):
		n = int(sys.stdin.readline())
		a = [int(x) for x in sys.stdin.readline().split(' ')]
		a.sort()
		match = True
		for i in range(1, len(a), 2):
			if a[i] != a[i - 1]:
				match = False
				break
		if not match:
			print('NO')
			continue
		prod = a[0] * a[-1]
		for i in range(len(a)):
			if a[i] * a[len(a) - i - 1] != prod:
				match = False
				break
		if match:
			print('YES')
		else:
			print('NO')
main()


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	bb = len(l)
	d = Counter(l)
	zx = 0
	ans = []
	for y in d:
		if d[y] % 2 != 0:
			zx = 1
			break
	if zx == 1:
		print('NO')
	else:
		l1 = l[0:bb // 2]
		l2 = l[bb // 2:bb]
		l2.reverse()
		for t in range(len(l1)):
			a = l1[t] * l2[t]
			ans.append(a)
		s = set(ans)
		if len(s) > 1:
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	flag = 1
	area = a[0] * a[-1]
	for i in range(0, 2 * n, 2):
		if a[i] != a[i + 1] or a[-(i + 1)] != a[-(i + 2)]:
			flag = 0
			break
		if a[i] * a[-(i + 1)] != area:
			flag = 0
			break
	if flag == 1:
		print('YES')
	else:
		print('NO')


cnt = [0] * 10002
a = [0]

def reset():
	global a, cnt
	for i in range(len(a)):
		cnt[a[i]] = 0

def good(val):
	global a, cnt
	n = len(a)
	for i in range(n):
		x = a[i]
		if val % x != 0 or val // x > 10000 or cnt[x] % 2 != 0 or (cnt[x] != cnt[val // x]):
			return False
	return True
tests = int(input())
for _ in range(tests):
	n = int(input())
	n *= 4
	a = list(map(int, input().split()))
	for i in range(n):
		cnt[a[i]] += 1
	ok = False
	a.sort()
	if good(a[0] * a[n - 1]):
		ok = True
	print('YES') if ok else print('NO')
	reset()


q = int(input())
ans = []
for i in range(q):
	l = []
	m = []
	x = 0
	y = 1
	temp = 0
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	if len(a) == 4:
		if a[0] == a[1] and a[2] == a[3]:
			ans.append('YES')
		else:
			ans.append('NO')
	else:
		while y < len(a):
			l.append(a[x])
			m.append(a[y])
			x += 2
			y += 2
		if l == m:
			area = l[0] * l[-1]
			for j in range(len(l) // 2 - 1):
				area_check = l[temp + 1] * l[-temp - 2]
				temp += 1
				if area == area_check:
					if j == len(l) // 2 - 2:
						ans.append('YES')
				else:
					ans.append('NO')
					break
		else:
			ans.append('NO')
for e in ans:
	print(e)


def main():
	n = input()
	sticks = list(map(int, input().split()))
	sticks.sort()
	s = list()
	for i in range(0, len(sticks), 2):
		if sticks[i] != sticks[i + 1]:
			print('NO')
			return
	while len(sticks) > 0:
		s.append(sticks[-1] * sticks[0])
		sticks.pop()
		sticks.pop()
		sticks.pop(0)
		sticks.pop(0)
	for i in range(len(s) - 1):
		if s[i] != s[i + 1]:
			print('NO')
			return
	print('YES')
q = int(input())
for i in range(q):
	main()


from sys import stdin
from collections import defaultdict
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	d = defaultdict(lambda : 0)
	arr = list(map(int, stdin.readline().rstrip().split(' ')))
	for ele in arr:
		d[ele] += 1
	sideSet = list(d.keys())
	if len(sideSet) == 1:
		print('YES')
		continue
	if d[sideSet[0]] % 2 != 0:
		print('NO')
		continue
	for i in range(len(sideSet)):
		if d[sideSet[i]] % 2 != 0:
			print('NO')
			break
		area = sideSet[0] * sideSet[i]
		visited = {}
		for j in range(len(sideSet)):
			if sideSet[j] in visited:
				continue
			else:
				visited[sideSet[j]] = 1
				other = area / sideSet[j]
				if other != int(other) or d[sideSet[j]] != d[other]:
					break
				visited[other] = 1
		else:
			print('YES')
			break
	else:
		print('NO')


q = int(input())
for w in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	n *= 4
	x = a[0] * a[n - 1]
	ok = 1
	for i in range(0, n // 2, 2):
		if a[i] * a[n - i - 1] != x or a[i] != a[i + 1] or a[n - i - 1] != a[n - i - 2]:
			ok = 0
			break
	if ok:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	x = [int(n) for n in input().split()]
	x = sorted(x)
	a = {}
	f = 0
	for i in x:
		if i not in a:
			a[i] = 0
		a[i] += 1
	for i in a:
		if a[i] & 1:
			f = 1
	s = x[0] * x[4 * n - 1]
	n = 4 * n
	if f == 0:
		for i in range(0, n // 2 + 1):
			if x[i] * x[n - 1 - i] != s:
				f = 1
	if f == 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	cnt = dict()
	now = list(map(int, input().split()))
	for j in range(4 * n):
		cnt[now[j]] = cnt.get(now[j], 0) + 1
	cnt = sorted(list(cnt.items()))
	(f, s) = (0, len(cnt) - 1)
	ans = cnt[0][0] * cnt[-1][0]
	good = True
	while f <= s and good:
		if cnt[f][0] * cnt[s][0] != ans or cnt[f][1] != cnt[s][1] or cnt[f][1] % 2 != 0:
			good = False
			break
		(f, s) = (f + 1, s - 1)
	if good:
		print('YES')
	else:
		print('NO')


tmp = input()
q = int(tmp)
for i in range(q):
	n = int(input())
	tmp = input().split()
	odd = []
	pair = []
	for t in tmp:
		t = int(t)
		if t not in odd:
			odd.append(t)
		else:
			odd.remove(t)
			pair.append(t)
	if odd:
		print('NO')
		continue
	pair.sort()
	area = pair[0] * pair[2 * n - 1]
	isOK = True
	for j in range(1, n):
		if pair[j] * pair[2 * n - 1 - j] != area:
			isOK = False
			break
	if isOK:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	if len({x * y for (x, y) in zip(a, a[::-1])}) == 1 and a[::2] == a[1::2]:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	v = [0] * 10001
	for j in range(4 * n):
		v[a[j]] += 1
	b = []
	flag = True
	for j in range(10001):
		if v[j] % 2 == 0:
			for k in range(v[j] // 2):
				b.append(j)
		else:
			flag = False
	for j in range(len(b) // 2):
		if b[j] * b[-j - 1] != b[0] * b[-1]:
			flag = False
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	same = True
	for i in range(1, len(a), 2):
		if a[i] != a[i - 1]:
			same = False
			break
	if len({x * y for (x, y) in zip(a, a[::-1])}) == 1 and same:
		print('YES')
	else:
		print('NO')


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	d = defaultdict(int)
	f = 0
	for i in lis:
		d[i] += 1
	for i in d:
		if d[i] % 2 == 1:
			f = 1
			break
	if f == 1:
		print('NO')
		continue
	lis.sort()
	p = lis[0] * lis[-1]
	i = 0
	j = len(lis) - 1
	while i < j:
		if p != lis[i] * lis[j]:
			f = 1
			break
		i += 2
		j -= 2
	if f == 0:
		print('YES')
	else:
		print('NO')


q = int(input())
answer = [''] * q
for t in range(q):
	n = int(input())
	x = [int(y) for y in input().split(' ')]
	x.sort()
	test = True
	if x[0] == x[1] and x[-2] == x[-1]:
		area = x[0] * x[-1]
		x = x[2:-2]
	else:
		test = False
	while x:
		if x[0] == x[1] and x[-2] == x[-1]:
			newarea = x[0] * x[-1]
			x = x[2:-2]
			if newarea != area:
				test = False
				break
		else:
			test = False
			break
	if test:
		answer[t] = 'YES'
	else:
		answer[t] = 'NO'
for r in answer:
	print(r)


def int_multiple():
	return [int(c) for c in input().split()]

def int_single():
	return int(input())

def str_multiple():
	return [c for c in input().split()]

def str_single():
	return input()
q = int_single()
res = []
for i in range(q):
	n = int_single()
	ok = True
	tmp = []
	l = int_multiple()
	if ok:
		l = sorted(l)
		for j in range(int(4 * n / 2)):
			if l[2 * j] != l[2 * j + 1]:
				ok = False
			else:
				tmp.append(l[2 * j])
	if ok:
		ltmp = len(tmp)
		fmul = tmp[0] * tmp[-1]
		if ltmp > 2:
			for j in range(1, int(ltmp / 2)):
				if tmp[j] * tmp[ltmp - j - 1] != fmul:
					ok = False
	if ok:
		res.append('YES')
	else:
		res.append('NO')
for r in res:
	print(r)


q = int(input())
for i in range(q):
	t = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	pos = True
	lengths = []
	for j in range(2 * t):
		if arr[2 * j] != arr[2 * j + 1]:
			pos = False
			break
		lengths.append(arr[2 * j])
	if pos == True:
		area = lengths[0] * lengths[2 * t - 1]
		for j in range(t - 1):
			if lengths[1 + j] * lengths[2 * t - 2 - j] != area:
				pos = False
				break
	if pos == True:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	p = a.copy()
	p.reverse()
	r = a[0] * p[0]
	c = 1
	for x in a:
		if a.count(x) % 2 != 0:
			c = 0
	for i in range(4 * n):
		if a[i] * p[i] != r:
			c = 0
	if c:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	arr = [int(k) for k in input().split()]
	dic = {}
	for i in range(4 * n):
		if arr[i] not in dic:
			dic[arr[i]] = 1
		else:
			dic[arr[i]] += 1
	res = []
	counter = 0
	for (key, item) in dic.items():
		if item % 2 != 0:
			counter = 1
			break
		for i in range(item // 2):
			res.append(key)
	res.sort()
	area = 0
	if counter:
		print('No')
		continue
	for i in range(len(res) // 2):
		if i == 0:
			area = res[i] * res[len(res) - i - 1]
			continue
		if res[i] * res[len(res) - i - 1] != area:
			counter = 1
			break
	if counter:
		print('No')
	else:
		print('Yes')


q = int(input())
for _ in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	base = a[0] * a[-1]
	for i in range(0, 2 * n, 2):
		if a[i] != a[i + 1]:
			print('NO')
			break
		if a[-i - 1] != a[-i - 2]:
			print('NO')
			break
		if a[i] * a[-i - 1] != base:
			print('NO')
			break
	else:
		print('YES')


q = int(input())
while q:
	q = q - 1
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	check = 0
	ch = l[0] * l[4 * n - 1]
	for i in range(0, 2 * n, 2):
		if l[i] != l[i + 1] or l[4 * n - i - 1] != l[4 * n - i - 2]:
			check = 1
			break
		if ch != l[i] * l[4 * n - i - 1]:
			check = 1
			break
	if check == 1:
		print('NO')
	else:
		print('YES')


q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = True
	S = -1
	i = 0
	for j in range(n):
		if a[i] == a[i + 1] and a[-(1 + i)] == a[-(2 + i)]:
			if S == -1 or S == a[i] * a[-(1 + i)]:
				S = a[i] * a[-(1 + i)]
			else:
				ans = False
				break
		else:
			ans = False
			break
		i += 2
	if ans:
		print('YES')
	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 math import gcd
(t,) = I()
while t:
	t -= 1
	(n,) = I()
	l = I()
	l.sort()
	area = l[0] * l[-1]
	i = 0
	ans = 'YES'
	while i < 2 * n:
		if l[i] == l[i + 1] and l[4 * n - i - 1] == l[4 * n - i - 2] and (l[i] * l[4 * n - i - 1] == area):
			i += 2
			continue
		ans = 'NO'
		break
	print(ans)


q = input()
q = int(q)
while q:
	n = input()
	n = int(n)
	l = list(map(int, input().split()))
	l.sort()
	i = 0
	j = len(l) - 1
	area = []
	ch = 0
	for i in range(len(l) // 2):
		if i % 2 == 0:
			if l[i] == l[i + 1] and l[j] == l[j - 1]:
				ch = l[i] * l[j]
				area.append(l[i] * l[j])
				j -= 2
	a = 0
	for i in range(len(area)):
		if area[i] == ch:
			a += 1
	if a == n:
		print('YES')
	else:
		print('NO')
	q -= 1


import sys

def rectangules(sticks, n):
	sticks.sort()
	end = 4 * n
	med = 2 * n
	area = sticks[0] * sticks[-1]
	for i in range(0, med, 2):
		if sticks[i] != sticks[i + 1] or sticks[end - i - 1] != sticks[end - i - 2]:
			return False
		if sticks[i] * sticks[end - i - 1] != area:
			return False
	return True
tests = int(input())
for i in range(tests):
	n = int(input())
	sticks = [int(x) for x in sys.stdin.readline().split()]
	if rectangules(sticks, n):
		print('YES\n')
	else:
		print('NO\n')


for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	(i, j) = (0, n * 4)
	s = a[0] * a[-1]
	while i < j:
		if a[i] == a[i + 1] and a[j - 2] == a[j - 1] and (s == a[i] * a[j - 1]):
			i += 2
			j -= 2
		else:
			print('NO')
			break
	else:
		print('YES')


q = int(input())
for _ in range(q):
	n = int(input())
	a = sorted(map(int, input().split()))
	k = 4 * n - 1
	v = a[0] * a[k]
	r = 'YES'
	i = 0
	while i < k // 2:
		if a[i] != a[i + 1] or a[k - i] != a[k - i - 1] or a[i] * a[k - i] != v:
			r = 'NO'
			break
		i += 2
	print(r)


t = int(input())
for T in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	area = a[0] * a[-1]
	(i, j) = (0, 4 * n - 1)
	for _ in range(n):
		if a[i] == a[i + 1] and a[j] == a[j - 1] and (a[i] * a[j] == area):
			i += 2
			j -= 2
			continue
		else:
			print('NO')
			break
	else:
		print('YES')


import collections
q = int(input())
for _ in range(q):
	n = int(input())
	A = [int(x) for x in input().split()]
	Dict = collections.Counter(A)
	flag = 0
	for i in Dict.keys():
		if Dict[i] % 2 == 0:
			Dict[i] = Dict[i] // 2
		else:
			flag = 1
			break
	if flag:
		print('NO')
	else:
		p = 1
		for i in Dict.keys():
			p *= i ** (Dict[i] / n)
		l = int(p + 0.5)
		temp = abs(l - p)
		if temp <= 1e-05:
			print('YES')
		else:
			print('NO')


from collections import Counter, defaultdict
q = int(input())
results = []
for _ in range(q):
	n = int(input())
	sticks = list(map(int, input().split()))
	sticks.sort()
	area = sticks[0] * sticks[-1]
	r = 'YES'
	for i in range(n):
		if sticks[2 * i] != sticks[2 * i + 1] or sticks[-1 * (2 * i + 1)] != sticks[-1 * (2 * i + 2)] or sticks[2 * i] * sticks[-1 * (2 * i + 1)] != area:
			r = 'NO'
	results.append(r)
print('\n'.join(results))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	if l[0] == l[1] and l[-1] == l[-2]:
		a = l[0] * l[-1]
	else:
		print('NO')
		continue
	ans = 'YES'
	for i in range(2, 2 * n, 2):
		if l[i] != l[i + 1] or l[-i - 1] != l[-i - 2] or l[i] * l[-i - 1] != a:
			ans = 'NO'
			break
	print(ans)


q = int(input())
for _ in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	f = True
	for i in range(1, n * 4, 2):
		if a[i] != a[i - 1]:
			print('NO')
			f = False
			break
	if not f:
		continue
	l = []
	for i in range(n):
		l.append(a[2 * i] * a[4 * n - i * 2 - 1])
	if l.count(l[0]) != len(l):
		f = False
	if f:
		print('YES')
	else:
		print('NO')


queries = int(input())
for q in range(queries):
	n = int(input())
	n *= 4
	sticks = list(map(int, input().split()))
	sticks.sort()
	s = sticks[0] * sticks[n - 1]
	ok = True
	for i in range(0, n // 2, 2):
		if sticks[i] != sticks[i + 1] or sticks[n - i - 1] != sticks[n - i - 2] or sticks[i] * sticks[n - i - 1] != s:
			ok = False
			break
	print('YES' if ok else 'NO')


from math import ceil, floor
q = int(input())
for query in range(q):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	(i, flag) = (0, False)
	while i < 2 * n:
		if A[i] == A[i + 1]:
			A.pop(i)
			i += 1
		else:
			flag = True
			break
	if flag:
		print('NO')
		continue
	prod = A[0] * A[2 * n - 1]
	for i in range(1, n):
		if prod != A[i] * A[2 * n - i - 1]:
			flag = True
			break
	if flag:
		print('NO')
	else:
		print('YES')


for q in range(int(input())):
	a = int(input())
	(d, f, l) = ([], 0, sorted(list(map(int, input().split()))))
	for x in range(0, 2 * a, 2):
		if l[x] == l[x + 1] and l[-x - 1] == l[-x - 2]:
			d.append(l[x] * l[-x - 1])
		else:
			f = 1
			break
	if f == 1:
		print('NO')
	elif len(set(d)) == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	input()
	a = sorted(map(int, input().split()))
	if len({a1 * an for (a1, an) in zip(a, a[::-1])}) == 1 and a[::2] == a[1::2]:
		print('YES')
	else:
		print('NO')


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
from heapq import heappush as hpush
from heapq import heappop as hpop
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())
for _ in range(ri(1)):
	n = ri(1)
	a = ri()
	a.sort()
	minn = a[0] * a[-1]
	status = 1
	temp = []
	for i in range(n):
		temp.append(a[0])
		temp.append(a[1])
		temp.append(a[-1])
		temp.append(a[-2])
		a.pop(0)
		a.pop(0)
		a.pop(-1)
		a.pop(-1)
		if temp[0] == temp[1] and temp[2] == temp[3] and (temp[0] * temp[3] == minn):
			pass
		else:
			status = 0
		temp = []
	if status:
		print('YES')
	else:
		print('NO')


n = int(input())
for x in range(n):
	q = int(input())
	ind = [int(x) for x in input().split()]
	ind.sort()
	area = ind[0] * ind[-1]
	canDo = True
	for i in range(q):
		l = i * 2
		r = 4 * q - 2 * i - 1
		if ind[l] != ind[l + 1] or ind[r] != ind[r - 1] or ind[l] * ind[r] != area:
			canDo = False
			break
	print('YES' if canDo else 'NO')


q = int(input())
while q:
	n = int(input())
	a = input().split()
	for i in range(4 * n):
		a[i] = int(a[i])
	a.sort()
	b = []
	count = 0
	for j in range(4 * n):
		if j == 0:
			count += 1
			if j == 4 * n - 1:
				b.append(count)
		elif a[j] == a[j - 1]:
			count += 1
			if j == 4 * n - 1:
				b.append(count)
		else:
			b.append(count)
			count = 1
			if j == 4 * n - 1:
				b.append(count)
	c = []
	for k in range(4 * n):
		if k % 2 == 0:
			c.append(a[k])
	count = 0
	for x in range(len(b)):
		if b[x] % 2 == 0:
			count += 1
	if count == len(b) and len(c) % 2 == 0:
		d = []
		for y in range(len(c) // 2):
			d.append(c[y] * c[len(c) - 1 - y])
		if len(set(d)) == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	q -= 1


def task_b(n, a):
	a.sort()
	ok = True
	area = a[0] * a[4 * n - 1]
	for i in range(n):
		lf = 2 * i
		rg = 4 * n - i * 2 - 1
		if a[lf] != a[lf + 1] or a[rg] != a[rg - 1] or a[lf] * a[rg] != area:
			ok = False
	if ok:
		return 'YES'
	else:
		return 'NO'
q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	print(task_b(n, a))


T = int(input())
for _ in range(T):
	n = int(input())
	side = input().split(' ')
	for i in range(4 * n):
		side[i] = int(side[i])
	side.sort()
	t = True
	for i in range(2 * n):
		if side.count(side[i * 2]) % 2 != 0:
			t = False
			break
	if not t:
		print('NO')
		continue
	if n == 1:
		print('YES')
		continue
	p = 1
	for i in side:
		p *= int(i)
	if p == pow(int(side[0]) * int(side[-1]), 2 * n):
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	y = 'YES'
	pr = a[0] * a[-1]
	for i in range(2 * n):
		if i % 2 == 1:
			if a[i] != a[i - 1]:
				y = 'NO'
			elif a[i] * a[-i - 1] != pr:
				y = 'NO'
		elif a[i] * a[-i - 1] != pr:
			y = 'NO'
	print(y)


from functools import reduce
from collections import Counter
for t in range(int(input())):
	(N, Sum, Check) = (int(input()), 1, True)
	X = sorted(list(map(int, input().split())))
	MyDict = Counter(X)
	for i in MyDict.values():
		if i % 2 == 1:
			Check = False
			break
	print('NO' if not Check or (X[0] * X[-1]) ** (N * 2) != reduce(lambda a, b: a * b, X) else 'YES')


from collections import Counter
for q in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = dict(Counter(a))
	w = True
	for i in m:
		if m[i] % 2:
			w = False
		else:
			m[i] //= 2
	if not w:
		print('NO')
		continue
	arr = list(sorted(m.keys()))
	s = arr[0] * arr[-1]
	n = len(arr)
	for i in range(len(arr) // 2):
		if arr[i] * arr[n - i - 1] != s or m[arr[i]] != m[arr[n - i - 1]]:
			w = False
	if n % 2:
		if arr[n // 2] ** 2 != s or m[arr[n // 2]] % 2:
			w = False
	if w:
		print('YES')
	else:
		print('NO')


from math import *
from collections import *
from itertools import *
from functools import *
from random import *

def getl(t=int):
	return [t(x) for x in input().split()]

def get(t=int):
	return t(input())
alphabet = [chr(x) for x in range(ord('a'), ord('z') + 1)]
alnum = lambda x: ord(x) - ord('a')

def main():
	for i in range(get()):
		if test():
			print('YES')
		else:
			print('NO')

def test():
	n = get()
	a = getl()
	a.sort()
	b = []
	for i in range(2 * n):
		if a[2 * i] != a[2 * i + 1]:
			return False
		b += [a[2 * i]]
	for i in range(n):
		if b[i] * b[2 * n - i - 1] != b[0] * b[2 * n - 1]:
			return False
	return True
main()


def construct():
	n = 4 * int(input())
	items = [int(item) for item in input().split()]
	items.sort()
	semi_items = []
	index = 1
	while index < n:
		if items[index - 1] != items[index]:
			return 'NO'
		else:
			semi_items.append(items[index])
			index += 2
	dif = 1
	index = 0
	squares = []
	while index < n / 2:
		squares.append(semi_items[index] * semi_items[index - dif])
		dif += 2
		index += 1
	if len(set(squares)) == 1:
		return 'YES'
	else:
		return 'NO'
for i in range(int(input())):
	print(construct())


from collections import Counter
q = int(input())
for testcases in range(q):
	n = int(input())
	C = Counter(list(map(int, input().split())))
	X = [x % 2 for x in C.values()]
	if 1 in X:
		print('NO')
		continue
	LIST = sorted(C.keys())
	sq = LIST[0] * LIST[-1]
	i = 0
	j = len(LIST) - 1
	for squares in range(n):
		while C[LIST[i]] == 0:
			i += 1
		while C[LIST[j]] == 0:
			j -= 1
		if LIST[i] * LIST[j] == sq:
			C[LIST[i]] -= 2
			C[LIST[j]] -= 2
			continue
		else:
			print('NO')
			break
	else:
		print('YES')


q = int(input())
for _ in range(q):
	n = int(input())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	dic = {}
	for val in arr:
		if val not in dic:
			dic[val] = 1
		else:
			dic[val] += 1
	flag = True
	arr2 = []
	for val in dic.keys():
		if dic[val] % 2 != 0:
			flag = False
			break
	if flag == True:
		s = set()
		for i in range(4 * n):
			s.add(arr[i] * arr[-(i + 1)])
		if len(s) == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	d = []
	j = 0
	flag = 1
	while j < 4 * n:
		if ar[j + 1] == ar[j]:
			d.append(ar[j])
			j += 2
		else:
			flag = 0
			break
	if flag == 0:
		print('NO')
		continue
	prod = d[0] * d[len(d) - 1]
	for j in range(len(d) // 2):
		l = d[j] * d[len(d) - j - 1]
		if l != prod:
			flag = 0
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.buffer.readline
cnt = [0] * 10005
a = []

def reset():
	global a, cnt
	for i in range(len(a)):
		cnt[a[i]] = 0

def good(val):
	global a, cnt
	n = len(a)
	for i in range(n):
		x = a[i]
		if val % x != 0 or val // x > 10000 or cnt[x] % 2 != 0 or (cnt[x] != cnt[val // x]):
			return False
	return True
tests = int(input())
for _ in range(tests):
	n = int(input())
	n *= 4
	a = list(map(int, input().split()))
	for i in range(n):
		cnt[a[i]] += 1
	ok = False
	a.sort()
	if good(a[0] * a[n - 1]):
		ok = True
	print('YES') if ok else print('NO')
	reset()


import sys

def inpt():
	return sys.stdin.readline().strip()
q = int(inpt())
for i in range(q):
	n = int(inpt())
	mas = sorted([int(i) for i in inpt().split()])
	di = dict()
	x = []
	for a in mas:
		if a not in di:
			di[a] = 1
			x.append(a)
		elif (di[a] + 1) % 2 == 0:
			di[a] = 0
		else:
			di[a] += 1
			x.append(a)
	bb = False
	for a in di:
		if di[a] != 0:
			bb = True
			print('NO')
			break
	if bb:
		continue
	con = x[0] * x[n * 2 - 1]
	qq = True
	for j in range(1, n + 1):
		if x[j] * x[2 * n - j - 1] != con:
			print('NO')
			qq = False
			break
	if qq:
		print('YES')


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')
t = int(input())
for i in range(t):
	n = int(input())
	num = list(map(int, input().split()))
	num.sort()
	d = 0
	dummy = 0
	p = 0
	p = num[0] * num[4 * n - 1]
	ch = True
	for j in range(1, 2 * n):
		if int(num[j]) == int(num[j - 1]) and j % 2 == 1:
			d = d + 1
		if num[j] * num[4 * n - 1 - j] == p:
			dummy = 1
		else:
			ch = False
	if ch == True and d == n:
		print('Yes')
	else:
		print('No')


t = int(input())
while t != 0:
	t -= 1
	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
	flag = 0
	for i in d:
		if d[i] % 2 != 0:
			flag = 1
	if flag == 1:
		print('NO')
		continue
	s = []
	for i in d:
		s.extend([i] * (d[i] // 2))
	s = list(sorted(s))
	area = s[0] * s[len(s) - 1]
	for i in range(0, len(s) // 2):
		if area != s[i] * s[len(s) - 1 - i]:
			flag = 1
	if flag == 1:
		print('NO')
	else:
		print('YES')


from sys import stdin
input = stdin.readline
for i in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	i = 0
	j = len(a) - 1
	if a[0] != a[1] or a[-1] != a[-2]:
		print('NO')
		continue
	t = a[0] * a[-1]
	while i < j:
		i += 2
		j -= 2
		if a[i] != a[i + 1] or a[j] != a[j - 1] or a[j] * a[i] != t:
			print('NO')
			break
	else:
		print('YES')


q = int(input())
for _ in range(q):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	area = A[0] * A[-1]
	for i in range(n):
		if A[2 * i] != A[2 * i + 1] or A[4 * n - 2 * i - 1] != A[4 * n - 2 * i - 2]:
			ans = 'NO'
			break
		if area != A[2 * i] * A[4 * n - 2 * i - 1]:
			ans = 'NO'
			break
	else:
		ans = 'YES'
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	x = 'YES'
	p = a[0] * a[-1]
	for i in range(2 * n):
		if a[i] * a[-(1 + i)] != p:
			x = 'NO'
			break
	if x == 'YES':
		for i in range(0, 4 * n, 2):
			if a[i] != a[i + 1]:
				x = 'NO'
				break
	print(x)


q = int(input())
ans = ''
for i in range(1, q + 1):
	n = int(input())
	L = list(map(int, input().split()))
	L.sort()
	b = True
	for j in range(1, len(L), 2):
		if L[j] - L[j - 1] != 0:
			ans += 'NO\n'
			b = False
			break
	if not b:
		continue
	A = []
	for j in range(0, n * 4, 2):
		A.append(L[j])
	p = A[0] * A[-1]
	b = True
	for j in range(n):
		if A[j] * A[n * 2 - j - 1] != p:
			ans += 'NO\n'
			b = False
			break
	if b:
		ans += 'YES\n'
print(ans.rstrip())


q = int(input())
for _ in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	l1 = []
	l2 = []
	for i in range(len(l)):
		if i % 2 == 0:
			l2.append(l[i])
		else:
			l1.append(l[i])
	x = 0
	for i in range(len(l) // 2):
		if l1[i] != l2[i]:
			x = 1
			print('NO')
			break
	if x == 0:
		mus = l1[0] * l1[len(l1) - 1]
		y = 0
		for i in range(1, len(l1) - 1):
			if l1[i] * l1[len(l1) - 1 - i] != mus:
				print('NO')
				y = 1
				break
		if y == 0:
			print('YES')


import sys, math, bisect
from collections import defaultdict

def pow(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res *= a
		a *= a
		b >>= 1
	return res

def powmod(a, b, m):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a *= a
		b >>= 1
	return res

def inv(a, m):
	return powmod(a, m - 2, m)

def hasodd(lst):
	for x in lst:
		if x % 2 == 1:
			return True
	return False

def alleq(lst):
	if len(list(set(lst))) == 1:
		return True
	return False
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(s) for s in input().split(' ')]
	dic = defaultdict(int)
	for x in a:
		dic[x] += 1
	if hasodd(list(dic.values())):
		print('NO')
		continue
	for key in dic:
		dic[key] //= 2
	temp = []
	for i in sorted(dic):
		while dic[i] > 0:
			temp.append(i)
			dic[i] -= 1
	tempo = []
	ini = 0
	fin = 2 * n - 1
	while ini < fin:
		tempo.append(temp[ini] * temp[fin])
		ini += 1
		fin -= 1
	if alleq(tempo):
		print('YES')
	else:
		print('NO')


q = int(input())
import collections
for qq in range(q):
	n = int(input())
	dat = list(map(int, input().split()))
	c = collections.Counter(dat)
	can = True
	l = []
	for k in c:
		if c[k] % 2 != 0:
			can = False
		for j in range(c[k] // 2):
			l.append(k)
	if can is False:
		print('NO')
		continue
	l.sort()
	l = collections.deque(l)
	menseki = l.pop() * l.popleft()
	for i in range(n - 1):
		t = l.pop() * l.popleft()
		if t != menseki:
			can = False
	print('YES' if can else 'NO')


from sys import setcheckinterval, stdin
setcheckinterval(1000)

def iin():
	return int(stdin.readline())

def lin():
	return list(map(int, stdin.readline().split()))
for _ in range(iin()):
	n = iin()
	a = lin()
	dc = {}
	for i in a:
		try:
			dc[i] += 1
		except:
			dc[i] = 1
	ans = [[dc[i], i] for i in dc]
	ans.sort()
	l = len(ans)
	if l == 1:
		print('YES')
	elif l == 2 and ans[0][0] == ans[1][0]:
		print('YES')
	else:
		a.sort()
		sol = set()
		for i in range(0, 2 * n, 2):
			if a[i] != a[i + 1] or a[-1 - i] != a[-i - 2]:
				print('NO')
				break
			sol.add(a[i] * a[-i - 1])
		else:
			if len(sol) > 1:
				print('NO')
			else:
				print('YES')


import sys
from collections import defaultdict
input = lambda : sys.stdin.readline().rstrip()
for q in range(int(input())):
	n = int(input())
	arr = sorted(map(int, input().split()))
	d = []
	for i in range(0, n * 2, 2):
		if arr[i] == arr[i + 1] and arr[-i - 1] == arr[-i - 2]:
			d.append(arr[i] * arr[-i - 1])
		else:
			d = [-1, -2]
	if len(set(d)) == 1:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	m = 4 * n
	l = list(map(int, input().split()))
	l.sort()
	flag = 1
	ar = l[0] * l[m - 1]
	for j in range(0, 2 * n, 2):
		if l[j] * l[m - j - 1] == ar:
			flag = 1
		else:
			flag = 0
			break
	if flag == 1:
		for j in range(0, 4 * n):
			if j % 2 == 1:
				if l[j] == l[j - 1]:
					flag = 1
				else:
					flag = 0
					break
	if flag == 0:
		print('NO')
	else:
		print('YES')


from collections import Counter
q = int(input())
for _ in range(q):
	n = int(input())
	sticks = list(map(int, input().split()))
	csticks = Counter(sticks)
	ruim = False
	for v in csticks.values():
		if v % 2 == 1:
			ruim = True
			break
	if not ruim:
		sticks = sorted(sticks)
		i = 0
		j = len(sticks) - 1
		desired = sticks[i] * sticks[j]
		i += 1
		j -= 1
		while i < j:
			if sticks[i] * sticks[j] != desired:
				ruim = True
				break
			i += 1
			j -= 1
	print('NO' if ruim else 'YES')


import math
q = int(input())
for blah in range(q):
	n = int(input())
	list1 = input().split()
	for i in range(4 * n):
		list1[i] = int(list1[i])
	list1.sort()
	arr = []
	bad = False
	for i in range(2 * n):
		if list1[2 * i] != list1[2 * i + 1]:
			bad = True
		else:
			arr.append(list1[2 * i])
	if not bad:
		val = arr[0] * arr[2 * n - 1]
		for i in range(n):
			if arr[i] * arr[2 * n - 1 - i] != val:
				bad = True
	if bad:
		print('NO')
	else:
		print('YES')


q = int(input())
for i in range(q):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	s = a[0] * a[4 * n - 1]
	f = 1
	for j in range(0, 2 * n, 2):
		if a[j] * a[4 * n - 1 - j] != s or a[j] != a[j + 1] or a[4 * n - 1 - j] != a[4 * n - 2 - j]:
			f = 0
			break
	if f == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	q = 0
	area = a[0] * a[len(a) - 1]
	for j in range(len(a) // 4):
		lf = j * 2
		rg = 4 * n - j * 2 - 1
		if a[lf] != a[lf + 1] or a[rg] != a[rg - 1] or a[lf] * a[rg] != area:
			q = 1
			print('NO')
			break
	if q == 0:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	a = max(l) * min(l)
	d = {}
	flag = 'YES'
	for i in l:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	for i in d:
		if d[i] % 2 != 0 or a % i != 0 or (a // i in d and d[i] != d[a // i]) or (a // i not in d):
			flag = 'NO'
	print(flag)


for qw in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	arr.sort()
	flag = True
	arrtemp = []
	for i in range(0, 4 * n, 2):
		if arr[i] != arr[i + 1]:
			flag = False
			break
		arrtemp.append(arr[i])
	if not flag:
		print('NO')
		continue
	ans = arrtemp[0] * arrtemp[-1]
	for i in range(n):
		if ans != arrtemp[i] * arrtemp[-1 * (i + 1)]:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


q = int(int(input()))
for i in range(q):
	n = int(input())
	l = list(map(int, input().split()))[:4 * n]
	l.sort()
	c = 0
	area = l[0] * l[4 * n - 1]
	for i in range(n):
		if l[2 * i] == l[2 * i + 1]:
			if l[4 * n - 2 * i - 1] == l[4 * n - 2 * i - 2]:
				if l[2 * i] * l[4 * n - 2 * i - 2] == area:
					c += 1
	if c == n:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	n = 4 * n
	a = [int(x) for x in input().split()]
	a.sort()
	i = 0
	j = n - 1
	z = a[0] * a[-1]
	f = 1
	while i < j:
		x = a[i] * a[j]
		if a[i] != a[i + 1] or x != z or a[j] != a[j - 1]:
			f = 0
			break
		i += 2
		j -= 2
	if f != 0:
		print('YES')
	else:
		print('NO')


def solve(a, n):
	count = {}
	for i in a:
		count[i] = count.get(i, 0) + 1
	for k in count:
		if count[k] % 2 == 1:
			return 'NO'
	i = 0
	j = len(a) - 1
	area = a[i] * a[j]
	while i < j:
		if a[i] * a[j] != area:
			return 'NO'
		i += 1
		j -= 1
	return 'YES'
q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	print(solve(a, n))


from collections import Counter
import math

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

def getvalue():
	return int(input())

def getstring():
	return input()
for _ in range(int(input())):
	n = getvalue()
	l = getlist()
	l.sort()
	(left, right) = (0, len(l) - 1)
	ans = 'YES'
	te = 0
	while left < right:
		a = []
		a.append(l[left])
		left += 1
		a.append(l[left])
		left += 1
		a.append(l[right])
		right -= 1
		a.append(l[right])
		right -= 1
		if a[0] != a[1] or a[-1] != a[-2]:
			ans = 'NO'
			break
		if not te:
			area = a[0] * a[-1]
			te = not te
		elif area != a[0] * a[-1]:
			ans = 'NO'
			break
	print(ans)


from sys import stdin
import math
testcases = True
from collections import Counter
if testcases:
	t = int(stdin.readline())
	while t:
		n = int(stdin.readline())
		a = list(map(int, stdin.readline().split()))
		c = Counter(a)
		a = sorted(list(set(a)))
		area = a[0] * a[-1]
		if a[0] == a[-1]:
			res = c[a[0]] // 4
		else:
			res = min(c[a[0]] // 2, c[a[-1]] // 2)
		for i in range(1, math.ceil(len(a) / 2)):
			if i == len(a) - 1 - i and area == a[i] * a[i]:
				res += c[a[i]] // 4
			elif area == a[i] * a[len(a) - 1 - i]:
				res += min(c[a[i]] // 2, c[a[len(a) - i - 1]] // 2)
		if res == n:
			print('YES')
		else:
			print('NO')
		t -= 1
else:
	n = int(stdin.readline())
	(a, b) = map(int, stdin.readline().split())


def solve(a, n):
	s = a[0] * a[-1]
	for i in range(n):
		l = i * 2
		r = 4 * n - 1 - l
		if a[l] != a[l + 1] or a[r] != a[r - 1]:
			return 'NO'
		if a[l] * a[r] != s:
			return 'NO'
	return 'YES'
for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	print(solve(a, n))


q = int(input())
for _ in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	k = a[-1] * a[0]
	while a != []:
		if a[-1] == a[-2] and a[0] == a[1]:
			t = a[-1] * a[0]
			if k == t:
				a.pop(-1)
				a.pop(-1)
				a.pop(0)
				a.pop(0)
			else:
				print('NO')
				break
		else:
			print('NO')
			break
	if a == []:
		print('YES')


I = input
for _ in range(int(I())):
	flag = True
	n = int(I())
	sticks = sorted(list(map(int, I().split())))
	ans = sticks[0] * sticks[4 * n - 1]
	for i in range(2 * n):
		if sticks[2 * i] * sticks[4 * n - 1 - 2 * i] != ans or sticks[2 * i] != sticks[2 * i + 1] or sticks[4 * n - 1 - 2 * i] != sticks[4 * n - 2 - 2 * i]:
			print('NO')
			flag = False
			break
	if flag:
		print('YES')


from itertools import combinations
from collections import Counter
for _ in range(int(input())):
	n = int(input())
	cnt = Counter(map(int, input().split()))
	res = False
	if not any((e & 1 for e in cnt.values())):
		l = sorted(set(cnt.keys()))
		n = len(l)
		p = l[0] * l[-1]
		ans = all((p % l[i] == 0 and cnt[l[i]] == cnt.get(p // l[i], 0) for i in range(n // 2)))
		if n & 1:
			ans &= cnt[l[n // 2]] % 4 == 0 and p == l[n // 2] ** 2
		res = ans
	print('YES' if res else 'NO')


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	cnt = [0] * 10001
	for _ in a:
		cnt[_] += 1
	s = a[0] * a[-1]
	ok = True
	for u in a:
		if cnt[u] == 0:
			continue
		if s % u != 0 or cnt[s // u] == 0:
			ok = False
			break
		cnt[u] -= 1
		cnt[s // u] -= 1
	if sum(cnt) != 0:
		ok = False
	for i in range(0, 4 * n, 2):
		if a[i] != a[i + 1]:
			ok = False
	print('YES' if ok else 'NO')


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	sticks = sorted([int(x) for x in input().split()])
	area = sticks[0] * sticks[-1]
	success = 1
	for i in range(0, 4 * n, 2):
		if sticks[i] != sticks[i + 1] or sticks[i] * sticks[4 * n - i - 1] != area:
			success = 0
			break
	print('YES' if success else 'NO')


for i in range(int(input())):
	n = int(input())
	a = [int(s) for s in input().split()]
	a.sort()
	k = a[0] * a[-1]
	while True:
		if len(a) > 0:
			if a[0] * a[-1] == k and a[0] == a[1] and (a[-2] == a[-1]):
				a = a[2:-2]
			else:
				print('NO')
				break
		else:
			print('YES')
			break


def main():
	T = int(input())
	t = 0
	while t < T:
		n = int(input())
		ls = [int(i) for i in input().split()]
		ok = key(ls)
		if ok:
			print('YES')
		else:
			print('NO')
		t += 1

def key(ls):
	ls = sorted(ls)
	n = len(ls) // 4
	sz = ls[0] * ls[4 * n - 1]
	for i in range(n):
		if ls[i * 2] != ls[2 * i + 1] or ls[4 * n - 1 - 2 * i] != ls[4 * n - 2 * i - 2] or ls[i * 2] * ls[4 * n - 2 * i - 1] != sz:
			return False
	return True
main()


q = int(input())
for _ in range(q):
	n = int(input())
	y = list(map(int, input().split()))
	y = sorted(y)
	area = y[0] * y[-1]
	area2 = y[1] * y[-2]
	if area == area2 and y[0] == y[1] and (y[-1] == y[-2]):
		i = 2
		j = 4 * n - 3
		while i < j:
			if y[i] * y[j] == area and y[i + 1] * y[j - 1] == area and (y[i] == y[i + 1]) and (y[j] == y[j - 1]):
				i += 2
				j -= 2
			else:
				break
		if i >= j:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import sys
from collections import defaultdict
import math

def main():
	q = int(input())
	for _ in range(q):
		n = int(input())
		a = list(map(int, input().split()))
		d = defaultdict(int)
		for val in a:
			d[val] += 1
		parity = True
		for val in d.values():
			if val % 2 != 0:
				parity = False
				break
		if not parity:
			print('NO')
		else:
			vals = list(d.keys())

			def check():
				x = a[0]
				for i in range(len(vals)):
					area = vals[i] * x
					ok = True
					for (k, v) in d.items():
						if area % k != 0:
							ok = False
							break
						d2 = area // k
						if d2 == k:
							if v % 4 != 0:
								ok = False
								break
						elif d2 not in d or d[d2] != v:
							ok = False
							break
					if ok:
						return True
				return False
			print('YES' if check() else 'NO')
main()


t = int(input())
for u in range(t):
	n = int(input())
	n = n * 4
	x = list(map(int, input().split()))
	x.sort()
	i = 0
	f = []
	while i < n:
		if x[i] == x[i + 1]:
			f += [x[i]]
			i += 2
		else:
			break
	ans = 'YES'
	if len(f) == n // 2:
		ar = f[0] * f[-1]
		i = 0
		j = len(f) - 1
		for k in range(n // 4):
			if f[i] * f[j] != ar:
				ans = 'NO'
				break
			else:
				i += 1
				j -= 1
	else:
		ans = 'NO'
	print(ans)


from collections import Counter
q = int(input())
for _ in range(0, q):
	n = int(input())
	A = list(map(int, input().split()))
	X = Counter(A)
	ok = 1
	for x in X:
		if X[x] % 2:
			ok = 0
		X[x] = X[x] // 2
	A = sorted(X.elements())
	x = None
	for i in range(0, len(A) // 2):
		if x is None:
			x = A[i] * A[-i - 1]
		elif A[i] * A[-i - 1] != x:
			ok = 0
	print('YES' if ok else 'NO')


t = int(input())
for _ in range(t):
	n = int(input())
	n = 4 * n
	arr = list(map(int, input().split()))
	arr.sort()
	start = 0
	end = n - 1
	flag = True
	area = arr[start] * arr[end]
	while start < end:
		if arr[start] != arr[start + 1] or arr[end] != arr[end - 1]:
			flag = False
			break
		temp_area = arr[start] * arr[end]
		if temp_area != area:
			flag = False
			break
		start += 2
		end -= 2
	if flag:
		print('YES')
	else:
		print('NO')


res = []
for _ in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	ans = l[0] * l[-1]
	result = 'YES'
	for i in range(0, 2 * n, 2):
		if l[i] * l[-(i + 1)] != ans or l[i] != l[i + 1] or l[-(i + 1)] != l[-(i + 2)]:
			result = 'NO'
	res.append(result)
for i in res:
	print(i)


from collections import defaultdict
q = int(input())
ans = []
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	d = defaultdict(int)
	for i in range(n * 4):
		d[a[i]] += 1
	l = []
	f = False
	for k in set(a):
		if d[k] % 2 == 1:
			f = True
		for j in range(d[k] // 2):
			l.append(k)
	if f:
		ans.append('NO')
		continue
	l.sort()
	aaa = 0
	c = 0
	for i in range(n):
		if aaa == 0 or l[i] * l[-i - 1] == aaa:
			aaa = l[i] * l[-i - 1]
			c += 1
	if c == n:
		ans.append('YES')
	else:
		ans.append('NO')
for i in range(q):
	print(ans[i])


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	c = Counter(map(int, input().split()))
	p = sorted(list(c.keys()))
	a = -1
	for i in p:
		if c[i] % 2:
			break
	else:
		for i in p:
			c[i] //= 2
		a = []
		for i in p:
			for j in range(c[i]):
				a.append(i)
		area = -1
		for i in range(n):
			if area == -1:
				area = a[i] * a[2 * n - i - 1]
			elif area != a[i] * a[2 * n - i - 1]:
				break
		else:
			print('YES')
			continue
	print('NO')


n = int(input())
for i in range(n):
	k = int(input())
	a = [int(p) for p in input().split()]
	a.sort()
	prod = a[0] * a[-1]
	flag = 1
	for j in range(0, len(a) // 2, 2):
		c = -j - 1
		d = j + 1
		e = -j - 2
		if prod != a[j] * a[c] or a[j] != a[d] or a[c] != a[e]:
			flag = 0
			break
	if flag:
		print('YES')
	else:
		print('NO')


num = int(input())
for i in range(num):
	rectangles = int(input())
	tmp = input().split()
	all_sticks = []
	for i in range(rectangles * 4):
		all_sticks.append(int(tmp[i]))
	all_sticks.sort()
	pairs = []
	is_NO = False
	for i in range(rectangles):
		if all_sticks[i * 2] != all_sticks[i * 2 + 1]:
			is_NO = True
			break
		if all_sticks[rectangles * 4 - 1 - i * 2] != all_sticks[rectangles * 4 - 1 - (i * 2 + 1)]:
			is_NO = True
			break
		pairs.append(all_sticks[i * 2] * all_sticks[rectangles * 4 - 1 - i * 2])
	for i in range(len(pairs)):
		if i == 0:
			continue
		if pairs[i] != pairs[i - 1]:
			is_NO = True
	if len(pairs) != rectangles:
		is_NO = True
	if is_NO:
		print('NO')
	else:
		print('YES')


test = int(input())
for i in range(test):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	c = 0
	for i in range(0, 4 * n, 2):
		if l[i] != l[i + 1]:
			c = 1
	if c == 1:
		print('NO')
	else:
		pro = l[0] * l[4 * n - 1]
		d = 0
		for j in range(0, 2 * n, 2):
			if pro != l[j] * l[4 * n - j - 1]:
				d = 1
		if d == 1:
			print('NO')
		else:
			print('YES')


numberOfQueries = int(input())
for _ in range(numberOfQueries):
	numberOfRects = int(input())
	sides = list(map(int, input().split()))
	sides.sort()
	area = sides[0] * sides[4 * numberOfRects - 1]
	index = 0
	canFormRects = True
	for _ in range(numberOfRects):
		if sides[index] != sides[index + 1] or sides[4 * numberOfRects - index - 1] != sides[4 * numberOfRects - index - 2] or sides[index] * sides[4 * numberOfRects - 1 - index] != area:
			canFormRects = False
			break
		index += 2
	print('YES' if canFormRects else 'NO')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().rstrip().split(' ')))
	l.sort()
	le = len(l)
	le = le // 4
	if n == 1:
		if l[0] != l[1] or l[2] != l[3]:
			print('NO')
		else:
			print('YES')
	else:
		ma = l[0] * l[-1]
		r = 'YES'
		for i in range(1, le):
			if l[2 * i] * l[le * 4 - 1 - 2 * i] != ma:
				r = 'NO'
				break
			if l[2 * i] != l[2 * i + 1] or l[le * 4 - 1 - 2 * i] != l[le * 4 - 2 - 2 * i]:
				r = 'NO'
				break
		if l[0] != l[1] or l[-2] != l[-1]:
			r = 'NO'
		print(r)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	l = 2 * n
	s = []
	flag = True
	for i in range(0, l, 2):
		if a[i] != a[i + 1] or a[4 * n - 1 - i] != a[4 * n - 2 - i]:
			flag = False
			break
		s.append(a[i] * a[4 * n - 1 - i])
	print('YES' if flag and len(set(s)) == 1 else 'NO')


def solve(n, a):
	dic = {}
	for aa in a:
		dic[aa] = dic.get(aa, 0) + 1
	l = []
	for key in dic.keys():
		value = dic[key]
		if value & 1:
			print('NO')
			return
		else:
			value //= 2
		l += [key] * value
	l.sort()
	area = l[0] * l[-1]
	for i in range(n):
		if l[i] * l[-i - 1] != area:
			print('NO')
			return
	print('YES')
q = int(input())
for _ in range(q):
	n = int(input())
	a = [int(x) for x in input().split()]
	solve(n, a)


import sys
import math
import collections
import bisect
import string

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	n = int(input())
	arr = get_list()
	arr.sort()
	poss = True
	area = arr[0] * arr[-1]
	start = 1
	end = 4 * n - 2
	while start < end:
		if arr[start] * arr[end] == area:
			start += 1
			end -= 1
		else:
			poss = False
			break
	if poss == False:
		print('NO')
		continue
	i = 0
	while i < 4 * n:
		if arr[i] == arr[i + 1]:
			i += 2
			continue
		else:
			poss = False
			break
	if poss:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = {}
	flag = 0
	flag2 = 0
	for i in a:
		if i in m:
			m[i] += 1
		else:
			m[i] = 1
	for i in m:
		if m[i] % 2 == 0:
			flag = 1
		else:
			flag = 0
			break
	a = set(a)
	a = list(a)
	for i in m:
		if m[i] / 2 > 1:
			for j in range(int(m[i] / 2) - 1):
				a.append(i)
	a = sorted(a)
	temp = a[0] * a[len(a) - 1]
	if len(a) % 2 == 0:
		for i in range(int(len(a) / 2)):
			if a[i] * a[len(a) - i - 1] == temp:
				flag2 = 1
			else:
				flag2 = 0
				break
	elif len(a) == 1:
		flag2 = 1
	else:
		flag2 = 0
	if flag == 1 and flag2 == 1:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	a = [int(s) for s in input().split()]
	a.sort()
	k = a[0] * a[-1]
	s = 0
	e = 4 * n - 1
	while s < e:
		if not (a[s] * a[e] == k and a[s] == a[s + 1] and (a[e] == a[e - 1])):
			print('NO')
			break
		s += 2
		e -= 2
	else:
		print('YES')


q = int(input())
B = []
for m in range(q):
	n = int(input())
	s = map(int, input().split())
	a = list(s)
	a.sort()
	square = a[0] * a[4 * n - 1]
	e = True
	for i in range(0, 2 * n, +2):
		if a[i] == a[i + 1] and a[4 * n - 1 - i] == a[4 * n - 2 - i] and (a[i] * a[4 * n - 1 - i] == square):
			e = True
		else:
			e = False
			break
	if e:
		B.append('YES')
	else:
		B.append('NO')
for i in range(q):
	print(B[i])


from sys import stdin, stdout
import math
T = int(input())
for i in range(T):
	N = int(input())
	arr = [int(x) for x in stdin.readline().split()]
	freq = {}
	for j in range(4 * N):
		num = arr[j]
		if num not in freq:
			freq[num] = 1
		else:
			freq[num] += 1
	k = []
	for key in freq:
		k.append(key)
	k.sort()
	if len(k) == 1:
		if freq[k[0]] % 4 == 0:
			print('YES')
		else:
			print('NO')
		continue
	flag = 0
	area = k[0] * k[-1]
	left = 0
	right = len(k) - 1
	while left <= right:
		A = freq[k[left]]
		B = freq[k[right]]
		if k[left] * k[right] != area:
			print('NO')
			flag = 1
			break
		elif A != B or A % 2 == 1 or B % 2 == 1:
			print('NO')
			flag = 1
			break
		left += 1
		right -= 1
	if flag == 0:
		print('YES')


q = int(input())
for _ in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = 'YES'
	b = a[:2 * n]
	c = a[2 * n:]
	c = c[::-1]
	area = a[0] * a[-1]
	for i in range(n):
		if b[i * 2] != b[i * 2 + 1] or c[i * 2] != c[i * 2 + 1] or b[i * 2] * c[i * 2] != area:
			ans = 'NO'
			break
	print(ans)


q = int(input())
for _ in range(q):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	area = a[0] * a[4 * n - 1]
	flag = True
	for i in range(n):
		left = 2 * i
		right = 4 * n - 2 * (i + 1)
		if a[left] != a[left + 1] or a[right] != a[right + 1] or a[left] * a[right] != area:
			flag = False
	if flag:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	m = list(map(int, input().split()))
	m = sorted(m)
	p = m[0] * m[len(m) - 1]
	h = 0
	for j in range(0, len(m) // 2, 2):
		if m[j] * m[len(m) - j - 1] != p or m[j] != m[j + 1] or m[len(m) - j - 1] != m[len(m) - j - 2]:
			h = 1
	if h == 1:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.readline

def equal_rectangle(n, l):
	a = l[0] * l[-1]
	for i in range(0, 2 * n, 2):
		if l[i] != l[i + 1] or l[-(i + 1)] != l[-(i + 2)] or l[i] * l[-(i + 1)] != a:
			return 'NO'
	return 'YES'
for _ in range(int(input())):
	n = int(input())
	l = sorted(map(int, input().split()))
	print(equal_rectangle(n, l))


def check(n, a):
	a.sort()
	area = a[0] * a[-1]
	i = 0
	while i < 2 * n:
		if a[i] != a[i + 1]:
			return False
		if a[-(i + 1)] != a[-(i + 2)]:
			return False
		if a[i] * a[-(i + 1)] != area:
			return False
		i += 2
	return True
q = int(input())
for i in range(q):
	n = int(input())
	a = [int(x) for x in input().split()]
	if check(n, a):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	lens = 4 * int(input())
	arrs = [int(x) for x in input().split()]

	def validate(arrs):
		arrs = sorted(arrs)
		for i in range(0, lens, 2):
			if arrs[i] != arrs[i + 1]:
				return 'NO'
		prod = arrs[0] * arrs[-1]
		for i in range(lens // 2):
			if arrs[i] * arrs[-i - 1] != prod:
				return 'NO'
		return 'YES'
	print(validate(arrs))


q = int(input())
for i in range(q):
	w = int(input())
	e = list(map(int, input().split()))
	r = sorted(e)
	t = []
	for i in range(0, 4 * w, 2):
		t.append(r[i] * r[4 * w - 1 - i])
	if len(list(set(t))) == 1 and r[::2] == r[1::2]:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	a = [0] + sorted([int(x) for x in input().split()])
	s = a[1] * a[-1]
	counter = 0
	for i in range(1, 2 * n + 1):
		if a[i] != a[i - 1]:
			if counter % 2 == 1:
				print('NO')
				break
			counter = 1
		else:
			counter += 1
		if a[i] * a[-i] != s:
			print('NO')
			break
	else:
		print('YES')


T = int(input())
for t in range(T):
	n = int(input())
	A = [int(i) for i in input().split()]
	A.sort()
	ok = 1
	areas = []
	left = 0
	right = 4 * n - 1
	for i in range(n):
		l1 = left
		l2 = left + 1
		r1 = right
		r2 = right - 1
		if not (A[l1] == A[l2] and A[r1] == A[r2]):
			ok = 0
		areas.append(A[l1] * A[r1])
		left += 2
		right -= 2
	if len(set(areas)) == 1 and ok:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	x = list(map(int, input().strip().split()))
	b = True
	for j in x:
		if x.count(j) % 2 != 0:
			print('NO')
			b = False
			break
	if b:
		x.sort()
		c = 0
		y = x[0] * x[int(len(x)) - 1]
		for j in range(int(len(x) / 2)):
			if x[j] * x[int(len(x)) - j - 1] == y:
				c = c + 1
		if c == len(x) / 2:
			print('YES')
		else:
			print('NO')


x = int(input())
while x > 0:
	y = int(input())
	stu = [int(x) for x in input().split()]
	count = [0] * 10001
	final = []
	flag = 0
	maxi = 0
	stu.sort()
	l = len(stu)
	for i in range(0, l):
		count[stu[i]] += 1
		if stu[i] > maxi:
			maxi = stu[i]
	for j in range(0, maxi + 1):
		if count[j] % 2 != 0:
			flag = 0
			break
		else:
			flag = 1
	if flag == 1:
		area = stu[0] * stu[l - 1]
		for k in range(1, l // 2):
			if stu[k] * stu[l - 1 - k] != area:
				flag = 0
				break
			else:
				flag = 1
	if flag == 1:
		print('YES')
	else:
		print('NO')
	x = x - 1


t = int(input())
for _ in range(t):
	c = []
	k = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	c = []
	i = 1
	while i < 4 * k:
		c.append(a[i] * a[4 * k - i])
		c.append(a[i - 1] * a[4 * k - i - 1])
		i = i + 2
	if c.count(c[0]) == len(c):
		print('YES')
	else:
		print('NO')


from collections import deque
import sys, collections

def inp():
	return sys.stdin.readline().strip()
for _ in range(int(inp())):
	n = int(inp())
	a = list(map(int, inp().split()))
	d = collections.Counter(a)
	f = True
	for i in d:
		if d[i] % 2 != 0:
			f = False
	a.sort()
	l = 0
	r = 4 * n - 1
	area = a[0] * a[-1]
	while l < r:
		if a[l] * a[r] != area:
			f = False
		l += 2
		r -= 2
	if f:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	dic = {}
	for x in a:
		if x in dic.keys():
			dic[x] += 1
		else:
			dic[x] = 1
	pairs = []
	good = True
	for x in sorted(dic.keys()):
		if dic[x] % 2 == 1:
			good = False
			break
		pairs.extend([x] * (dic[x] // 2))
	if not good:
		print('NO')
		continue
	l = 0
	r = len(pairs) - 1
	res = pairs[l] * pairs[r]
	while l < r:
		if pairs[l] * pairs[r] != res:
			good = False
			break
		l += 1
		r -= 1
	if good:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	s = set()
	n *= 4
	f = 1
	for i in range(0, n // 2, 2):
		if a[i] == a[i + 1] and a[-i - 2] == a[-i - 1]:
			s.add(a[i] * a[-i - 1])
		else:
			f = 0
			break
	if f and len(s) == 1:
		print('YES')
	else:
		print('NO')


q = int(input())
tsypko_ne_pidaras = 'NO'
tsypko_pidaras = 'YES'
for i in range(q):
	n = int(input()) * 4
	a = list(map(int, input().split()))
	a = sorted(a)
	ans = tsypko_pidaras
	for i in range(0, n, 2):
		if a[i] != a[i + 1]:
			ans = tsypko_ne_pidaras
	x = set()
	for i in range(0, n // 2, 2):
		x.add(a[i] * a[n - i - 1])
	if len(x) != 1:
		ans = tsypko_ne_pidaras
	print(ans)


n = int(input())
for i in range(n):
	z = int(input())
	y = list(map(int, input().split()))
	y.sort()
	temp = y[0] * y[-1]
	status = True
	for j in range(0, len(y) // 2, 2):
		if y[j] * y[-j - 1] == temp:
			if y[j] == y[j + 1] and y[-1 - j] == y[-j - 2]:
				status = True
			else:
				status = False
				break
		else:
			status = False
			break
	if status:
		print('YES')
	else:
		print('NO')


from collections import Counter
q = int(input())
for _ in range(q):
	n = int(input())
	A = Counter([int(x) for x in input().split()])
	if any([b % 2 for (a, b) in A.items()]):
		print('NO')
		continue
	B = sorted([list(a) for a in A.items()])
	area = B[0][0] * B[-1][0]
	(i, j) = (0, len(B) - 1)
	good = True
	while i <= j:
		B[i][1] -= 2
		B[j][1] -= 2
		good &= B[i][0] * B[j][0] == area
		if B[i][1] == 0:
			i += 1
		if B[j][1] == 0:
			j -= 1
	if good:
		print('YES')
	else:
		print('NO')


MAXI = 10001
count = [0 for i in range(MAXI)]
q = int(input())
for t in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(MAXI):
		count[i] = 0
	for i in range(4 * n):
		count[a[i]] += 1
	ok = False
	a_sorted = sorted(a)
	my_max = a_sorted[-1]
	iter_list = [i for i in range(MAXI) if count[i] > 0 and i < my_max]
	if count[my_max] % 2 == 0:
		for i in iter_list:
			all_ok = True
			if count[i] != count[my_max]:
				continue
			area = i * my_max
			for j in iter_list:
				if j == i or count[j] == 0:
					continue
				if area % j != 0:
					all_ok = False
					break
				need = area // j
				if need >= MAXI or count[j] != count[need]:
					all_ok = False
					break
				if j == need and count[j] % 4 != 0:
					all_ok = False
					break
			if all_ok:
				ok = True
				break
	if count[my_max] % 4 == 0 and all((a[0] == e for e in a)):
		ok = True
	print('YES' if ok else 'NO')


q = int(input())

def check(a):
	area = 1
	dp = [0] * (10 ** 4 + 1)
	all_l = set()
	for l in a:
		all_l.add(l)
		dp[l] += 1
	all_l = sorted(list(all_l))
	m = len(all_l)
	area = all_l[0] * all_l[-1]
	for i in range(m):
		if all_l[i] * all_l[-(i + 1)] != area or dp[all_l[i]] != dp[all_l[-(i + 1)]] or dp[all_l[i]] % 2 != 0 or (dp[all_l[i]] % 2 != 0):
			return False
		if all_l[i] == all_l[-(i + 1)] and dp[all_l[i]] % 4 != 0:
			return False
	return True
for i in range(q):
	n = int(input())
	a = [int(s) for s in input().split(' ')]
	if check(a):
		print('YES')
	else:
		print('NO')


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
else:
	_str = str
	str = lambda x=b'': x if type(x) is bytes else _str(x).encode()
from math import ceil, floor, log, sqrt, factorial, pow, pi

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

def fi():
	return float(input())

def si():
	return input()

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

def li():
	return list(mi())

def main():
	q = ii()
	for _ in range(q):
		n = ii()
		a = li()
		a.sort()
		if not (a[0] == a[1] and a[4 * n - 2] == a[4 * n - 1]):
			print('NO')
			continue
		else:
			c = a[0] * a[4 * n - 2]
		pos = True
		for i in range(1, n):
			if not (a[2 * i] == a[2 * i + 1] and a[4 * n - 2 - 2 * i] == a[4 * n - 2 - 2 * i + 1] and (a[2 * i] * a[4 * n - 2 - 2 * i] == c)):
				print('NO')
				pos = False
				break
		if pos == True:
			print('YES')
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 _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		if self.buffer.tell():
			return self.buffer.read()
		return os.read(self._fd, os.fstat(self._fd).st_size)

	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))

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', b' '), 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', b'\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
input = lambda : sys.stdin.readline().rstrip(b'\r\n')
main()


q = int(input())
for i in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	areas = []
	aux = True
	for i in range(0, 2 * n + 1):
		areas.append(l[i] * l[-(i + 1)])
		if l.count(l[i]) % 2 != 0:
			aux = False
			break
	for i in range(len(areas)):
		if areas[i] != areas[0]:
			aux = False
			break
	if aux:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	i = 1
	j = len(a) - 2
	ans = 'YES'
	area = a[0] * a[-1]
	while i < j:
		if a[i] == a[i - 1] and a[j] == a[j + 1] and (a[i] * a[j] == area):
			i += 2
			j -= 2
		else:
			ans = 'NO'
			break
	print(ans)


import sys
import math
import bisect

def solve(A):
	area = A[0] * A[-1]
	i = 0
	j = len(A) - 1
	while i < j:
		if A[i] == A[i + 1] and A[j] == A[j - 1] and (A[i] * A[j] == area) and (A[i + 1] * A[j - 1] == area):
			pass
		else:
			return False
		i += 2
		j -= 2
	return True

def main():
	for _ in range(int(input())):
		n = int(input())
		A = list(map(int, input().split()))
		A.sort()
		if solve(A):
			print('YES')
		else:
			print('NO')
main()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	l = [0] + l
	area = l[1] * l[-1]
	t = True
	for i in range(1, n + 1):
		if l[2 * i - 1] == l[2 * i] and l[4 * n - 2 * i + 1] == l[4 * n - 2 * i + 2] and (l[2 * i] * l[4 * n - 2 * i + 2] == area):
			continue
		else:
			t = False
			break
	if t:
		print('YES')
	else:
		print('NO')


q = int(input())
for j in range(q):
	n = int(input())
	sp = list(map(int, input().split()))
	sp.sort()
	sqrt = sp[4 * n - 1] * sp[0]
	t = True
	for i in range(0, 2 * n, 2):
		if sp.count(sp[i]) % 2 != 0 or sp.count(sp[4 * n - i - 1]) % 2 != 0:
			t = False
			break
		if sp[4 * n - i - 1] * sp[i] != sqrt:
			t = False
			break
	if t == False:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	n *= 4
	a = list(map(int, input().split()))
	a.sort()
	flag = False
	ans = -1
	for i in range(0, n // 2, 2):
		if a[i] != a[i + 1] or a[n - i - 1] != a[n - i - 2]:
			flag = True
			break
		temp = a[i] * a[n - i - 1]
		if ans == -1:
			ans = temp
		elif ans != temp:
			flag = True
			break
	if flag:
		print('NO')
	else:
		print('YES')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		a.sort()
		r = []
		for i in range(n):
			b = (a[i * 2], a[i * 2 + 1], a[i * -2 - 1], a[i * -2 - 2])
			if b[0] != b[1] or b[2] != b[3]:
				r.append(1)
				r.append(2)
			r.append(b[0] * b[2])
		rr.append(YES(len(set(r)) == 1))
	return JA(rr, '\n')
print(main())


def checker(hashmap, n):
	v = hashmap.values()
	for i in v:
		if i % 2 != 0:
			return False
	k = []
	for (j, i) in hashmap.items():
		b = [j] * (i // 2)
		k.extend(b)
	k.sort()
	curr = k[0] * k[-1]
	count = 0
	for i in range(1, len(k) - 1):
		if k[i] * k[len(k) - 1 - i] == curr:
			count = count + 1
	count = count // 2
	count = count + 1
	if count == n:
		return True
	else:
		return False
q = int(input())
for i in range(0, q):
	n = int(input())
	v = list(map(int, input().split()))
	hash_map = {}
	for j in range(0, 4 * n):
		try:
			hash_map[v[j]] = hash_map[v[j]] + 1
		except:
			hash_map[v[j]] = 1
	if checker(hash_map, n):
		print('YES')
	else:
		print('NO')


ll = lambda : list(map(int, input().split()))
testcases = 1
testcases = int(input())
for testcase in range(testcases):
	[n] = ll()
	a = ll()
	fa = {}
	for i in a:
		if i in fa:
			fa[i] += 1
		else:
			fa[i] = 1
	for (key, value) in fa.items():
		if value & 1:
			print('NO')
			break
	else:
		d2 = {}
		for (key1, value1) in fa.items():
			for (key2, value2) in fa.items():
				if key1 == key2 and value1 < 3:
					continue
				else:
					d2[key1 * key2] = d2.get(key1 * key2, 0) + 1
		(mk, mv) = (0, 0)
		for (key, value) in d2.items():
			if value > mv:
				mk = key
				mv = value
		for i in fa.keys():
			try:
				if mk % i == 0:
					if fa[i] == fa[mk // i]:
						continue
				print('NO')
				break
			except:
				print('NO')
				break
		else:
			print('YES')


import collections as cl
for _ in range(int(input())):
	(n, a) = (int(input()), list(sorted(map(int, input().split()))))
	if all([k % 2 == 0 for k in cl.Counter(a).values()]):
		s = a[0] * a[-1]
		i = 2
		j = len(a) - 3
		while i < j:
			if a[i] * a[j] != s:
				print('NO')
				break
			i += 2
			j -= 2
		else:
			print('YES')
	else:
		print('NO')


for _ in ' ' * int(input()):
	a = int(input())
	a -= 1
	b = sorted(map(int, input().split()))
	ans = True
	if b[0] != b[1] or b[-1] != b[-2]:
		print('NO')
	else:
		c = b[0] * b[-1]
		b.pop(0)
		b.pop(0)
		b.pop(-1)
		b.pop(-1)
		for i in range(a):
			if b[0] != b[1] or b[-1] != b[-2] or c != b[0] * b[-1]:
				ans = False
				break
			else:
				b.pop(0)
				b.pop(0)
				b.pop(-1)
				b.pop(-1)
		if ans:
			print('YES')
		else:
			print('NO')


queries = int(input())
for i in range(0, queries):
	n = int(input())
	len_input = input()
	len_input_1 = len_input.split(' ')
	len_array = []
	for i in len_input_1:
		len_array.append(int(i))
	len_array = sorted(len_array)
	len_array_2n = []
	truth = True
	for i in range(0, 4 * n - 1, 2):
		if len_array[i] != len_array[i + 1]:
			truth = False
			print('NO')
			break
		else:
			len_array_2n.append(len_array[i])
	if truth == True:
		product_value = len_array_2n[0] * len_array_2n[2 * n - 1]
		for i in range(1, n):
			if len_array_2n[i] * len_array_2n[2 * n - 1 - i] != product_value:
				truth = False
				break
		if truth == True:
			print('YES')
		else:
			print('NO')


from collections import defaultdict
t = int(input())
for _ in range(t):
	done = False
	sides = list()
	n = int(input())
	a = list(map(int, input().split()))
	sticks = defaultdict(lambda : 0)
	for x in a:
		sticks[x] += 1
	for key in sticks:
		if sticks[key] % 2 == 1:
			print('NO')
			done = True
			break
		else:
			sides.extend([key] * (sticks[key] // 2))
	if done:
		continue
	sosides = sorted(sides)
	area = sosides[0] * sosides[-1]
	for i in range(n):
		if not sosides[i] * sosides[-(i + 1)] == area:
			print('NO')
			done = True
			break
	if done:
		continue
	print('YES')


for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	x = []
	for i in range(len(a)):
		x.append(a[i] * a[len(a) - i - 1])
	if len(set(x)) == 1 and a[::2] == a[1::2]:
		print('YES')
	else:
		print('NO')


from collections import Counter
import math
q = int(input())
for i in range(q):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	d = Counter(a)
	f = 1
	for e in d:
		if d[e] % 2 == 1:
			f = 0
			break
	N = max(a) * min(a)
	a = sorted(list(set(a)))
	for e in a:
		if e <= math.sqrt(N):
			if N % e != 0:
				f = 0
				break
			if d[e] != d[N // e]:
				f = 0
				break
	print('YES' if f else 'NO')


import atexit, io, sys
input_lines = sys.stdin.read().splitlines()
input = iter(input_lines).__next__
out_buffer = io.StringIO()
sys.stdout = out_buffer

@atexit.register
def write():
	sys.__stdout__.write(out_buffer.getvalue())
from itertools import repeat
from collections import Counter

def line():
	return map(int, input().split())
q = int(input())
for _ in repeat(None, q):
	n = int(input())
	a = Counter(line())
	s = max(a) * min(a)
	if all((s % e == 0 and a[s // e] == r and (r % 2 == 0) for (e, r) in a.items())):
		print('YES')
	else:
		print('NO')


q = int(input())
for x in range(q):
	b = True
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	c = a[0] * a[n * 4 - 1]
	for i in range(n * 2):
		if a[i * 2] != a[i * 2 + 1]:
			b = False
	for i in range(n):
		if a[i * 2] * a[n * 4 - 1 - i * 2] != c:
			b = False
	if b:
		print('YES')
	else:
		print('NO')


import collections
q = int(input())
for _ in range(q):
	n = int(input())
	arr = list(map(int, input().split()))
	counter = collections.Counter(arr)
	sz = len(counter)
	if sz == 1:
		print('YES')
	else:
		arr = sorted(arr)
		i = 0
		j = len(arr) - 1
		if counter.get(arr[i]) != counter.get(arr[j]) or counter.get(arr[i]) % 2 == 1:
			print('NO')
		else:
			sq = arr[i] * arr[j]
			i += 1
			j -= 1
			yes = True
			while i < j:
				if arr[i] * arr[j] != sq:
					yes = False
					break
				if counter.get(arr[i]) != counter.get(arr[j]) or counter.get(arr[i]) % 2 == 1:
					yes = False
					break
				i += 1
				j -= 1
			if yes:
				print('YES')
			else:
				print('NO')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	const = arr[0] * arr[4 * n - 1]
	i = 0
	j = 4 * n - 1
	flag = 0
	while i < j:
		if const != arr[i] * arr[j] or arr[i] != arr[i + 1] or arr[j] != arr[j - 1]:
			print('NO')
			flag = 1
			break
		i += 2
		j -= 2
	if flag == 0:
		print('YES')


import math
q = int(input())
for _ in range(q):
	n = int(input())
	p = list(map(lambda x: int(x), input().split()))
	p.sort()
	area = p[-1] * p[0]
	l = 0
	r = 4 * n - 1
	correct = True
	while r > l:
		if p[r] * p[l] != area or p[r] != p[r - 1] or p[l] != p[l + 1]:
			correct = False
			break
		r -= 2
		l += 2
	print('YES' if correct else 'No')


from collections import Counter
q = int(input())
for i in range(q):
	n = int(input())
	flag = 0
	inp = list(map(int, input().split()))
	c = Counter(inp)
	for i in c.values():
		if i % 2 == 1:
			flag = 1
			print('NO')
			break
	if flag == 0:
		x = list(c.keys())
		x.sort()
		mul = x[0] * x[-1]
		k = len(x)
		start = 0
		end = k - 1
		while start <= end:
			if x[start] * x[end] != mul:
				flag = 1
				print('NO')
				break
			else:
				c[x[start]] -= 2
				c[x[end]] -= 2
				if c[x[start]] == 0:
					start += 1
				if c[x[end]] == 0:
					end -= 1
		if flag == 0:
			print('YES')


q = int(input())
for i in range(q):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	d = dict()
	answ = 'YES'
	for j in range(2 * n):
		d[a[j] * a[-j - 1]] = d.get(a[j] * a[-j - 1], 0) + 1
		if len(d) > 1 or a[2 * j + 1] != a[2 * j]:
			answ = 'NO'
			break
	print(answ)


q = int(input())
for query in range(q):
	n = int(input())
	sticks = list(map(int, input().split()))
	d = {}
	for elem in sticks:
		if elem not in d:
			d[elem] = 1
		else:
			d[elem] += 1
	kinds = []
	for elem in d:
		kinds.append(elem)
	kinds.sort()
	j = len(kinds) - 1
	i = 0
	area = kinds[0] * kinds[j]
	while i <= j:
		a = kinds[i]
		b = kinds[j]
		temp = kinds[i] * kinds[j]
		if temp != area:
			print('NO')
			break
		elif d[a] != d[b] or d[a] % 2 == 1:
			print('NO')
			break
		i += 1
		j -= 1
	else:
		print('YES')


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	dims = list(map(int, input().strip().split()))
	cnt = list(sorted(Counter(dims).most_common()))
	lcnt = len(cnt)
	area = cnt[0][0] * cnt[-1][0]
	fl = True
	for i in range((lcnt + 1) // 2):
		if cnt[i][0] * cnt[lcnt - i - 1][0] != area or cnt[i][1] != cnt[lcnt - i - 1][1] or cnt[i][1] % 2 != 0:
			print('NO')
			fl = False
			break
	if fl:
		print('YES')


q = int(input())
while q > 0:
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	if a[0] == a[1] and a[-1] == a[-2]:
		k = a[0] * a[-1]
		flag = False
		for i in range(2, 2 * n, 2):
			if not (a[i] == a[i + 1] and a[-i - 1] == a[-i - 2] and (a[i] * a[-i - 1] == k)):
				flag = True
				break
		if flag:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')
	q -= 1


from collections import Counter
t = int(input())
for case_num in range(t):
	n = int(input())
	cnt = Counter(map(int, input().split(' ')))
	a = list(cnt)
	a.sort()
	l = 0
	r = len(a) - 1
	area = a[l] * a[r]
	ok = True
	while l <= r:
		if a[l] * a[r] != area or cnt[a[l]] != cnt[a[r]] or cnt[a[l]] % 2 == 1 or (l == r and cnt[a[l]] % 4 != 0):
			ok = False
			break
		l += 1
		r -= 1
	print('YES' if ok else 'NO')


def solver():
	q = int(input().strip())
	for case in range(q):
		n = int(input().strip())
		a = list(map(int, input().strip().split()))
		a.sort()
		ok = True
		area = a[0] * a[-1]
		for i in range(n):
			(lf, rg) = (i * 2, 4 * n - i * 2 - 1)
			if a[lf] != a[lf + 1] or a[rg] != a[rg - 1] or a[lf] * a[rg] != area:
				ok = False
		if ok:
			print('YES')
		else:
			print('NO')

def main():
	while 1:
		try:
			solver()
		except EOFError:
			break
main()


from collections import Counter
from math import gcd

def check(cand, C):
	for (k, v) in C.items():
		if cand % k != 0:
			return False
		p = cand // k
		if p == k:
			if v % 4 == 0:
				C[p] = 0
				continue
			else:
				return False
		if v != C[p]:
			return False
		C[p] = 0
		C[k] = 0
	return True

def solve():
	n = int(input())
	A = [int(i) for i in input().split()]
	C = Counter(A)
	candidate = []
	a0 = A[0]
	for (k, v) in C.items():
		if v % 2 != 0:
			return False
		candidate.append(a0 * k)
	for cand in candidate:
		CC = C.copy()
		if check(cand, CC):
			return True
	return False

def main():
	q = int(input())
	for _ in range(q):
		if solve():
			print('YES')
		else:
			print('NO')
main()


N = int(input())
for i in range(N):
	A = int(input())
	B = list(map(int, input().split()))
	B.sort()
	flag = True
	for i in range(2 * A):
		if B[2 * i] != B[2 * i + 1]:
			flag = False
			break
	S = B[0] * B[-1]
	for i in range(A):
		if B[i * 2] * B[-i * 2 - 1] != S:
			flag = False
			break
	print(['NO', 'YES'][flag])


from itertools import combinations
q = int(input())
for x in range(q):
	n = int(input())
	dic = {}
	l = []
	for x in input().split():
		if x in dic:
			dic[x] += 1
			if dic[x] == 2:
				dic[x] = 0
				l.append(int(x))
		else:
			dic[x] = 1
	l.sort()
	areas = {}
	for i in range(len(l) // 2):
		a = l[i] * l[len(l) - i - 1]
		if a in areas:
			areas[a] += 1
		else:
			areas[a] = 1
	if n in areas.values():
		print('YES')
	else:
		print('NO')


from collections import defaultdict

def eval(sides, target, n):
	tot_number = 0
	for side in sides:
		if sides[side] % 2 != 0:
			return 0
		complement = target / side
		if sides[complement] != sides[side]:
			return 0
		if complement == side and sides[side] % 4 != 0:
			return 0
		if complement == side:
			tot_number += sides[side] / 4
		else:
			tot_number += sides[side] / 4
	if not int(tot_number) == n:
		return 0
	else:
		return 1
for query in range(int(input())):
	n = int(input())
	sticks = list(map(int, input().split()))
	sides = defaultdict(lambda : 0)
	for s in sticks:
		sides[s] += 1
	keys = sorted(sides.keys())
	target = keys[0] * keys[-1]
	if eval(sides, target, n):
		print('YES')
	else:
		print('NO')


def arr_inp():
	return [int(x) for x in input().split()]
q = int(input())
for i in range(q):
	(n, a) = (int(input()), arr_inp())
	a.sort()
	diff = 0
	for j in range(0, n * 2, 2):
		if j == 0:
			diff = a[j] * a[-(j + 1)]
		if a[j] * a[-(j + 1)] != diff:
			diff = 0
			break
		if a[j] != a[j + 1] or a[-(j + 1)] != a[-(j + 2)]:
			diff = 0
			break
	print('YNEOS'[diff == 0::2])


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	d = {}
	flag = 0
	k = l[0] * l[4 * n - 1]
	for j in range(2 * n):
		if l[j] * l[4 * n - j - 1] != k:
			flag = 1
			break
	for j in range(4 * n):
		if l[j] in d:
			d[l[j]] += 1
		else:
			d[l[j]] = 1
	for j in d:
		if d[j] % 2 != 0:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * 10005
	for i in a:
		b[i] += 1
	for i in range(10005):
		b[i] //= 2
	ans = min(a) * max(a)
	cnt = 0
	c = [False] * 10005
	for i in range(1, 10005):
		if not (c[i] and c[ans // i]) and ans // i < 10005 and (ans % i == 0):
			if i * i == ans:
				cnt += b[i] // 2
			else:
				cnt += min(b[i], b[ans // i])
			c[i] = True
			c[ans // i] = True
	if cnt == n:
		print('YES')
	else:
		print('NO')


import collections
q = int(input())
for i in range(q):
	n = int(input())
	A = [int(i) for i in input().split()]
	A.sort()
	chk = True
	if A[0] != A[1] or A[-1] != A[-2]:
		chk = False
	else:
		area = A[0] * A[-1]
		for j in range(1, n):
			(a, b, c, d) = (A[2 * j], A[2 * j + 1], A[4 * n - 2 - 2 * j], A[4 * n - 1 - 2 * j])
			if a != b or c != d or a * c != area:
				chk = False
	print('YES' if chk == True else 'NO')


q = int(input())
f = []
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	k = 'YES'
	for i in range(2 * n):
		if a[2 * i] != a[2 * i + 1]:
			k = 'NO'
			break
	if k == 'YES':
		p = a[0] * a[4 * n - 1]
		for i in range(4 * n):
			if a[i] * a[4 * n - 1 - i] != p:
				k = 'NO'
				break
	f += [k]
for i in f:
	print(i)


q = int(input())
for i in range(q):
	n = int(input())
	a = [0] * (n * 4)
	a[0:n * 4] = map(int, input().split())
	a.sort()
	w = a[0] * a[n * 4 - 1]
	e = 0
	for o in range(n):
		if a[o * 2] != a[o * 2 + 1] or a[n * 4 - o * 2 - 1] != a[n * 4 - o * 2 - 2] or a[o * 2] * a[n * 4 - o * 2 - 1] != w:
			e = 1
			break
	if e == 1:
		print('No')
	else:
		print('Yes')


q = int(input())
for k in range(q):
	n = int(input())
	a = list(map(int, input().rstrip().split()))
	a.sort()
	p = dict()
	flag = 0
	for i in a:
		if i in p:
			p[i] += 1
		else:
			p[i] = 1
	for i in p:
		if p[i] % 2 == 1:
			flag = 1
			break
	l = a[0] * a[-1]
	i = 0
	j = 4 * n - 1
	while i < j:
		if a[i] * a[j] == l:
			pass
		else:
			flag = 1
			break
		i += 1
		j -= 1
	if flag == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	l = [0] * 10000
	n = int(input())
	y = list(map(int, input().split()))
	y.sort()
	for i in y:
		l[i - 1] += 1
	test = True
	for i in y:
		if l[i - 1] % 2 == 1:
			test = False
			break
	if test == False:
		print('NO')
	elif n == 1:
		print('YES')
	else:
		d = y[0] * y[-1]
		for i in range(2 * n):
			if d != y[-i - 1] * y[i] or l[y[i] - 1] != l[y[-i - 1] - 1]:
				test = False
		if test == False:
			print('NO')
		else:
			print('YES')


for i in range(int(input())):
	y = 0
	n = int(input())
	x = [int(i) for i in input().split()]
	x.sort()
	z = x[0] * x[n * 4 - 1]
	for i in range(0, 2 * n, 2):
		if x[i] != x[i + 1] or x[4 * n - i - 1] != x[4 * n - i - 2] or x[i] * x[4 * n - i - 1] != z:
			y = 1
	if y == 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	N = int(input())
	a = list(map(int, input().split()))
	a.sort()
	f = True
	s = a[0] * a[len(a) - 1]
	for i in range(0, 2 * N, 2):
		if s == a[i] * a[len(a) - 1 - i] and a[i] == a[i + 1] and (a[len(a) - 1 - i] == a[len(a) - 2 - i]):
			pass
		else:
			f = False
	if f:
		print('YES')
	else:
		print('NO')


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 ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter
from itertools import combinations
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

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 fsep():
	return map(float, inp().split())

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

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

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

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

def prefix_sum(ar):
	return list(accumulate(ar))

def suffix_sum(ar):
	return list(accumulate(ar[::-1]))[::-1]

def N():
	return int(inp())
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]
from collections import defaultdict

def numberOfSetBits(i):
	i = i - (i >> 1 & 1431655765)
	i = (i & 858993459) + (i >> 2 & 858993459)
	return ((i + (i >> 4) & 252645135) * 16843009 & 4294967295) >> 24
from decimal import *

def solve():
	n = 4 * N()
	ar = lis()
	c = counter(ar)
	for i in c.values():
		if i % 2 == 1:
			print('NO')
			return
	temp = []
	for i in c.keys():
		temp += [i] * (c[i] // 2)
	temp.sort()
	req = temp[0] * temp[-1]
	for i in range(len(temp)):
		if temp[i] * temp[-i - 1] != req:
			print('NO')
			return
	print('YES')
testcase(int(inp()))


for i in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	f = 0
	b = [0] * 2 * n
	j = 0
	for i in range(0, 4 * n, 2):
		if a[i] == a[i + 1] and a[4 * n - i - 1] == a[4 * n - i - 2]:
			b[j] = a[i] * a[4 * n - i - 1]
			j += 1
		else:
			f = 1
			break
	if f == 0:
		b = sorted(b)
		print('YES' if b[0] == b[-1] else 'NO')
	else:
		print('NO')


for T in range(int(input().strip())):
	(n, data) = (int(input()), [int(i) for i in input().strip().split()])
	data = sorted(data)
	check = set()
	flag = True
	(l, r) = (0, 4 * n - 1)
	while l < r:
		(a, b, c, d) = (data[l], data[l + 1], data[r], data[r - 1])
		if a != b or c != d:
			flag = False
			break
		check.add(a * d)
		if len(check) > 1:
			flag = False
			break
		l += 2
		r -= 2
	print('YES' if flag else 'NO')


q = int(input())
for _ in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	f = 0
	i = 0
	while i < 4 * n:
		t = s[i]
		c = 0
		while t == s[i]:
			c = c + 1
			i = i + 1
			if i == 4 * n:
				break
		if c % 2 == 1:
			f = 1
			break
	if f:
		print('NO')
	else:
		i = 0
		j = 4 * n - 1
		a = s[i] * s[j]
		while i < j:
			if a != s[i] * s[j]:
				a = 0
				break
			else:
				i = i + 2
				j = j - 2
		if a:
			print('YES')
		else:
			print('NO')


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

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

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

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

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

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
for _ in range(ii()):
	n = ii()
	a = sorted(li())
	area = a[0] * a[-1]
	for i in range(n):
		if a[2 * i] != a[2 * i + 1] or a[-2 * i - 1] != a[-2 * i - 2] or a[2 * i] * a[-2 * i - 1] != area or (a[2 * i + 1] * a[-2 * i - 2] != area):
			print('NO')
			break
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	(m, res, square) = (4 * n, 'YES', 0)
	for i in range(0, 2 * n, 2):
		(x, y) = (lst[i], lst[m - i - 2])
		if x == lst[i + 1] and y == lst[m - i - 1]:
			if i == 0:
				square = x * y
			elif square != x * y:
				res = 'NO'
				break
		else:
			res = 'NO'
			break
	print(res)


for _ in range(int(input())):
	n = int(input())
	ls = list(map(int, input().split()))
	ls.sort()
	i = 0
	j = 4 * n - 1
	p = ls[i] * ls[j - 1]
	f = True
	while i < 2 * n:
		if ls[i] == ls[i + 1] and ls[j] == ls[j - 1] and (ls[i] * ls[j - 1] == p):
			i += 2
			j -= 2
		else:
			f = False
			break
	if f:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in range(4 * n):
		if a[i] in d:
			d[a[i]] += 1
		else:
			d[a[i]] = 1
	flag = 1
	for (key, value) in d.items():
		if value % 2 != 0:
			flag = 0
			break
	if flag == 1:
		a1 = min(a)
		a2 = max(a)
		area = a1 * a2
		count = 0
		for (key, value) in d.items():
			if value == 0:
				continue
			if area != area // key * key:
				flag = 0
				break
			if value != 0 and area // key not in d:
				flag = 0
				break
			elif key == area // key:
				x = value // 4
				count += x
				d[key] -= x * key
			else:
				x = min(value, d[area // key])
				count += x // 2
				d[area // key] -= x
				d[key] -= x
		if flag == 0:
			print('NO')
		elif count == n:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def gns():
	return list(map(int, input().split()))
t = int(input())
for i in range(t):
	n = int(input())
	ns = gns()
	ns.sort()
	a = ns[0] * ns[-1]
	f = True
	for i in range(4 * n):
		if i % 2 == 1:
			continue
		if ns[i] != ns[i + 1]:
			f = False
			break
	if not f:
		print('NO')
		continue
	for i in range(4 * n):
		if ns[i] * ns[4 * n - 1 - i] != a:
			f = False
			break
	if not f:
		print('NO')
		continue
	print('YES')


q = int(input())
for i in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	c = [0] * 10001
	for j in l:
		c[j] += 1
	b = False
	for j in c:
		if j % 2:
			print('NO')
			b = True
			break
	if b:
		continue
	s = []
	for j in range(len(c)):
		if c[j]:
			s += [j] * (c[j] // 2)
	area = s[0] * s[-1]
	p = 1
	b = True
	while p < len(s) / 2:
		if s[p] * s[-1 - p] != area:
			print('NO')
			b = False
			break
		p += 1
	if b:
		print('YES')


q = int(input())
for _ in range(q):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	if len({a1 * a2 for (a1, a2) in zip(a, a[::-1])}) == 1 and a[::2] == a[1::2]:
		print('YES')
	else:
		print('NO')


from sys import stdin
q = int(input())
for i in range(q):
	n = int(input())
	p = sorted([int(x) for x in input().split()])
	fail = False
	area = -1
	for i in range(0, len(p), 2):
		if p[i] != p[i + 1]:
			fail = True
		if p[len(p) - i - 1] != p[len(p) - i - 2]:
			fail = True
		if p[i] * p[len(p) - i - 1] != area:
			if area is -1:
				area = p[i] * p[len(p) - i - 1]
			else:
				fail = True
	if fail:
		print('NO')
	else:
		print('YES')


def main():
	n = int(input())
	for i in range(0, n):
		req = int(input())
		val = list((int(v) for v in input().split()))
		freq = {}
		for v in val:
			if v not in freq:
				freq[v] = 0
			freq[v] += 1
		is_ok = True
		for (k, v) in freq.items():
			if v % 2 != 0:
				is_ok = False
				break
		if not is_ok:
			print('NO')
			continue
		is_ok = True
		v1 = sorted(val)
		s = v1[0] * v1[len(val) - 1]
		for (k, v) in freq.items():
			if s % k == 0 and s // k in freq:
				if v != freq[s // k]:
					is_ok = False
					break
			else:
				is_ok = False
				break
		print('YES' if is_ok else 'NO')
main()


from fractions import gcd
from itertools import combinations, permutations, accumulate, product
from collections import deque, defaultdict, Counter
import decimal
import re
import math
import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
from sys import stdin
readline = stdin.readline

def readInts():
	return list(map(int, readline().split()))

def readTuples():
	return tuple(map(int, readline().split()))

def I():
	return int(readline())
for _ in range(I()):
	n = I()
	A = readInts()
	dic = Counter(A)
	arr = []
	flag = False
	for (k, v) in dic.items():
		if v % 2:
			flag = True
			break
		for _ in range(v // 2):
			arr.append(k)
	arr = sorted(arr)
	SetArr = set()
	for i in range(len(arr) // 2):
		SetArr.add(arr[i] * arr[-i - 1])
	if flag:
		print('NO')
		continue
	if len(SetArr) == 1:
		print('YES')
	else:
		print('NO')


test = int(input())
while test:
	n = int(input())
	n *= 4
	side = list(map(int, input().split()))
	side.sort()
	num = side[0] * side[n - 1]
	l = 0
	r = n - 1
	fal = True
	while l < r:
		if side[l] == side[l + 1] and side[r] == side[r - 1] and (side[l] * side[r] == num):
			l += 2
			r -= 2
		else:
			fal = False
			break
	if fal == True:
		print('YES')
	else:
		print('NO')
	test -= 1


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	pr = a[0] * a[1] * a[-1] * a[-2]
	for q in range(0, n * 2, 2):
		if a[q] != a[q + 1] or a[4 * n - q - 1] != a[4 * n - q - 2] or a[q] * a[q + 1] * a[4 * n - q - 1] * a[4 * n - q - 2] != pr:
			print('NO')
			break
	else:
		print('YES')


import math
t = int(input())
for _ in range(t):
	n = int(input())
	p = 0
	a = list(map(int, input().split()))
	d = {}
	for i in a:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	e = list(d.values())
	z = 1
	for i in e:
		if i % 2 == 1:
			z = 0
			break
	if z == 0:
		print('NO')
		continue
	p = 1
	for i in a:
		p = p * pow(i, 1 / (2 * n))
	if abs(p - round(p)) < 0.0001:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	flag = 1
	for i in range(2 * n):
		if l[2 * i] != l[2 * i + 1]:
			flag = 0
			break
	ans = l[0] * l[-1]
	if flag != 0:
		for i in range(0, 2 * n, 2):
			if l[i] * l[4 * n - i - 1] != ans:
				flag = 0
				break
	if flag:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	k = list(map(int, input().split()))
	k.sort()
	x = 0
	x1 = 4 * n - 1
	f = True
	pl = 0
	while x < x1:
		if k[x] != k[x + 1] or k[x1 - 1] != k[x1]:
			f = False
			break
		if x == 0:
			pl = k[x] * k[x1]
		elif pl != k[x] * k[x1]:
			f = False
			break
		x += 2
		x1 -= 2
	if f == False:
		print('NO')
	else:
		print('YES')


for q in range(int(input())):
	n = int(input())
	arr = sorted([int(s) for s in input().split()])
	(count, now) = (1, arr[0])
	ans = 1
	for i in range(1, 4 * n):
		if now != arr[i] and i % 2 != 0:
			ans = 0
		now = arr[i]
	arr1 = [0] * (2 * n)
	for i in range(0, 4 * n, 2):
		arr1[i // 2] = arr[i]
	s = arr1[0] * arr1[2 * n - 1]
	for i in range(2 * n):
		if arr1[i] * arr1[2 * n - i - 1] != s:
			ans = 0
	print('YES' if ans else 'NO')


q = int(input())
for _ in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	a2 = [a[i] for i in range(0, len(a), 2)]
	a3 = [a[i + 1] for i in range(0, len(a), 2)]
	if a2 != a3:
		print('NO')
		continue
	a3.reverse()
	areas = [ai * aj for (ai, aj) in zip(a2, a3)]
	if areas == [areas[0]] * 2 * n:
		print('YES')
	else:
		print('NO')


import sys
from collections import Counter

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 list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

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

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

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7

def check1(C):
	for v in C.values():
		if v % 2 != 0:
			return False
	return True

def check2(A):
	A.sort()
	S = set()
	for i in range(0, N * 4, 2):
		(a, b) = (A[i], A[N * 4 - i - 1])
		S.add(a * b)
	return len(S) == 1
for _ in range(INT()):
	N = INT()
	A = LIST()
	C = Counter(A)
	if check1(C) and check2(A):
		YES()
	else:
		NO()


n = int(input())
for t in range(n):
	y = int(input())
	x = list(map(int, input().split()))
	a = [0] * len(x)
	for i in range(len(x)):
		a[i] = x[i]
	a.sort()
	z = 0
	x.sort(reverse=True)
	prod = x[0] * a[0]
	for i in range(0, y * 2, 2):
		if x[i] == x[i + 1] and a[i] == a[i + 1]:
			if prod == x[i] * a[i]:
				z += 1
	if z == y:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	t = []
	k = 0
	for i in range(0, 2 * n, 2):
		if a[i] == a[i + 1] and a[4 * n - i - 1] == a[4 * n - i - 2]:
			s = a[i] * a[4 * n - i - 1]
			t.append(s)
		else:
			k += 1
	if k > 0:
		print('NO')
	elif len(list(set(t))) == 1:
		print('YES')
	else:
		print('NO')


from sys import stdin
from collections import defaultdict
q = int(stdin.readline())
for i in range(0, q):
	n = int(stdin.readline())
	sticks = [int(i) for i in stdin.readline().split(' ')]
	lengths = defaultdict(int)
	for j in sticks:
		lengths[j] += 1
	arranged = sorted(list(lengths.keys()))
	area = arranged[0] * arranged[-1]
	impossible = False
	for l in range(0, len(arranged)):
		if (lengths[arranged[l]] % 2 == 1 or arranged[l] * arranged[-l - 1] != area) or lengths[arranged[l]] != lengths[arranged[-l - 1]]:
			impossible = True
			break
	if not impossible:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	area = a[0] * a[-1]
	for (i, j) in zip(range(0, 4 * n, 2), range(4 * n - 1, -1, -2)):
		if a[i] != a[i + 1] or a[j] != a[j - 1] or a[i] * a[j] != area:
			print('NO')
			break
	else:
		print('YES')


count = int(input())
result = []
for _ in range(count):
	num = int(input())
	sides = list(map(lambda num: int(num), input().split()))
	sides.sort()
	flag = 1
	if len(sides) % 4 != 0:
		result.append('NO')
		flag = 0
	else:
		lindex = 0
		rindex = len(sides) - 1
		area = 0
		while lindex <= rindex:
			if sides[lindex] != sides[lindex + 1] or sides[rindex] != sides[rindex - 1]:
				result.append('NO')
				flag = 0
				break
			else:
				test = sides[lindex] * sides[rindex]
				if area == 0:
					area = test
				elif area != test:
					result.append('NO')
					flag = 0
					break
			lindex += 2
			rindex -= 2
	if flag:
		result.append('YES')
print('\n'.join(result))


q = int(input())
for i in range(q):
	n = int(input())
	array = list(map(int, input().split()))
	d = {}
	for el in array:
		if el not in d:
			d[el] = 1
		else:
			d[el] += 1
	p = False
	for el in d:
		if d[el] % 2 == 1:
			print('NO')
			p = True
			break
	if p:
		continue
	array.sort()
	s = array[4 * n - 1] * array[0]
	(i, j) = (2, 4 * n - 3)
	while i <= j:
		if array[i] * array[j] == s:
			i += 2
			j -= 2
		else:
			print('NO')
			p = True
			break
	if not p:
		print('YES')


q = int(input())
for i in range(q):
	result = 'NO'
	k = int(input())
	li = list(map(int, input().split()))
	li.sort()
	area = li[0] * li[-1]
	for i in range(0, len(li) // 2, 2):
		if li[i] * li[(i + 1) * -1] != area or li[i] != li[i + 1] or li[(i + 1) * -1] != li[(i + 2) * -1]:
			break
		if i == len(li) // 2 - 2:
			result = 'YES'
	print(result)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	x = 0
	for i in range(len(l)):
		x = x ^ l[i]
	if x != 0:
		print('NO')
		continue
	else:
		k = []
		for i in range(0, len(l), 2):
			k.append(l[i])
		ans = []
		flag = 0
		for i in range(len(k) // 2):
			ans.append(k[i] * k[len(k) - i - 1])
		if len(set(ans)) == 1:
			print('YES')
		else:
			print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	c = min(a)
	d = max(a)
	s = c * d
	a = sorted(a)
	f = False
	for i in range(0, n * 2, 2):
		if a[i] != a[i + 1] or a[n * 4 - i - 1] != a[n * 4 - i - 2]:
			f = True
			break
		if a[i] * a[n * 4 - i - 1] != s:
			f = True
			break
	if not f:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	arr = [0] + list(map(int, input().split()))
	arr1 = []
	d = dict()
	for i in arr[1:]:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
			arr1.append(i)
	c = 1
	for i in d:
		if d[i] % 2 == 1:
			print('NO')
			c = 0
			break
	if c == 1:
		arr.sort()
		aera = arr[1] * arr[-1]
		for i in range(1, 2 * n + 1):
			if arr[i] * arr[4 * n - i + 1] != aera:
				print('NO')
				c = 0
				break
		if c == 1:
			print('YES')


for q in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * 10001
	a.sort()
	flag = 0
	area = a[0] * a[4 * n - 1]
	for i in range(0, 2 * n, 2):
		if a[i] != a[i + 1] or a[4 * n - 1 - i] != a[4 * n - 2 - i]:
			flag = 1
			break
		if a[i] * a[4 * n - 1 - i] != area:
			flag = 1
			break
	if flag == 0:
		print('YES')
	else:
		print('NO')


MAXVAL = 10001

def solve(n, a):
	count = [0] * MAXVAL
	for val in a:
		count[val] += 1
	num_unique = 0
	b = []
	c = []
	for i in range(MAXVAL):
		if count[i] % 2 == 1:
			return 'NO'
		if count[i] > 0:
			b.append(i)
			c.append(count[i])
	i = 0
	j = len(b) - 1
	if i < j:
		area = b[i] * b[j]
	else:
		return 'YES'
	while i <= j:
		if c[i] != c[j]:
			return 'NO'
		if b[i] * b[j] != area:
			return 'NO'
		i += 1
		j -= 1
	return 'YES'
q = int(input())
for test in range(q):
	n = int(input())
	a = list(map(int, input().strip().split()))
	res = solve(n, a)
	print(res)


q = int(input())
while q > 0:
	n = int(input())
	a = [int(ele) for ele in input().split()]
	a.sort()
	i = 0
	j = len(a) - 1
	flag = 1
	while i < j:
		if i == 0:
			if a[i] == a[i + 1] and a[j] == a[j - 1]:
				area = a[i] * a[j]
				i += 2
				j -= 2
			else:
				flag = 0
				break
		elif a[i] == a[i + 1] and a[j] == a[j - 1]:
			ar = a[i] * a[j]
			if ar == area:
				i += 2
				j -= 2
			else:
				flag = 0
				break
		else:
			flag = 0
			break
	if flag == 1:
		print('YES')
	else:
		print('NO')
	q -= 1


Q = int(input())
for q in range(Q):
	N = int(input())
	A = sorted([int(a) for a in input().split()])
	S = A[0] * A[-1]
	(i, j) = (0, 4 * N - 1)
	for _ in range(N):
		if not (A[i] == A[i + 1] and A[j] == A[j - 1] and (A[i] * A[j] == S)):
			print('NO')
			break
		i += 2
		j -= 2
	else:
		print('YES')


T = int(input())
for t in range(T):
	check = True
	num = 4 * int(input())
	l = list(map(int, input().split()))
	l = sorted(l)
	size = l[1] * l[-2]
	for k in range(0, num // 2, 2):
		if size == l[k] * l[num - k - 1]:
			pass
		else:
			check = False
		if l[k] == l[k + 1] and l[num - k - 1] == l[num - k - 2]:
			pass
		else:
			check = False
	if check == False:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	d = {}
	b = []
	f = 0
	l = [int(i) for i in input().split()]
	l.sort()
	for j in range(0, 4 * n - 1, 2):
		if l[j] != l[j + 1]:
			f = 1
	for j in l:
		d[j] = 0
	for j in l:
		d[j] = d[j] + 0.5
	for j in l:
		if d[j] > 0:
			b.append(j)
			d[j] -= 1
	b.sort()
	prod = b[0] * b[2 * n - 1]
	for j in range(n):
		p = b[j] * b[2 * n - 1 - j]
		if j > 0:
			if p != prod:
				f = 1
				break
	if f == 0:
		print('YES')
	if f == 1:
		print('NO')


n = int(input())
for f in range(n):
	k = int(input())
	s = 0
	con = 0
	g = list(map(int, input().split()))
	g.sort()
	g1 = g[::2]
	g2 = g[1::2]
	if g1 != g2:
		print('No')
	else:
		g2.reverse()
		con = g1[0] * g2[0]
		for i in range(1, len(g1) // 2 + 1):
			if con == g1[i] * g2[i]:
				s += 1
		if s == k:
			print('Yes')
		else:
			print('No')


def valid(numbers, area):
	for n in numbers.keys():
		if area % n:
			return False
		if numbers[n] % 2:
			return False
		if numbers[n] != numbers.get(area // n, 0):
			return False
	return True
for _ in range(int(input())):
	input()
	b = {}
	for a in map(int, input().split()):
		b[a] = b.get(a, 0) + 1
	if valid(b, max(b.keys()) * min(b.keys())):
		print('YES')
	else:
		print('NO')


q = int(input())
for query in range(q):
	n = int(input())
	lengths = list(map(int, input().split()))
	lengths.sort()
	size = lengths[0] * lengths[-1]
	flag = True
	for i in range(n):
		if lengths[i * 2] != lengths[i * 2 + 1] or lengths[-i * 2 - 1] != lengths[-i * 2 - 2] or lengths[i * 2] * lengths[-i * 2 - 1] != size:
			flag = False
	print('YES' if flag else 'NO')


from sys import stdin, stdout
from collections import defaultdict
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	d = defaultdict(int)
	arr = [int(x) for x in stdin.readline().split()]
	arr.sort()
	for v in arr:
		d[v] += 1
	r = arr[0] * arr[-1]
	if all([x % 2 == 0 for x in d.values()]) and all([arr[i] * arr[-1 - i] == arr[i + 1] * arr[-2 - i] for i in range(0, int(len(arr) / 2))]):
		stdout.write('YES\n')
	else:
		stdout.write('NO\n')


a = int(input())
for i in range(a):
	b = int(input())
	A = list(map(int, input().split()))
	A.sort()
	q = 0
	w = 1
	e = b * 4 - 1
	r = b * 4 - 2
	v = True
	if A[q] == A[w] and A[e] == A[r]:
		s = A[q] * A[e]
		q += 2
		w += 2
		e -= 2
		r -= 2
	else:
		v = False
	while r > w and v == True:
		if A[q] == A[w] and A[e] == A[r]:
			if A[q] * A[e] == s:
				q += 2
				w += 2
				e -= 2
				r -= 2
			else:
				v = False
		else:
			v = False
	if v == True:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	data = [int(i) for i in input().split()]
	dic = {}
	for d in data:
		if d not in dic:
			dic[d] = 1
		else:
			dic[d] += 1
	lst = []
	good = True
	for d in dic:
		if dic[d] & 1:
			good = False
			break
		else:
			lst += [d] * (dic[d] // 2)
			dic[d] //= 2
	if not good:
		print('NO')
		continue
	lst.sort()
	prod = lst[0] * lst[-1]
	wer = 2 * n - 1
	for i in range(1, n):
		if lst[i] * lst[wer - i] != prod:
			good = False
			break
	if not good:
		print('NO')
	else:
		print('YES')


from sys import stdin

def ii():
	return int(stdin.readline())

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

def li():
	return list(mi())
for _ in range(ii()):
	n = ii()
	a = li()
	a.sort()
	p = f = 0
	(i, j) = (0, n * 4 - 1)
	while j > i:
		if a[i] == a[i + 1] and a[j] == a[j - 1]:
			s = a[i] * a[j]
		else:
			f = 1
			break
		if p and p != s:
			f = 1
			break
		else:
			p = s
		i += 2
		j -= 2
	print('YES' if not f else 'NO')


def main():
	q = int(input())
	for _ in range(q):
		n = int(input())
		slist = list(sorted(map(int, input().split())))
		(li, ri) = (0, 4 * n - 1)
		ans = None
		for j in range(n):
			if slist[li] != slist[li + 1] or slist[ri] != slist[ri - 1]:
				print('NO')
				break
			if ans is None:
				ans = slist[li] * slist[ri]
				li += 2
				ri -= 2
			elif ans != slist[li] * slist[ri]:
				print('NO')
				break
			else:
				li += 2
				ri -= 2
		else:
			print('YES')
main()


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
import itertools

def Int():
	return int(sys.stdin.readline())

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

def Lstr():
	return list(sys.stdin.readline().strip())

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

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

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

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

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	for _ in range(Int()):
		n = Int()
		l = List()
		l.sort()
		m = l[::-1]
		ans = []
		a = l[0::2]
		b = l[1::2]
		if a != b:
			print('NO')
		else:
			for i in range(len(l)):
				ans.append(l[i] * m[i])
			if len(set(ans)) == 1:
				print('YES')
			else:
				print('NO')
solution()


q = int(input())
for k in range(q):
	n = int(input())
	data = []
	data[:] = map(int, input().split())
	dic = {}
	for i in data:
		if i in dic:
			dic[i] += 1
		else:
			dic[i] = 1
	flag = 0
	for i in dic.keys():
		if dic[i] % 2 != 0:
			print('NO')
			flag = 1
			break
		else:
			dic[i] //= 2
	if not flag:
		keys = []
		s = ''
		for i in dic.keys():
			s += (str(i) + ' ') * dic[i]
		keys[:] = map(int, s.split())
		keys.sort()
		sq = keys[0] * keys[-1]
		for i in range(1, len(keys) // 2):
			if keys[i] * keys[len(keys) - i - 1] != sq:
				print('NO')
				flag = 1
				break
		if not flag:
			print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	x = a[0] * a[-1]
	f = 0
	for i in range(0, 2 * n, 2):
		if a[i] == a[i + 1] and a[-1 * (i + 1)] == a[-1 * (i + 2)]:
			if a[i] * a[-1 * (i + 1)] == x:
				continue
			else:
				f = 1
				break
		else:
			f = 1
			break
	if f:
		print('NO')
	else:
		print('YES')


from sys import stdin, stdout
from collections import OrderedDict
R = lambda : stdin.readline().strip()
RL = lambda : list(map(int, R().split(' ')))
output = lambda x: stdout.write(str(x) + '\n')
MX = 10005
for tc in range(int(R())):
	n = int(R())
	a = RL()
	cnt = MX * [0]
	for i in a:
		cnt[i] += 1
	ans = True
	for i in cnt:
		if i % 2:
			ans = False
	if ans:
		A = min(a) * max(a)
		for i in a:
			if A % i or cnt[i] != cnt[A // i]:
				ans = False
	if ans:
		output('YES')
	else:
		output('NO')


q = int(input())
for qq in range(q):
	n = int(input())
	(*a,) = list(map(int, input().split()))
	a = list(sorted(a))
	br = False
	for i in range(2 * n):
		if a[2 * i] != a[2 * i + 1]:
			print('NO')
			br = True
			break
	if br:
		continue
	a = a[::2]
	ar = a[0] * a[-1]
	for i in range(n):
		if a[i] * a[-i - 1] != ar:
			print('NO')
			break
	else:
		print('YES')


def are_rectangles_possible(a):
	s = max(a) * min(a)
	occ = {}
	for x in a:
		if x in occ:
			occ[x] += 1
		else:
			occ[x] = 1
	for x in occ:
		if occ[x] % 2 > 0:
			return 'NO'
	req = {}
	for x in a:
		div = s / x
		if s % x > 0:
			return 'NO'
		elif x in req and req[x] > 0:
			req[x] -= 1
		elif div in req:
			req[div] += 1
		else:
			req[div] = 1
	for x in req:
		if req[x] > 0:
			return 'NO'
	return 'YES'
for i in range(int(input())):
	input()
	print(are_rectangles_possible(list(map(int, input().split()))))


q = int(input())
while q:
	q -= 1
	b = []
	c = []
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	for i in range(0, 4 * n - 1, 2):
		z = 0
		if a[i] == a[i + 1]:
			pass
		else:
			print('NO')
			z = 1
			break
	if z == 1:
		continue
	for i in range(0, 4 * n, 2):
		b.append(a[i])
	if n == 1:
		print('YES')
		continue
	for i in range(len(b) // 2):
		c.append(b[i] * b[-(i + 1)])
	if all((c[i] == c[i + 1] for i in range(len(c) - 1))):
		print('YES')
		continue
	else:
		print('NO')
		continue


q = int(input())
for _ in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	area = a[0] * a[-1]
	if all((a[2 * i] == a[2 * i + 1] and a[4 * n - 2 * i - 1] == a[4 * n - 2 * i - 2] and (a[4 * n - 2 * i - 1] * a[2 * i] == area) for i in range(n))):
		print('YES')
	else:
		print('NO')


q = int(input())
while q > 0:
	n = int(input())
	a = [int(v) for v in input().split()]
	a.sort()
	left = 0
	right = len(a) - 1
	area = -1
	flag = 0
	while left < right:
		if area == -1:
			area = a[left] * a[right]
			if not a[left + 1] == a[left] or not a[right - 1] == a[right]:
				flag = 1
				break
		elif not area == a[left] * a[right] or (not a[left + 1] == a[left] or not a[right - 1] == a[right]):
			flag = 1
			break
		left += 2
		right -= 2
	if flag == 0:
		print('YES')
	else:
		print('NO')
	q -= 1


for q in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	area = a[0] * a[-1]
	flag = 0
	for i in range(0, 2 * n, 2):
		p = a[i]
		q = a[i + 1]
		r = a[4 * n - i - 1]
		s = a[4 * n - i - 2]
		if p != q or r != s or p * r != area:
			flag = 1
			break
	if flag:
		print('NO')
	else:
		print('YES')


q = int(input())
for j in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	if n == 1:
		if a[0] == a[1] and a[2] == a[3]:
			print('YES')
		else:
			print('NO')
	else:
		b = []
		for i in range(0, 4 * n - 1, 2):
			if a[i] == a[i + 1]:
				b.append(a[i])
		if len(b) == 2 * n:
			x = b[0] * b[2 * n - 1]
			for i in range(1, n):
				if b[i] * b[2 * n - i - 1] == x:
					x = b[i] * b[2 * n - i - 1]
				else:
					x = 0
					break
			if x != 0:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	s = input()
	list = []
	list = s.split()
	for i in range(len(list)):
		list[i] = int(list[i])
	list.sort()
	turn = 0
	ans = list[0] * list[4 * n - 1]
	for i in range(0, 2 * n, 2):
		if list[i] == list[i + 1] and list[i] * list[4 * n - 1 - i] == ans and (list[4 * n - 1 - i] == list[4 * n - 2 - i]):
			continue
		else:
			turn = 1
			break
	if turn == 0:
		print('YES')
	else:
		print('NO')


try:
	T = int(input())
	while T > 0:
		n = int(input())
		b = [int(x) for x in input().split()]
		f = 0
		if b.count(b[0] == 4 * n):
			print('YES')
			continue
		for i in range(4 * n):
			if b.count(b[i]) % 2 != 0:
				f = 1
				break
		if f == 1:
			print('NO')
			continue
		b.sort()
		l = []
		for i in range(0, 4 * n, 2):
			l.append(b[i])
		p = l[0] * l[2 * n - 1]
		for i in range(1, 2 * (n - 1)):
			if p != l[i] * l[2 * n - i - 1]:
				f = 1
				break
		if f == 1:
			print('NO')
		else:
			print('YES')
		T = T - 1
except:
	pass


q = int(input(''))
for v in range(q):
	n = int(input(''))
	s = list(map(int, input('').split(' ')))
	s.sort()
	a = []
	r = True
	for i in range(2 * n):
		t = s[2 * i]
		if t == s[2 * i + 1]:
			a.append(t)
		else:
			r = False
			break
	if r:
		ar = a[0] * a[2 * n - 1]
		for i in range(n):
			if ar == a[i] * a[2 * n - 1 - i]:
				r = True
			else:
				r = False
				break
	if r:
		print('YES')
	else:
		print('NO')


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	c = Counter(arr)
	dic = dict(c)
	nhi = 1
	for (i, j) in dic.items():
		if j % 2 != 0:
			nhi = 0
			print('NO')
			break
	if nhi == 1:
		srt = list(arr)
		srt.sort()
		area = srt.pop(0) * srt.pop(-1)
		for i in range(0, len(srt) // 2, 2):
			if srt[i] * srt[len(srt) - i - 1] != area:
				print('NO')
				nhi = 0
				break
		if nhi == 1:
			print('YES')


t = int(input())
for ijk in range(0, t):
	n = int(input())
	a = list(map(int, input().strip().split()))
	a.sort()
	c = 0
	area = a[0] * a[-1]
	n = 4 * n
	for i in range(0, n // 2, 2):
		if a[i] != a[i + 1]:
			break
		elif a[n - 1 - i] != a[n - 2 - i]:
			break
		cur = a[i] * a[n - 1 - i]
		if cur == area:
			c += 1
		else:
			break
	if c == n // 4:
		print('YES')
	else:
		print('NO')


def some(numbers):
	sort = list(sorted(numbers))
	clear = list()
	for i in range(1, len(sort), 1):
		if i % 2 == 1:
			if sort[i] != sort[i - 1]:
				return 'NO'
			clear.append(sort[i])
	sum_ = clear[0] * clear[len(clear) - 1]
	for i in range(1, len(clear) // 2):
		if sum_ != clear[i] * clear[len(clear) - i - 1]:
			return 'NO'
	return 'YES'
n = int(input())
for _ in range(n):
	count = int(input())
	numbers = list(map(int, input().split()))
	print(some(numbers))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(j) for j in input().split()]
	arr.sort()
	n *= 4
	flag = 0
	for i in range(0, n, 2):
		if arr[i] != arr[i + 1]:
			flag = 1
			break
	if flag == 1:
		print('NO')
		continue
	lol = arr[0] * arr[-1]
	for i in range(n // 2):
		if arr[i] * arr[n - i - 1] != lol:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


yn = []
q = int(input())
for i in range(q):
	k = 0
	n = int(input())
	a = [int(m) for m in input().split()]
	a.insert(0, 0)
	a.sort()
	area = a[1] * a[n * 4]
	j = 1
	while j <= n:
		if (a[2 * j - 1] == a[2 * j]) & (a[4 * n - 2 * j + 1] == a[4 * n - 2 * j + 2]) & (a[2 * j - 1] * a[4 * n - 2 * j + 2] == area):
			k = k + 1
		j = j + 1
	if k == n:
		yn.append('YES')
	else:
		yn.append('NO')
for i in range(q):
	print(yn[i])


def yes():
	print('YES')

def no():
	print('NO')
t = int(input())
for _ in range(t):
	n = int(input())
	a = input().split()
	l = []
	for i in a:
		l.append(int(i))
	l.sort()
	k = 0
	f = 0
	i1 = 1
	i2 = len(l) - 1
	p = l[i1] * l[i2]
	while i1 <= i2:
		if not (l[i1] == l[i1 - 1] and l[i1] * l[i2 - i1] == p):
			no()
			f = 1
			break
		i1 += 2
	if f == 0:
		yes()
	l.clear()
	a.clear()


q = int(input())
for itr in range(q):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	S = arr[0] * arr[-1]
	i = 0
	j = 4 * n - 1
	used = 0
	while i < j:
		if arr[i] == arr[i + 1] and arr[j] == arr[j - 1] and (arr[i] * arr[j] == S):
			used += 1
		i += 2
		j -= 2
	if used == n:
		print('YES')
	else:
		print('NO')


def readInts():
	return [int(s) for s in input().split(' ')]

def solve():
	n = readInts()[0]
	a = readInts()
	a.sort()
	b = []
	for i in range(2 * n):
		if a[2 * i] != a[2 * i + 1]:
			return 'NO'
		b.append(a[2 * i])
	area = b[0] * b[-1]
	for i in range(1, n):
		if b[i] * b[len(b) - 1 - i] != area:
			return 'NO'
	return 'YES'

def main():
	Q = readInts()[0]
	for q in range(Q):
		print(solve())
main()


from sys import stdin
input = stdin.readline
q = int(input())
for _ in range(q):
	n = int(input())
	a = sorted([int(i) for i in input().split()])
	res = True
	stick = 0
	A = a[0] * a[4 * n - 1]
	while res and stick < 2 * n:
		if a[stick] != a[stick + 1] or a[4 * n - stick - 1] != a[4 * n - stick - 2] or a[stick] * a[4 * n - stick - 1] != A:
			res = False
		stick += 2
	if res:
		print('YES')
	else:
		print('NO')


import math
q = int(input())
for test in range(0, q):
	n = int(input())
	S = input().split()
	Dict = {}
	max = 1
	min = 10000
	for i in range(0, 4 * n):
		val = int(S[i])
		if val in Dict:
			Dict[val] = Dict[val] + 1
		else:
			Dict[val] = 1
		if val < min:
			min = val
		if val > max:
			max = val
	if min == max:
		print('YES')
	else:
		ar = min * max
		f = 1
		for i in range(1, int(math.sqrt(ar)) + 1):
			if ar % i == 0:
				if i in Dict:
					if ar // i in Dict:
						if Dict[i] != Dict[ar // i]:
							f = 0
							break
						elif Dict[i] % 2 == 1:
							f = 0
							break
					else:
						f = 0
						break
			elif ar // i in Dict:
				f = 0
				break
		if f == 1:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	n = int(input())
	k = 1
	a = sorted(map(int, input().split()))
	p = a[1] * a[-1]
	for i in range(1, n * 2, 2):
		if a[i] != a[i - 1] or a[-i] != a[-i - 1] or a[i] * a[-i] != p:
			k = 0
	print('YES' if k else 'NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d1 = {}
	for i in l:
		if i in d1:
			d1[i] += 1
		else:
			d1[i] = 1
	f = True
	li = []
	for i in d1:
		if d1[i] % 2 != 0:
			f = False
			break
		else:
			li.extend([i] * (d1[i] // 2))
	if f:
		li.sort()
		c = li[0] * li[-1]
		i = 1
		j = len(li) - 2
		while i < j:
			if c != li[i] * li[j]:
				f = False
				break
			else:
				i += 1
				j -= 1
		if f:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def rectangles(n, lst):
	(prod, flag) = (lst[0] * lst[-1], True)
	for i in range(2 * n):
		if lst[2 * i] != lst[2 * i + 1]:
			flag = False
			break
	for i in range(2 * n):
		if prod != lst[i] * lst[4 * n - i - 1]:
			flag = False
			break
	if flag:
		return 'YES'
	return 'NO'
q = int(input())
for j in range(q):
	m = int(input())
	a = [int(x) for x in input().split()]
	print(rectangles(m, sorted(a)))


q = int(input())
x = []
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = 'YES'
	l1 = 0
	l2 = 1
	r1 = 4 * n - 1
	r2 = 4 * n - 2
	for i in range(0, 4 * n, 2):
		if a[i] != a[i + 1]:
			b = 'NO'
			break
	if b != 'NO':
		g = a[l1] * a[r1]
		while r2 - l2 >= 1:
			if a[l1] * a[r1] != g:
				b = 'NO'
				break
			l1 += 1
			l2 += 1
			r1 -= 1
			r2 -= 1
	x.append(b)
for i in range(q):
	print(x[i])


for k in range(int(input())):
	n = int(input())
	t = list(map(int, input().split()))
	t.sort()
	u = t[1] * t[-1]
	d = 0
	for j in range(1, n * 2, 2):
		if t[j] != t[j - 1] or t[-j] != t[-(j + 1)] or t[j] * t[-j] != u:
			d = 1
	if d == 0:
		print('YES')
	else:
		print('NO')


def function(n, nums):
	l = 0
	r = len(nums) - 1
	nums.sort()
	total = nums[0] * nums[-1]
	while l < r:
		c = nums[l] * nums[r]
		if c != total:
			return 'NO'
		if nums[l + 1] != nums[l] or nums[r - 1] != nums[r]:
			return 'NO'
		l += 2
		r -= 2
	return 'YES'
t = int(input())
for k1 in range(t):
	n = int(input())
	nums = list(map(int, input().rstrip().split()))
	print(function(n, nums))


q = int(input())
for i in range(q):
	n = int(input())
	x = sorted(list(map(int, input().split(' '))))
	a = [x[j] * x[4 * n - 1 - j] for j in range(0, 4 * n, 2)]
	print('YES' if x[::2] == x[1::2] and len(set(a)) == 1 else 'NO')


for _ in range(int(input())):
	n = int(input())
	flag = 0
	l = [int(x) for x in input().split()]
	l.sort()
	t = l[0] * l[-1]
	d = []
	for i in range(len(l)):
		if l.count(l[i]) % 2 != 0:
			flag = 1
			break
		elif l[i] * l[-(i + 1)] == t:
			continue
		else:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


from collections import defaultdict as DD
from bisect import bisect_left as BL
from bisect import bisect_right as BR
from itertools import combinations as IC
from itertools import permutations as IP
from random import randint as RI
import sys
import math
MOD = pow(10, 9) + 7
from math import gcd

def IN(f=0):
	if f == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
tc = IN(1)
for _ in range(tc):
	n = 4 * IN(1)
	a = IN()
	a.sort()
	i = 0
	j = n - 1
	s = set()
	f = 0
	while i < j:
		if a[i] != a[i + 1] or a[j] != a[j - 1]:
			f = 1
			break
		s.add(a[i] * a[j])
		i = i + 2
		j = j - 2
	if f == 0 and len(s) == 1:
		print('YES')
	else:
		print('NO')


def solve(arr):
	n = len(arr)
	arr.sort()
	area = arr[0] * arr[-1]
	flag = True
	for i in range(0, n, 2):
		if arr[i] != arr[i + 1]:
			flag = False
			return 'NO'
	i = 0
	j = n - 1
	while i < j:
		curarea = arr[i] * arr[j]
		if area != curarea:
			return 'NO'
		i += 2
		j -= 2
	return 'YES'

def main():
	n = int(input())
	for _ in range(n):
		num = int(input())
		arr = list(map(int, input().rstrip().split()))
		ans = solve(arr)
		print(ans)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	w = list(map(int, input().split()))
	w.sort()
	u = [0] * (2 * n)
	ok = True
	for i in range(0, 4 * n, 2):
		if w[i] != w[i + 1]:
			ok = False
			break
		u[i // 2] = w[i]
	if not ok:
		print('NO')
		continue
	ans = u[0] * u[-1]
	for i in range(1, n):
		if u[i] * u[-i - 1] != ans:
			ok = False
			break
	if ok:
		print('YES')
	else:
		print('NO')


from collections import Counter

def solve(a, n):
	d = Counter(a)
	for i in d:
		if d[i] % 2:
			return 'NO'
	new = []
	for i in d:
		for j in range(d[i] // 2):
			new.append(i)
	new.sort()
	ans = []
	(l, r) = (0, len(new) - 1)
	while l < r:
		ans.append(new[l] * new[r])
		r -= 1
		l += 1
	if ans.count(ans[0]) == n:
		return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(solve(a, n))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	i = 0
	j = len(arr) - 1
	area = arr[0] * arr[j]
	flag = 1
	while i < j:
		if arr[i] == arr[i + 1] and arr[j] == arr[j - 1] and (area == arr[i] * arr[j]):
			i += 2
			j -= 2
		else:
			flag = 0
			break
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	for i in range(0, 4 * n, 2):
		if a[i] == a[i + 1]:
			pass
		else:
			print('NO')
			break
	else:
		area = a[0] * a[-1]
		for i in range(n):
			if a[2 * i] * a[-2 * i - 1] == area:
				pass
			else:
				print('NO')
				break
		else:
			print('YES')


q = int(input())
while q:
	n = int(input())
	a = input().split()
	for i in range(4 * n):
		a[i] = int(a[i])
	a.sort()
	count = 0
	value = a[0] * a[4 * n - 1]
	j = 0
	while j <= 2 * n - 2:
		if a[j] == a[j + 1] and a[4 * n - j - 1] == a[4 * n - j - 2]:
			if a[j] * a[4 * n - j - 1] == value:
				count += 1
		j += 2
	if count == n:
		print('YES')
	else:
		print('NO')
	q -= 1


q = int(input())
while q:
	res = True
	n = int(input())
	lista = [int(x) for x in input().split()]
	lista.sort()
	tam = len(lista) - 1
	ini = 0
	aux = []
	while ini <= tam:
		if lista[ini] != lista[ini + 1] or lista[tam] != lista[tam - 1]:
			res = False
			break
		area = lista[ini] * lista[tam]
		ini += 2
		tam -= 2
		if len(aux) == 0:
			aux.append(area)
			continue
		if area not in aux:
			res = False
			break
	if res:
		print('YES')
	else:
		print('NO')
	q -= 1


I = lambda : map(int, input().split())
for i in range(int(input())):
	res = 0
	n = int(input())
	a = sorted(list(I()))
	area = -1
	ind1 = 0
	ind2 = 4 * n - 1
	while ind1 < ind2:
		if a[ind1] == a[ind1 + 1] and a[ind2] == a[ind2 - 1]:
			area1 = a[ind1] * a[ind2]
			if area == -1:
				area = area1
			if area != area1:
				res = 1
				break
			else:
				ind1 += 2
				ind2 -= 2
		else:
			res = 1
			break
	print('YNEOS'[res::2])


for _ in range(int(input())):
	n = int(input())
	sticks = list(map(int, input().strip().split()))
	sticks.sort()
	areas = []
	eq = []
	for _ in range(n):
		(a, b, *sticks, c, d) = sticks
		eq.append(a == b and c == d)
		areas.append(a * c)
	print('YES' if all(eq) and all((areas[0] == a for a in areas)) else 'NO')


q = int(input())
for Q in range(q):
	n = int(input())
	arr = list(map(int, input().split()))
	arr2 = []
	unused = set()
	for i in arr:
		if i not in unused:
			unused.add(i)
		else:
			arr2.append(i)
			unused.remove(i)
	if len(unused) != 0:
		print('NO')
	else:
		flag = True
		arr2.sort()
		s = arr2[0] * arr2[-1]
		arr2 = arr2[1:-1]
		while len(arr2) != 0:
			s2 = arr2[0] * arr2[-1]
			if s2 != s:
				print('NO')
				flag = False
				break
			else:
				arr2 = arr2[1:-1]
		if flag:
			print('YES')


def nextInt():
	return int(input())

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

def solve():
	n = nextInt()
	a = nextInts()
	a.sort()
	area = -1
	for i in range(n):
		if a[2 * i] != a[2 * i + 1]:
			return False
		if a[4 * n - 1 - 2 * i] != a[4 * n - 2 - 2 * i]:
			return False
		tmp = a[2 * i] * a[4 * n - 1 - 2 * i]
		if area == -1:
			area = tmp
		elif area != tmp:
			return False
	return True
q = nextInt()
for i in range(q):
	print('YES' if solve() else 'NO')


def f(l, n):
	l.sort()
	x = l[0] * l[-1]
	for i in range(n):
		(n1, n2, n_1, n_2) = (l[2 * i], l[2 * i + 1], l[-2 * i - 1], l[-2 * i - 2])
		if n1 != n2 or n_1 != n_2:
			return 'NO'
		if n1 * n_1 != x:
			return 'NO'
	return 'YES'
q = int(input())
for k in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	print(f(l, n))


casos = int(input())
for i in range(casos):
	cuadrados = int(input())
	tam = cuadrados * 4
	longitudes = list(map(int, input().split()))
	longitudes.sort()
	area = longitudes[0] * longitudes[tam - 1]
	ans = True
	for j in range(0, cuadrados):
		if longitudes[2 * j] != longitudes[2 * j + 1] or longitudes[tam - 2 * j - 1] != longitudes[tam - 2 * j - 2]:
			ans = False
			break
		elif longitudes[2 * j] * longitudes[tam - 2 * j - 1] != area:
			ans = False
			break
	if ans:
		print('YES')
	else:
		print('NO')


from collections import Counter
from collections import deque
Q = int(input())
for i in range(Q):
	N = int(input())
	A = list(map(int, input().split()))
	D = Counter(A)
	K = sorted(D.keys())
	L = len(K)
	S = K[0] * K[-1]
	flag = True
	for i in range(L):
		a = K[i]
		b = K[L - 1 - i]
		if D[a] % 2 or D[b] % 2:
			flag = False
			print('No')
			break
		if a == b:
			if D[a] % 4 or a * a != S:
				flag = False
				print('No')
				break
		elif D[a] != D[b] or a * b != S:
			flag = False
			print('No')
			break
	if flag:
		print('Yes')


o = int(input())
for j in range(0, o):
	n = int(input())
	p = input().rstrip().split(' ')
	p.sort(key=int)
	l = []
	q = []
	w = []
	S = []
	D = []
	G = 0
	for i in range(0, n):
		V = p[0:2]
		B = p[len(p) - 2:len(p)]
		del p[0]
		del p[0]
		del p[len(p) - 1]
		del p[len(p) - 1]
		if V[0] == V[1] and B[0] == B[1]:
			l.append(int(V[0]) * int(B[0]))
		else:
			G = 1
			break
	if G == 1:
		print('NO')
	elif len(list(set(l))) == 1:
		print('YES')
	else:
		print('NO')


q = int(input())
ansar = []
for i in range(q):
	S = []
	y = []
	n = int(input())
	x = list(map(int, input().split()))
	x.sort()
	for j in range(4 * n):
		S.append(x[j] * x[-j - 1])
	for k in range(0, 4 * n, 2):
		if x[k] == x[k + 1]:
			y.append(1)
		else:
			y.append(0)
	if max(S) == min(S) and sum(y) == len(y):
		ansar.append('YES')
	else:
		ansar.append('NO')
print(*ansar, sep='\n')


q = int(input())
for _ in range(q):
	n = int(input())
	aa = list(map(int, input().split()))
	ok = True
	aa.sort()
	area = aa[0] * aa[-1]
	for i in range(n):
		if aa[2 * i] != aa[2 * i + 1] or aa[-2 * i - 1] != aa[-2 * i - 2]:
			ok = False
			break
		if aa[2 * i] * aa[-2 * i - 1] != area:
			ok = False
			break
	if ok:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	a = [int(i) for i in input().split()]
	a = sorted(a)
	n = len(a)
	b = a[:n // 2]
	c = a[n // 2:]
	c = c[::-1]
	sides = list(zip(b, c))
	res = sides[0][0] * sides[0][1]
	ans = 'YES'
	for (s1, s2) in sides:
		if s1 * s2 != res:
			ans = 'NO'
	for i in range(0, n, 2):
		if a[i] != a[i + 1]:
			ans = 'NO'
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = sorted(map(int, input().split()))
	b = a[::-1]
	d = dict()
	for i in range(len(a)):
		d[a[i] * b[i]] = 1
	print('YNEOS'[not (len(d) == 1 and a[::2] == a[1::2])::2])


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	area = arr[0] * arr[-1]
	flag = True
	for i in range(n):
		if arr[2 * i] != arr[2 * i + 1] or arr[4 * n - 2 * i - 1] != arr[4 * n - 1 - 2 * i - 1] or arr[2 * i] * arr[4 * n - 2 * i - 1] != area:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')
	t = t - 1


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	l = sorted(l)
	x = 0
	for i in l:
		x ^= i
	if x != 0:
		print('NO')
		continue
	dic = []
	for i in range(0, len(l), 2):
		dic.append(l[i])
	dic = sorted(dic)
	i = 0
	j = len(dic) - 1
	p = dic[0] * dic[j]
	done = False
	while i < j:
		if dic[i] * dic[j] != p:
			print('NO')
			done = True
			break
		i += 1
		j -= 1
	if done == False:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	ck = 1
	comp = lst[0] * lst[4 * n - 1]
	for i in range(0, 2 * n, 2):
		if lst[i] * lst[4 * n - i - 1] != comp:
			ck = 0
			break
		if lst[i] != lst[i + 1] or lst[4 * n - i - 1] != lst[4 * n - i - 2]:
			ck = 0
			break
	if ck:
		print('YES')
	else:
		print('NO')


from collections import Counter

def solve():
	n = int(input())
	a = [int(x) for x in input().split()]
	c = Counter(a)
	for (a, b) in c.most_common():
		if b % 2 != 0:
			print('NO')
			return
	ls = [a for (a, b) in c.most_common() for _ in range(b // 2)]
	ls.sort()
	(l, r) = (0, len(ls) - 1)
	s = set()
	while l < r:
		s.add(ls[l] * ls[r])
		l += 1
		r -= 1
	if len(s) == 1:
		print('YES')
	else:
		print('NO')
for _ in range(int(input())):
	solve()


from sys import stdin
for i in range(int(stdin.readline())):
	n = int(stdin.readline())
	data = sorted(list(map(int, stdin.readline().split())))
	p = f = 0
	(i, j) = (0, n * 4 - 1)
	while j > i:
		if data[i] == data[i + 1] and data[j] == data[j - 1]:
			s = data[i] * data[j]
		else:
			f = 1
			break
		if p and p != s:
			f = 1
			break
		else:
			p = s
		i += 2
		j -= 2
	if not f:
		print('YES')
	else:
		print('NO')


def compare(l, w):
	lengths = a.count(l)
	widths = a.count(w)
	if lengths % 2 != 0 or widths % 2 != 0:
		return False
	if l == w:
		if lengths % 4 == 0:
			return True
		else:
			return False
	if lengths == widths:
		return True
	else:
		return False
for _ in range(int(input())):
	f_n = int(input())
	a = sorted(list(map(int, input().split())))
	if 0 in a:
		print('NO')
		continue
	st = sorted(set(a))
	set_len = len(st)
	if set_len == 1:
		print('YES')
		continue
	area = st[0] * st[-1]
	i = 0
	flag = True
	while i < set_len:
		w = area / st[i]
		if not compare(st[i], w):
			flag = False
			print('NO')
			break
		i += 1
	if flag:
		print('YES')


from math import *
a = int(input())
for x in range(a):
	b = int(input())
	c = list(map(int, input().split()))
	c.sort()
	t = 0
	m = 0
	for y in range(0, 4 * b // 2, 2):
		if y == 0:
			if c[y] == c[y + 1] and c[4 * b - y - 1] == c[4 * b - y - 2]:
				t = c[y] * c[4 * b - y - 1]
			else:
				m = -1
				break
		elif c[y] * c[4 * b - y - 1] != t or c[y] != c[y + 1] or c[4 * b - y - 1] != c[4 * b - y - 2]:
			m = -1
			break
	if m == -1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	p = 4 * n
	area = []
	ok = True
	i = 0
	while i < 2 * n - 1:
		if a[i] == a[i + 1] and a[p - i - 1] == a[p - i - 2]:
			area.append(a[i] * a[p - i - 1])
			i += 2
		else:
			ok = False
			break
	for i in range(len(area) - 1):
		if area[i] != area[i + 1]:
			ok = False
			break
	if not ok:
		print('NO')
	else:
		print('YES')


q = int(input().strip())
for _ in range(q):
	n = int(input().strip())
	nums = [int(i) for i in input().strip().split()]
	nums.sort()
	index_a = 0
	index_b = 4 * n - 1
	pos = True
	prev = -1
	while index_a < index_b:
		if nums[index_a] != nums[index_a + 1]:
			pos = False
			break
		if nums[index_b] != nums[index_b - 1]:
			pos = False
			break
		if prev == -1:
			result = nums[index_b] * nums[index_a]
			prev = 1
		else:
			if result != nums[index_b] * nums[index_a]:
				pos = False
				break
			result = nums[index_b] * nums[index_a]
		index_a += 2
		index_b -= 2
	if pos:
		print('YES')
	else:
		print('NO')


for z in range(int(input())):
	ans = 'YES'
	n = int(input())
	a = []
	pair = set()
	for elem in list(map(int, input().split())):
		if elem in pair:
			pair.remove(elem)
			a.append(elem)
		else:
			pair.add(elem)
	if len(pair) != 0:
		ans = 'NO'
	else:
		a.sort()
		p = a[0] * a[len(a) - 1]
		for i in range(len(a) // 2):
			if a[i] * a[len(a) - i - 1] != p:
				ans = 'NO'
				break
	print(ans)


t = int(input())
while t > 0:
	n = int(input())
	a = []
	a = list(map(int, input().split()))
	mp = {}
	ma = 0
	mi = 10000.0
	for i in range(4 * n):
		if a[i] not in mp:
			mp[a[i]] = 1
		else:
			mp[a[i]] = mp[a[i]] + 1
		mi = min(mi, a[i])
		ma = max(ma, a[i])
	k = mi * ma
	f = 1
	for i in mp.keys():
		if mp[i] % 2 != 0:
			f = 0
			break
		if k % i != 0 and i != 1:
			f = 0
			break
		if k / i not in mp:
			f = 0
			break
		if mp[k / i] != mp[i]:
			f = 0
			break
		mp[k / i] = mp[k / i] - mp[i]
		mp[i] = 0
	if f:
		print('YES')
	else:
		print('NO')
	t = t - 1


q = int(input())
for x in range(q):
	n = 4 * int(input()) - 1
	possible = True
	sticks = sorted([int(i) for i in input().split()])
	area = sticks[0] * sticks[n]
	while sticks:
		if sticks[0] * sticks[n] != area:
			print('NO')
			possible = False
			break
		elif sticks[0] != sticks[1] or sticks[n - 1] != sticks[n]:
			print('NO')
			possible = False
			break
		del sticks[n]
		del sticks[n - 1]
		del sticks[1]
		del sticks[0]
		n -= 4
	if possible:
		print('YES')


q = int(input())
for i in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	k = l[0] * l[4 * n - 1]
	x = 0
	for j in range(0, 4 * n, 2):
		if l[j] != l[j + 1] or l[j] * l[4 * n - 1 - j] != k:
			print('NO')
			x += 1
			break
	if x == 0:
		print('YES')


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	A = [int(_) for _ in input().split()]
	D = Counter(A)
	A = []
	for _ in D:
		if D[_] % 2 == 1:
			print('NO')
			break
		A.extend([_] * (D[_] // 2))
	else:
		A.sort()
		x = A[0] * A[-1]
		n = len(A)
		for _ in range(n):
			if x != A[_] * A[n - _ - 1]:
				print('NO')
				break
		else:
			print('YES')


def get_number(A):
	B = {}
	for i in A:
		B[i] = B.get(i, 0) + 1
	return B

def process(A, n):
	C = get_number(A)
	flag = True
	for i in C.values():
		if i % 2 == 1:
			flag = False
			break
	if flag:
		A.sort()
		B = []
		for i in range(0, len(A) - 1, 2):
			B.append([A[i], A[i + 1]])
		area = B[0][0] * B[len(B) - 1][1]
		res = 1
		for i in range(1, len(B) // 2):
			if B[i][0] * B[len(B) - i - 1][1] == area:
				res = res + 1
		if res == n:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
n = int(input())
for i in range(n):
	k = int(input())
	B = []
	for x in input().split():
		B.append(int(x))
	process(B, k)


q = int(input().strip())
for i in range(q):
	n = int(input().strip())
	a = input().strip().split()
	a = list(map(int, a))
	a.sort()
	truefalse = True
	v = len(a)
	s = a[0] * a[v - 1]
	for j in range(0, 2 * n, 2):
		if s == a[j] * a[v - j - 1] and a[j] == a[j + 1] and (a[v - j - 1] == a[v - j - 2]):
			continue
		else:
			truefalse = False
	if truefalse == True:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	l = [int(x) for x in input().split()][0:4 * n]
	res = True
	sides = dict()
	for a in l:
		if a in sides:
			sides[a] += 1
		else:
			sides[a] = 1
	for k in sides.values():
		if k % 2 > 0:
			res = False
			break
	l = []
	if res:
		for (side, count) in sides.items():
			for i in range(count // 2):
				l.append(side)
		l.sort()
		s = l.pop(0) * l.pop()
		while len(l) > 0:
			if l.pop(0) * l.pop() != s:
				res = False
				break
	if res:
		print('YES')
	else:
		print('NO')


q = int(input())
for I in range(q):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	st = 0
	en = 4 * n - 1
	poss = 1
	curr_area = -1
	while st < en:
		if a[st] != a[st + 1] or a[en] != a[en - 1]:
			poss = 0
			break
		if curr_area == -1:
			curr_area = a[st] * a[en]
		else:
			temp = a[st] * a[en]
			if temp != curr_area:
				poss = 0
				break
		st += 2
		en -= 2
	if poss:
		print('YES')
	else:
		print('NO')


def solve(rec, nr):
	rec.sort()
	i = 0
	prev_area = 0
	area = 0
	list_len = nr * 4
	while i < list_len / 2:
		if rec[i] != rec[i + 1]:
			return 'NO'
		a = rec[i]
		if rec[list_len - i - 1] != rec[list_len - i - 2]:
			return 'NO'
		b = rec[list_len - i - 1]
		if nr == 1:
			return 'YES'
		prev_area = area
		area = a * b
		if i == 0:
			i += 2
			continue
		if prev_area != area:
			return 'NO'
		i += 2
	return 'YES'
nq = int(input())
res = []
for i in range(nq):
	nr = int(input())
	rec = list(map(int, input().split()))
	res.append(solve(rec, nr))
for r in res:
	print(r)


queries = int(input())

def checksides(list):
	for i in range(0, len(list), 2):
		if list[i] != list[i + 1]:
			return False
	return True

def sides(list):
	resp = []
	for i in range(0, len(list), 2):
		resp.append(list[i])
	return resp

def check_areas(sides_list):
	if len(sides_list) == 2:
		return True
	j = len(sides_list) - 1
	for i in range(len(sides_list) // 2):
		if sides_list[i] * sides_list[j] != sides_list[i + 1] * sides_list[j - 1]:
			return False
		j -= 1
	return True
for query in range(queries):
	num_rect = int(input())
	sticks = sorted(list(map(int, input().split())))
	if checksides(sticks):
		sidesList = sides(sticks)
		if check_areas(sidesList):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	B = {}
	for i in A:
		if i not in B:
			B[i] = 0
		B[i] += 1
	ans = 'YES'
	J = []
	for i in B:
		if B[i] % 2:
			ans = 'NO'
			break
		else:
			for _ in range(B[i] // 2):
				J.append(i)
	if ans == 'YES':
		J.sort()
		s = set()
		for i in range(n):
			s.add(J[i] * J[-i - 1])
		if len(s) != 1:
			ans = 'NO'
	print(ans)


q = int(input())
for _ in range(q):
	n = int(input())
	a = list(map(int, input().split()))

	def solve(a):
		from collections import Counter
		c = Counter(a)
		keys = sorted(c)
		for key in keys:
			if c[key] % 2 != 0:
				return False
		temp = [[k] * c[k] for k in keys]
		keys = []
		for t in temp:
			keys += t
		area = keys[0] * keys[-1]
		head = 0
		tail = len(keys) - 1
		if len(keys) % 2 != 0:
			return False
		while head < tail:
			if keys[head] * keys[tail] != area:
				return False
			head += 1
			tail -= 1
		return True
	print('YES' if solve(a) else 'NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ar = a[0] * a[-1]
	check = 0
	i = 0
	while check == 0 and i < n:
		lf = i * 2
		rg = 4 * n - i * 2 - 1
		if a[lf] != a[lf + 1] or a[rg] != a[rg - 1] or a[lf] * a[rg] != ar:
			check += 1
		i += 1
	if check == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	c = -1
	for i in l:
		try:
			d[i] += 1
		except KeyError:
			d[i] = 1
	for i in d.values():
		if i % 2 != 0:
			c = 1
			break
	if c == 1:
		print('NO')
	else:
		c1 = 0
		l.sort()
		a = l[0] * l[len(l) - 1]
		if l[1] * l[len(l) - 2] == a:
			c1 += 1
		for i in range(2, len(l) // 2, 2):
			b = l[i] * l[len(l) - i - 1]
			c = l[i + 1] * l[len(l) - (i + 1) - 1]
			if b == a and c == a:
				c1 += 1
		if c1 != n:
			print('NO')
		else:
			print('YES')
	t -= 1


q = int(input())

def ver(p, n):
	p.sort()
	for i in range(0, 4 * n, 2):
		if p[i] != p[i + 1]:
			return False
	i = 0
	j = 4 * n - 2
	d = p[i] * p[j]
	while i < 2 * n and p[i] * p[j] == d:
		i += 2
		j -= 2
	if i >= 2 * n:
		return True
	return False
for i in range(q):
	n = int(input())
	p = list(map(int, input().split()))
	if ver(p, n):
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline

def query(n, A):
	A.sort()
	B = []
	for i in range(0, n * 4, 2):
		if A[i] != A[i + 1]:
			return 'NO'
		B.append(A[i])
	s = B[0] * B[-1]
	for i in range(n * 2):
		if B[i] * B[-i - 1] != s:
			return 'NO'
	return 'YES'
q = int(input())
for _ in range(q):
	n = int(input())
	A = list(map(int, input().split()))
	print(query(n, A))


le = int(input())
for _ in range(le):
	n = int(input())
	ar = list(map(int, input().split()))
	ar.sort()
	flag = flag1 = True
	if ar[-1] == ar[-2] and ar[0] == ar[1]:
		area = ar[-1] * ar[0]
	else:
		flag = False
		flag1 = False
	if flag:
		for i in range(1, n):
			id = i * 2
			if ar[id] == ar[id + 1] and ar[-id - 1] == ar[-id - 2]:
				if ar[id + 1] * ar[-id - 2] != area:
					flag1 = False
					break
			else:
				flag1 = False
				break
	if flag1:
		print('YES')
	else:
		print('NO')


n = int(input())
m = []
for l in range(n):
	s = int(input())
	b = list(map(int, input().split()))
	b.sort()
	q = 1
	d = set(b)
	d = list(d)
	for h in range(len(d)):
		f = b.count(d[h])
		if f % 2 != 0:
			m.append('NO')
			q = 0
			break
	if q == 1:
		k = 0
		c = []
		for i in range(int(len(b) / 4)):
			x = b[k + 1] * b[len(b) - 2 - k]
			k = k + 2
			c.append(x)
		c = set(c)
		if len(c) == 1:
			m.append('YES')
		else:
			m.append('NO')
for h in m:
	print(h)


q = int(input())
for i in range(q):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	flag = 1
	ar = -1
	b = []
	for j in range(0, 4 * n, 2):
		if a[j] != a[j + 1]:
			flag = 0
			break
		b.append(a[j])
	if flag == 0:
		print('NO')
	else:
		for j in range(n):
			r = b[j] * b[-1 - j]
			if ar == -1:
				ar = r
			elif ar != r:
				flag = 0
				break
		if flag == 0:
			print('NO')
		else:
			print('YES')


q = int(input())
for i in range(q):
	n = int(input())
	a = [int(x) for x in input().split()[:4 * n]]
	a.sort()
	area = []
	sat = True
	for j in range(0, 4 * n, 2):
		if a[j] != a[j + 1]:
			print('NO')
			sat = False
			break
	if sat:
		for j in range(0, 2 * n, 2):
			sat = True
			newArea = a[j] * a[4 * n - 2 - j]
			area.append(newArea)
			if newArea != area[0]:
				sat = False
				print('NO')
				break
		if sat:
			print('YES')


q = int(input())
for query in range(q):
	n = int(input())
	A = []
	was = dict()
	B = list(map(int, input().split()))
	for i in range(4 * n):
		x = B[i]
		if x not in was or was[x] == 0:
			was[x] = 1
			A.append(x)
		else:
			was[x] = 0
	A.sort()
	if len(A) != 2 * n:
		print('NO')
		continue
	S = [A[i] * A[-i - 1] for i in range(n)]
	if max(S) != min(S):
		print('NO')
	else:
		print('YES')


import math
from collections import Counter, defaultdict
from sys import stdin, stdout
input = stdin.readline
li = lambda : list(map(int, input().split()))
m = int(input())
for i in range(0, m):
	n = int(input())
	a = li()
	a.sort()
	p = a[0] * a[len(a) - 1]
	f = 0
	for i in range(0, len(a) // 2):
		if p != a[i] * a[len(a) - i - 1]:
			f = 1
			break
	for i in range(0, len(a), 2):
		if a[i] != a[i + 1]:
			f = 1
			break
	if f == 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input()) * 4
	a = list(map(int, input().split()))
	a.sort()
	s = a[0] * a[n - 1]
	l = 0
	r = n - 1
	fl = True
	while l < r:
		if a[l] == a[l + 1] and a[r] == a[r - 1] and (a[l] * a[r] == s):
			l += 2
			r -= 2
		else:
			fl = False
			break
	if fl:
		print('YES')
	else:
		print('NO')


x = int(input())
for __ in range(x):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = a[0] * a[4 * n - 1]
	f = 0
	i = 0
	j = 4 * n - 1
	while i < j:
		if a[i] * a[j] == b and a[i] == a[i + 1] and (a[j] == a[j - 1]):
			i += 2
			j -= 2
		else:
			f = 1
			break
	if f == 1:
		print('NO')
	else:
		print('YES')


q = int(input())

def query():
	n = int(input())
	a = list(map(lambda n: int(n), input().split()))
	a.sort()
	max_area = min(a) * max(a)
	s = set(a)
	for i in s:
		y = max_area / i
		if y not in s or a.count(i) % 2 != 0 or a.count(y) % 2 != 0 or (a.count(i) != a.count(y)):
			return 'NO'
	return 'YES'
for i in range(q):
	print(query())


for i in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	b.sort()
	unique = []
	s = []
	t = []
	flag = True
	for num in b:
		if b.count(num) % 2 == 0:
			continue
		else:
			flag = False
			break
	if flag == False:
		print('NO')
	elif len(b) % 4 != 0:
		print('NO')
	else:
		for i in range(0, len(b), 2):
			t.append(b[i])
		x = t[:len(t) // 2]
		y = t[len(t) // 2:]
		y.sort(reverse=True)
		d = []
		for z in range(len(y)):
			d.append(y[z] * x[z])
		if d.count(d[0]) == len(d):
			print('YES')
		else:
			print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	A = list((int(i) for i in input().split()))
	A.sort()
	B = []
	f = True
	for i in range(0, 4 * n - 1, 2):
		if A[i] == A[i + 1]:
			B.append(A[i])
		else:
			f = False
			break
	if f is True:
		prev = -1
		p = True
		for i in range(n):
			ans = B[i] * B[2 * n - 1 - i]
			if prev == -1:
				prev = ans
			elif prev != ans:
				p = False
				break
		if p is True:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import sys

def input_from_file(file_name):
	sys.stdin = open(file_name, 'r')

def filter_data(data, type):
	if type == 'list':
		return data
	else:
		return data[0]
take_input = lambda data_type: [data_type(x) for x in input().split(' ')]
cin = lambda data_type, type: filter_data(take_input(data_type), type)

def main():
	q = cin(int, 'single')
	while q:
		q -= 1
		n = cin(int, 'single')
		data = cin(int, 'list')
		data.sort()
		complete_data = []
		for ind in range(2 * n):
			complete_data.append([data[2 * ind], data[2 * ind + 1], data[4 * n - 2 * ind - 1], data[4 * n - 2 * ind - 2]])
		area = set()
		pos = True
		for x in complete_data:
			if x[0] != x[1] or x[2] != x[3]:
				pos = False
			else:
				area.add(x[0] * x[3])
		if pos == True and len(area) == 1:
			print('YES')
		else:
			print('NO')
main()


def is_area_equal(arr, n):
	arr.sort()
	j = 0
	while j < n * 4:
		if arr[j] == arr[j + 1]:
			j = j + 2
		else:
			return 'NO'
	area = arr[0 * 2] * arr[(n * 2 - 0 - 1) * 2]
	for i in range(1, n):
		if arr[i * 2] * arr[(n * 2 - (i + 1)) * 2] == area:
			continue
		else:
			return 'NO'
	return 'YES'
q = int(input())
ans = ''
for i in range(q):
	n = int(input())
	arr = input()
	arr = list(arr.split(' '))
	for j in range(len(arr)):
		arr[j] = int(arr[j])
	ans = ans + is_area_equal(arr, n) + '\n'
print(ans)


import io, os
q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	(mn, mx) = (10 ** 18, 0)
	for c in a:
		if c < mn:
			mn = c
		if c > mx:
			mx = c
		d[c] = d.get(c, 0) + 1
	s = mn * mx
	f = True
	for c in d:
		if not (d[c] % 2 == 0 and s % c == 0 and (d.get(s // c, 0) == d[c])):
			f = False
			print('NO')
			break
	if f:
		print('YES')


q = int(input())
for i in range(q):
	n = int(input())
	a = [int(item) for item in input().split()]
	a.sort()
	length = len(a)
	is_no = False
	for i in range(length // 2):
		if a[i * 2] != a[i * 2 + 1]:
			is_no = True
			break
		if i == 0:
			S = a[i * 2] * a[length - 1 - i * 2]
		if S != a[i * 2] * a[length - 1 - i * 2]:
			is_no = True
			break
	if is_no:
		print('NO')
	else:
		print('YES')


from collections import Counter

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	c = Counter(a)
	b = list(c.items())
	b.sort()
	i = 0
	j = len(b) - 1
	exp = b[0][0] * b[-1][0]
	while i < len(b):
		assert all((b[i][1] % 2 == 0, b[j][1] % 2 == 0, b[i][0] * b[j][0] == exp, b[i][1] == b[j][1]))
		if i == j:
			assert b[i][1] % 4 == 0
		i += 1
		j -= 1

def main():
	q = int(input())
	for _ in range(q):
		try:
			solve()
		except AssertionError:
			print('NO')
		else:
			print('YES')
main()


def split(rec_sides):
	trac_set = set()
	(l1, l2) = ([], [])
	for s in rec_sides:
		if s not in trac_set:
			trac_set.add(s)
			l1.append(s)
		elif s in trac_set:
			trac_set.remove(s)
			l2.append(s)
	return (l1, l2)

def decide_divis(l1, target):
	for i in range(int(len(l1) / 2)):
		if l1[i] * l1[-1 * i - 1] != target:
			return 'NO'
	return 'YES'
num_q = int(input())
for q in range(num_q):
	num_rec = int(input())
	rec_sides = list(map(int, input().split(' ')))
	(l1, l2) = split(rec_sides)
	if len(l1) != len(l2):
		print('NO')
		continue
	l1.sort()
	target = l1[0] * l1[-1]
	print(decide_divis(l1, target))


q = int(input())
for query in range(q):
	n = int(input())
	a = list(map(int, input().split(' ')))
	n1 = 4 * n
	i = 0
	j = n1 - 1
	flag = 0
	a = sorted(a)
	area = a[0] * a[-1]
	while i < j:
		if a[i] != a[i + 1] or a[j] != a[j - 1]:
			flag = 1
			break
		if a[i] * a[j] != area or a[i + 1] * a[j - 1] != area:
			flag = 1
			break
		i += 2
		j -= 2
	if flag == 1:
		print('NO')
	else:
		print('YES')
	flag = 0


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	area = []
	a.sort()
	i = 0
	f = 1
	for i in range(0, 4 * n, 2):
		if a[i] != a[i + 1]:
			print('NO')
			f = 0
			break
	if f == 1:
		ar = a[0] * a[-1]
		for i in range(n):
			if ar != a[2 * i] * a[n * 4 - 2 * i - 1]:
				f = 0
				print('NO')
				break
	if f == 1:
		print('YES')


def naiveSolve(n):
	return
from collections import Counter

def solve():
	n = int(input())
	a = readIntArr()
	cnts = Counter(a)
	for (k, v) in cnts.items():
		if v % 2 == 1:
			print('NO')
			return
		cnts[k] //= 2
	desiredArea = min(cnts.keys()) * max(cnts.keys())
	for (k, v) in cnts.items():
		if desiredArea % k != 0:
			print('NO')
			return
		other = desiredArea // k
		if other == k:
			if v % 2 == 1:
				print('NO')
				return
		elif cnts[k] != cnts[other]:
			print('NO')
			return
	print('YES')
	return

def main():
	q = int(input())
	for _ in range(q):
		solve()
	return
import sys
input = sys.stdin.buffer.readline

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultValFactory, dimensionArr):
	dv = defaultValFactory
	da = dimensionArr
	if len(da) == 1:
		return [dv() for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(l, r):
	print('? {} {}'.format(l, r))
	sys.stdout.flush()
	return int(input())

def answerInteractive(x):
	print('! {}'.format(x))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
from math import gcd, floor, ceil
for _abc in range(1):
	main()


T = int(input())
for _ in range(T):
	N = int(input())
	nums = sorted((int(i) for i in input().split()))
	print('YNEOS'[not (len({a1 * a2 for (a1, a2) in zip(nums, nums[::-1])}) == 1 and nums[::2] == nums[1::2])::2])


for _ in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	d = {}
	c = []
	for i in b:
		try:
			k = d[i]
			d[i] += 1
			k += 1
			if k == 2:
				c.append(i)
				d[i] = 0
		except KeyError:
			d[i] = 1
	c.sort()
	if len(c) != 2 * a:
		print('NO')
	else:
		ans = 0
		l = c[0] * c[-1]
		z = 0
		for i in range(a):
			if l != c[i] * c[2 * a - 1 - i]:
				z = 1
				break
		if z == 0:
			print('YES')
		else:
			print('NO')


q = int(input())
for query in range(q):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	a_dict = {}
	ans = 'YES'
	for item in a:
		if item in a_dict.keys():
			a_dict[item] += 1
		else:
			a_dict[item] = 1
	for x in a_dict.values():
		if x % 2 == 1:
			ans = 'NO'
			break
	a.sort()
	a_prods = [a[i] * a[-i - 1] for i in range(2 * n)]
	if len(set(a_prods)) > 1:
		ans = 'NO'
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = sorted([int(x) for x in input().split()])
	add = a[0] * a[-1]
	ans = True
	for i in range(len(a) // 2):
		if add != a[i] * a[-i - 1]:
			ans = False
			break
	for i in range(1, len(a), 2):
		if a[i] != a[i - 1]:
			ans = False
			break
	print('YES' if ans else 'NO')


def func(n, list):
	list.sort()
	i = 0
	j = len(list) - 1
	value = list[i] * list[j]
	for k in range(2 * n):
		if list[i] == list[i + 1]:
			i += 2
		else:
			return False
	i = 0
	for f in range(n):
		if list[i] * list[j] == value:
			i += 2
			j -= 2
		else:
			return False
	return True
for i in range(int(input())):
	if func(int(input()), list(map(int, input().split()))):
		print('YES')
	else:
		print('NO')


t = int(input())
for itttt in range(t):
	s = int(input())
	m = list(map(int, input().split()))
	m.sort()
	d = {}
	for i in range(4 * s):
		try:
			d[m[i]] = d[m[i]] + 1
		except KeyError:
			d[m[i]] = 1
	ans = True
	val = list(d.keys())
	val.sort()
	for i in val:
		if d[i] % 2 != 0:
			ans = False
			break
	if ans:
		area = []
		p1 = 0
		p2 = len(val) - 1
		while p2 >= p1:
			c1 = d[val[p1]]
			c2 = d[val[p2]]
			if c1 == c2:
				area.append(val[p1] * val[p2])
				d[val[p1]] = 0
				d[val[p2]] = 0
				p2 = p2 - 1
				p1 = p1 + 1
			elif c1 < c2:
				area.append(val[p1] * val[p2])
				d[val[p2]] = c2 - c1
				d[val[p1]] = 0
				p1 = p1 + 1
			elif c1 > c2:
				area.append(val[p1] * val[p2])
				d[val[p2]] = 0
				d[val[p1]] = c1 - c2
				p2 = p2 - 1
		a = list(set(area))
		if len(a) == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import sys
(mod, MOD) = (1000000007, 998244353)
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd, log10, atan, tan

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	if small[-1] == large[-1]:
		large.pop()
	large.reverse()
	small.extend(large)
	return small

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
T = int(input())
while T > 0:
	n = int(input())
	Arr = get_array()
	Arr.sort()
	n *= 4
	flag = 0
	for i in range(0, n, 2):
		if Arr[i] != Arr[i + 1]:
			flag = 1
			break
	if flag == 1:
		print('NO')
		T -= 1
		continue
	xx = Arr[0] * Arr[-1]
	for i in range(n):
		if Arr[i] * Arr[n - i - 1] != xx:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')
	T -= 1


casos = int(input())
for i in range(casos):
	n = int(input())
	lados = list(map(int, input().split()))
	lados.sort()
	area = lados[0] * lados[4 * n - 1]
	ans = 'YES'
	for j in range(0, n):
		if lados[2 * j] != lados[2 * j + 1] or lados[4 * n - 2 * j - 1] != lados[4 * n - 2 * j - 2]:
			ans = 'NO'
		elif lados[2 * j] * lados[4 * n - 2 * j - 1] != area:
			ans = 'NO'
	print(ans)


n = int(input())
for i in range(n):
	k = int(input())
	idict = {}
	ilist = list(map(int, input().split()))
	for i in ilist:
		if idict.get(i) == None:
			idict[i] = 1
		else:
			idict[i] += 1
	keys = sorted(idict.keys())
	s = keys[0] * keys[-1]
	i = 0
	j = len(keys) - 1
	out = 1
	while i < j:
		if idict[keys[i]] != idict[keys[j]] or idict[keys[i]] % 2 != 0 or idict[keys[j]] % 2 != 0 or (keys[i] * keys[j] != s):
			out = 0
			break
		i += 1
		j -= 1
	if i == j:
		if idict[keys[i]] % 4 != 0 or keys[i] ** 2 != s:
			out = 0
	if out:
		print('YES')
	else:
		print('NO')


def main():
	from collections import deque
	Q = int(input())
	for query in range(Q):
		N = int(input())
		A = [int(i) for i in input().split()]
		A.sort()
		A = deque(A)
		area = -1
		for _ in [0] * N:
			a = A.popleft()
			b = A.popleft()
			c = A.pop()
			d = A.pop()
			if a != b or c != d:
				print('NO')
				break
			if area == -1:
				area = a * c
			elif area != a * c:
				print('NO')
				break
		else:
			print('YES')
main()


q = int(input())
for _ in range(q):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	l = 4 * n
	flag = 1
	area = arr[0] * arr[l - 1]
	for i in range(0, l // 2, 2):
		if arr[i] * arr[l - i - 1] != area:
			flag = 0
			break
		if arr[i] != arr[i + 1] or arr[l - i - 1] != arr[l - i - 2]:
			flag = 0
			break
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	A = sorted(map(int, input().split()))
	print('YES' if len({A[i] * A[-i - 1] for i in range(2 * n)}) < 2 and all((A[2 * i] == A[2 * i + 1] for i in range(2 * n))) else 'NO')


q = int(input())
for _ in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in a:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	s = sorted(d)
	l = len(s)
	if l % 2 == 0:
		p = l // 2
	else:
		p = l // 2 + 1
	f = s[-1] * s[0]
	tag = True
	for i in range(p):
		if i == l - i - 1:
			if s[i] * s[i] == f:
				if d[s[i]] % 4 == 0:
					pass
				else:
					tag = False
					break
			else:
				tag = False
				break
		elif s[i] * s[l - i - 1] == f:
			if d[s[i]] == d[s[l - i - 1]]:
				if d[s[i]] % 2 == 0:
					pass
				else:
					tag = False
					break
			else:
				tag = False
				break
		else:
			tag = False
			break
	if tag:
		print('YES')
	else:
		print('NO')


t = int(input())
for y in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = dict()
	for i in l:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	l = list(set(l))
	l.sort()
	low = 0
	up = len(l) - 1
	pro = l[low] * l[up]
	f = 0
	while low <= up:
		if not (d[l[up]] == d[l[low]] and d[l[up]] % 2 == 0 and (l[low] * l[up] == pro)):
			f = 1
			break
		up -= 1
		low += 1
	if f == 1:
		print('NO')
	else:
		print('YES')


q = int(input())
for i in range(q):
	n = int(input())
	z = list(map(int, input().split()))
	z.sort()
	ans = []
	for i in range(1, len(z), 2):
		if z[i] == z[i - 1]:
			ans.append(z[i])
	if len(ans) == len(z) / 2:
		flag = True
		area = ans[0] * ans[-1]
		for i in range(len(ans)):
			if ans[i] * ans[len(ans) - i - 1] != area:
				flag = False
		if flag:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for q in range(int(input())):
	n = int(input())
	numeros = list(map(int, input().split()))
	aux = []
	pares = []
	for i in range(4 * n):
		if numeros[i] not in aux:
			aux.append(numeros[i])
		else:
			aux.pop(aux.index(numeros[i]))
			pares.append(numeros[i])
	if len(aux) > 0:
		print('NO')
	else:
		pares.sort()
		c = 1
		resultado = pares[0] * pares[-1]
		while c < n and pares[c] * pares[2 * n - c - 1] == resultado:
			c += 1
		if c == n:
			print('YES')
		else:
			print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	a = sorted(map(int, input().split()))
	s = {a * b for (a, b) in zip(a, a[::-1])}
	if len(s) == 1 and a[::2] == a[1::2]:
		print('YES')
	else:
		print('NO')


from collections import Counter
q = int(input())
for i in range(q):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	c = Counter(A)
	U = []
	b = 1
	for k in c.keys():
		if c[k] % 2 == 1:
			b = 0
		x = c[k] // 2
		U += [k] * x
	d = set()
	for j in range(len(U) // 2):
		d.add(U[j] * U[len(U) - j - 1])
	if len(d) == 1 and b == 1:
		print('YES')
	else:
		print('NO')


import math
import sys
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

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

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)
q = ii()
for i in range(q):
	n = ii()
	d = sorted(li())
	s = d[0] * d[-1]
	last = 4 * n - 1
	f = True
	for i in range(0, 2 * n, 2):
		if d[i] != d[i + 1] or d[last - i] != d[last - i - 1] or d[i] * d[last - i] != s:
			f = False
			break
	print('YES') if f else print('NO')


q = int(input())
while q > 0:
	q -= 1
	n = int(input())
	p = list(map(int, input().split()))
	area = {}
	d = {}
	for i in p:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	key = []
	value = []
	for i in d:
		if d[i] > 1:
			key.append(i)
			value.append(d[i])
	for i in range(len(key)):
		mini = value[i] // 4
		if mini >= 1:
			aa = key[i] * key[i]
			if aa in area:
				area[aa] += mini
			else:
				area[aa] = mini
		for j in range(i + 1, len(key)):
			mini = min(value[i] // 2, value[j] // 2)
			aa = key[i] * key[j]
			if aa in area:
				area[aa] += mini
			else:
				area[aa] = mini
	ans = 'NO'
	for i in area:
		if area[i] == n:
			ans = 'YES'
			break
	print(ans)


from sys import stdin
from sys import setrecursionlimit as SRL
SRL(10 ** 7)
rd = stdin.readline
rrd = lambda : map(int, rd().strip().split())
q = int(input())
while q:
	n = int(input())
	cnt = [0] * (10000 + 10)
	a = list(rrd())
	for i in a:
		cnt[i] += 1
	mn = 1000000
	mx = 0
	for (i, v) in enumerate(cnt):
		if v:
			mn = min(mn, i)
			mx = max(mx, i)
	a = mn * mx
	ok = True
	for (i, v) in enumerate(cnt):
		if v:
			if a % i != 0 or cnt[a // i] != v or v % 2:
				print('NO')
				ok = False
				break
	if ok:
		print('YES')
	q -= 1


import collections
import heapq
import bisect

def solve(A):
	count = collections.Counter(A)
	keys = sorted(count.keys())
	if any((v % 2 for v in count.values())):
		return False
	target = False
	(i, j) = (0, len(keys) - 1)
	while i <= j:
		if not target:
			target = keys[i] * keys[j]
		if i == j:
			if count[keys[i]] % 4 or keys[i] * keys[j] != target:
				return False
		elif count[keys[i]] != count[keys[j]] or keys[i] * keys[j] != target:
			return False
		i += 1
		j -= 1
	return True
q = input()
tests = []
for test in range(int(q)):
	n = input()
	tests.append([int(p) for p in input().split(' ')])
for A in tests:
	print('YES' if solve(A) else 'NO')


for q in range(int(input())):
	n = int(input())
	r = list(map(int, input().split()))
	r.sort()
	cnt = 1
	for i in range(0, 4 * n, 2):
		if r[i] != r[i + 1]:
			cnt = 0
	prod = r[0] * r[4 * n - 1]
	for i in range(0, 2 * n, 2):
		if r[i] * r[4 * n - i - 1] != prod:
			cnt = 0
	if cnt == 1:
		print('YES')
	else:
		print('NO')


import sys

def solve(A, n):
	B = [0 for i in range(max(A) + 1)]
	for a in A:
		B[a] += 1
	i = 0
	j = len(B) - 1
	r = -1
	while i <= j:
		if B[i] == 0:
			i += 1
		elif B[j] == 0:
			j -= 1
		elif i == j:
			if B[i] % 4 != 0:
				return False
			if r == -1:
				r = i * i
			if i * i != r:
				return False
			i += 1
			j -= 1
		else:
			if B[i] != B[j]:
				return False
			if B[i] % 2 != 0:
				return False
			if r == -1:
				r = i * j
			if i * j != r:
				return False
			i += 1
			j -= 1
	return True
in_file = sys.stdin
q = int(in_file.readline().strip())
for _ in range(q):
	n = int(in_file.readline().strip())
	A = list(map(int, in_file.readline().strip().split()))
	if solve(A, n):
		sys.stdout.write('YES\n')
	else:
		sys.stdout.write('NO\n')
sys.stdout.flush()


q = int(input())
while q > 0:
	q -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	front = 0
	end = len(arr) - 1
	area = arr[front] * arr[end]
	possible = arr[front] == arr[front + 1] and arr[end] == arr[end - 1]
	front += 2
	end -= 2
	while possible and front < end:
		if arr[front] != arr[front + 1] or arr[end] != arr[end - 1] or arr[front] * arr[end] != area:
			possible = False
		front += 2
		end -= 2
	if possible:
		print('YES')
	else:
		print('NO')


from collections import defaultdict
q = int(input())
for _ in range(q):
	n = int(input())
	a = [int(i) for i in input().strip().split()]
	a.sort()
	d = a[0] * a[-1]
	count = defaultdict(lambda : 0)
	for el in a:
		count[el] += 1
	nums = list(set(a))
	ans = True
	for n in nums:
		if d // n < n:
			break
		if count[n] % 2 == 0 and count[n] == count[d // n] and (d % n == 0):
			pass
		else:
			ans = False
			break
	if ans:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	n = n * 4
	l = list(map(int, input().split()))
	l.sort()
	ll = []
	flag = 0
	for i in range(0, n, 2):
		if l[i] - l[i + 1] == 0:
			ll.append(l[i])
		else:
			flag = 1
			break
	if flag == 0:
		x = ll[0] * ll[len(ll) - 1]
		flg = 0
		for i in range(1, len(ll) - 1):
			if ll[i] * ll[len(ll) - i - 1] == x:
				continue
			else:
				flg = 1
				break
		if flg == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
for i in range(n):
	c = []
	d = []
	a = int(input())
	b = list(map(int, input().split()))
	b.sort()
	fg = 0
	for j in range(0, len(b), 2):
		if b[j] == b[j + 1]:
			c.append(b[j])
		else:
			fg = 1
			break
	if not fg:
		for j in range(len(c)):
			sum = c[j] * c[-j - 1]
			d.append(sum)
		if len(set(d)) == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	r = min(a) * max(a)
	c = Counter(a)
	ans = 0
	for (i, j) in c.items():
		if j >= 2 and r // i != i and (r % i == 0) and (c[r // i] >= 2):
			t = min(c[r // i], j)
			t = t - 1 if t & 1 else t
			c[r // i] -= t
			c[i] -= t
			ans += t // 2
		if r % i == 0 and r // i == i and (j >= 4):
			t = j // 4
			c[i] -= t * 4
			ans += t
	print('YES' if ans == n else 'NO')


import itertools

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

def output_list(v):
	print(' '.join((str(x) for x in v)))

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = input_ints()
		a.sort()
		ok = True
		for i in range(2 * n):
			if a[2 * i] != a[2 * i + 1]:
				ok = False
		x = []
		for i in range(n):
			x.append(a[2 * i] * a[-1 - 2 * i])
		if min(x) == max(x) and ok:
			print('YES')
		else:
			print('NO')
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	n = n * 4
	area = a[0] * a[1] * a[n - 1] * a[n - 2]
	(i, j) = (0, n - 1)
	c = 0
	while i < j:
		if a[i] == a[i + 1] and a[j] == a[j - 1] and (area == a[i] * a[i + 1] * a[j] * a[j - 1]):
			i = i + 2
			j = j - 2
		else:
			c = 1
			break
	if c == 1:
		print('NO')
	else:
		print('YES')


N = int(input())
count = [0 for i in range(N)]
lengths = [0 for i in range(N)]
split = [0 for i in range(N)]
for i in range(N):
	count[i] = int(input())
	lengths[i] = input()
	split[i] = lengths[i].split(' ')
	numbers = []
	for x in split[i]:
		numbers.append(int(x))
	numbers.sort()
	numbers2 = numbers.copy()
	numbers2.reverse()
	area = numbers[0] * numbers2[0]
	possible = True
	for j in range(4 * count[i]):
		if numbers[j] * numbers2[j] != area:
			possible = False
	for j in range(2 * count[i]):
		if numbers[2 * j] != numbers[2 * j + 1]:
			possible = False
	if possible:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	b = a[::-1]
	d = dict()
	for i in range(len(a)):
		d[a[i] * b[i]] = 1
	if len(d) == 1 and a[::2] == a[1::2]:
		print('YES')
	else:
		print('NO')


num_test = int(input())
for i in range(num_test):
	num_stick = 4 * int(input())
	len_stick = list(map(int, input().split()))
	len_stick.sort()
	(i, j) = (0, len(len_stick) - 1)
	area = len_stick[i] * len_stick[j]
	check = 0
	while i < j:
		if len_stick[i] == len_stick[i + 1] and len_stick[j] == len_stick[j - 1]:
			i += 2
			j -= 2
			new_area = len_stick[i] * len_stick[j]
			if new_area == area:
				check = 1
			else:
				check = 0
				break
		else:
			check = 0
			break
	if check == 0:
		print('NO')
	else:
		print('YES')


q = int(input())
for i in range(q):
	n = int(input())
	longs = input().split()
	for j in range(4 * n):
		longs[j] = int(longs[j])
	longs.sort()
	square = longs[0] * longs[-1]
	if_possible = True
	for j in range(n):
		if longs[2 * j] == longs[2 * j + 1] and longs[-2 * j - 1] == longs[-2 * j - 2]:
			if longs[2 * j] * longs[-2 * j - 1] != square:
				if_possible = False
				break
		else:
			if_possible = False
			break
	if if_possible:
		print('YES')
	else:
		print('NO')


for q in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	(d1, d2) = (a[0::2], a[1::2])
	if d1 == d2:
		d2.reverse()
		(d1, d2) = (d1[:n], d2[:n])
		for i in range(len(d1)):
			d1[i] *= d2[i]
		if min(d1) == max(d1):
			print('YES')
			continue
	print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	array = list(map(int, input().split()))
	array.sort()
	flag = 1
	for i in set(array):
		if array.count(i) % 2:
			flag = 0
			break
	if not flag:
		print('NO')
		continue
	k = 4 * n // 2 - 1
	area = array[0] * array[-1]
	for i in range(k + 1):
		if array[i] * array[-1 - i] != area:
			flag = 0
			break
	if flag:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	d = dict()
	for x in a:
		d[x] = d.get(x, 0) + 1
	f = True
	for key in d:
		if d[key] % 2 != 0:
			f = False
			break
	s = a[0] * a[-1]
	for i in range(2 * n):
		if s != a[i] * a[-(i + 1)]:
			f = False
			break
	if f:
		print('YES')
	else:
		print('NO')


n = int(input())
for _ in range(0, n):
	x = int(input())
	a = list(map(int, input().split()))
	count = 0
	a.sort()
	flag = True
	last = []
	last.append(a[0] * a[-1])
	right = []
	right.append(a[-1])
	left = []
	left.append(a[0])
	for i in range(1, len(a) // 2):
		temp = a[i] * a[-i - 1]
		if count == x:
			break
		if i % 2 != 0:
			if temp == last[-1] and a[i] == left[-1] and (a[-1 - i] == right[-1]):
				count += 1
			else:
				flag = False
				break
		if temp != last[-1]:
			flag = False
			break
		left.append(a[i])
		right.append(a[-1 - i])
		last.append(temp)
	if flag and count >= x:
		print('YES')
	else:
		print('NO')


t = int(input())
for w in range(t):
	n = int(input())
	l = sorted([int(i) for i in input().split()])
	ar = l[0] * l[-1]
	c = 1
	for i in range(0, 4 * n, 2):
		if l[i] != l[i + 1] or l[4 * n - i - 1] != l[4 * n - i - 2] or l[i] * l[4 * n - i - 1] != ar:
			c = 0
			break
	if c == 1:
		print('YES')
	else:
		print('NO')


import sys, collections
tc = int(sys.stdin.readline())
for _ in range(tc):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	res = collections.Counter(arr)
	even = True
	for i in res:
		if res[i] % 2 == 1:
			even = False
			break
	if even:
		arr.sort()
		ans = []
		i = 0
		j = len(arr) - 1
		while i < j:
			ans.append(arr[i] * arr[j])
			i += 2
			j -= 2
		print('YES' if len(set(ans)) == 1 else 'NO')
	else:
		print('NO')


from collections import deque
query = int(input())
for q in range(query):
	n = int(input())
	arr = deque(sorted(map(int, input().split())))
	s = set()
	flag = True
	while arr:
		a = arr.pop()
		b = arr.pop()
		c = arr.popleft()
		d = arr.popleft()
		s.add(a * c)
		if a != b or c != d:
			flag = False
			break
	if len(s) == 1 and flag == True:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	sticks = list(map(int, input().split()))
	sticks.sort()
	temp = sticks[::-1]
	d = dict()
	for i in range(4 * n):
		d[sticks[i] * temp[i]] = 1
	if len(d) == 1 and sticks[::2] == sticks[1::2]:
		print('YES')
	else:
		print('NO')


from collections import Counter
Q = int(input())
data = []
for _ in range(Q):
	N = int(input())
	A = list(map(int, input().split()))
	data.append([N, A])
for (N, A) in data:
	ans = 'YES'
	B = Counter(A)
	C = []
	for (k, v) in B.items():
		if v % 2 != 0:
			ans = 'NO'
			break
		C.extend([k] * (v // 2))
	if ans == 'YES':
		C.sort()
		for k in range(N):
			if k == 0:
				a = C[k] * C[2 * N - k - 1]
			elif C[k] * C[2 * N - k - 1] != a:
				ans = 'NO'
				break
	print(ans)


for _ in range(int(input())):
	r = int(input())
	sticks = sorted([int(x) for x in input().split()])
	if len({a1 * an for (a1, an) in zip(sticks, sticks[::-1])}) == 1 and sticks[::2] == sticks[1::2]:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	ans = a[0] * a[-1]
	sol = 'YES'
	for i in range(2 * n):
		if i % 2 == 0:
			if a[i] * a[-(i + 1)] != ans or a[i] != a[i + 1] or a[-(i + 1)] != a[-(i + 2)]:
				sol = 'NO'
				break
	print(sol)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	val = set()
	flag = 0
	for j in range(0, 2 * n, 2):
		a = l[j]
		b = l[j + 1]
		c = l[4 * n - j - 1]
		d = l[4 * n - j - 2]
		if a * d == b * c and a == b and (d == c):
			val.add(a * d)
		else:
			flag = 1
			break
	if len(val) == 1 and flag == 0:
		print('YES')
	else:
		print('NO')


from sys import stdout
from sys import stdin

def get():
	return stdin.readline().strip()

def getf():
	return [int(i) for i in get().split()]

def put(a, end='\n'):
	stdout.write(str(a) + end)

def putf(a, sep=' ', end='\n'):
	stdout.write(sep.join([str(i) for i in a]) + end)

def putff(a, sep=' ', end='\n'):
	[putf(i, sep, end) for i in a]
from collections import defaultdict as dd

def solve(a, n):
	d = dd(int)
	for i in a:
		d[i] += 1
	for i in d:
		if d[i] % 2 == 1:
			return 'NO'
	a = []
	k = 0
	for i in d:
		a.extend([i] * (d[i] // 2))
		k += d[i] // 2
	a = sorted(a)
	p = a[0] * a[k - 1]
	for i in range(k // 2 + k % 2):
		if a[i] * a[k - i - 1] != p:
			return 'NO'
	return 'YES'

def main():
	q = int(get())
	for i in range(q):
		n = int(get())
		a = getf()
		print(solve(sorted(a), n))
main()


import sys
input = lambda : sys.stdin.readline().strip()
T = int(input())
for _ in range(T):
	n = int(input())
	ls = list(map(int, input().split()))
	ls.sort()
	for i in range(0, 4 * n, 2):
		if ls[i] != ls[i + 1]:
			print('NO')
			break
	else:
		forw = [ls[i] for i in range(0, 4 * n, 2)]
		back = [ls[i] for i in range(4 * n - 1, -1, -2)]
		for i in range(2 * n):
			if forw[i] * back[i] != forw[0] * back[0]:
				print('NO')
				break
		else:
			print('YES')


def solve(arr, n, ans):
	arr.sort()
	products = set()
	start = 0
	end = 4 * n - 1
	while start < end:
		if arr[start] != arr[start + 1]:
			ans.append('NO')
			return
		if arr[end] != arr[end - 1]:
			ans.append('NO')
			return
		p = arr[start] * arr[end]
		if p not in products:
			if len(products) == 0:
				products.add(p)
			else:
				ans.append('NO')
				return
		start += 2
		end -= 2
	ans.append('YES')

def main():
	q = int(input())
	ans = []
	for i in range(q):
		n = int(input())
		arr = list(map(int, input().split()))
		solve(arr, n, ans)
	for i in ans:
		print(i)
main()


q = int(input())
for _ in range(q):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	bad = False
	area = None
	for i in range(n):
		a1 = a[2 * i]
		a2 = a[2 * i + 1]
		b1 = a[4 * n - 1 - 2 * i]
		b2 = a[4 * n - 1 - 2 * i - 1]
		if a1 != a2 or b1 != b2:
			bad = True
			break
		if area is None:
			area = a1 * b1
		elif a1 * b1 != area:
			bad = True
			break
	if bad:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	A = sorted(A)
	k = 1
	ch = A[0] * A[4 * n - 1]
	for i in range(2 * n):
		if A[i] * A[4 * n - 1 - i] != ch:
			k = 0
			break
	for i in range(0, 4 * n - 1, 2):
		if A[i] != A[i + 1]:
			k = 0
			break
	if k:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	area = a[0] * a[-1]
	ans = 'YES'
	for i in range(n):
		(l, r) = (i * 2, 4 * n - i * 2 - 1)
		if a[l] != a[l + 1] or a[r] != a[r - 1] or a[l] * a[r] != area:
			ans = 'NO'
			break
	print(ans)


q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	f = True
	c = a[0] * a[4 * n - 1]
	j = 0
	while f and j < 2 * n - 1:
		if a[j] != a[j + 1] or a[4 * n - j - 1] != a[4 * n - j - 2] or a[j] * a[4 * n - j - 1] != c:
			f = False
		j += 2
	if f:
		print('YES')
	else:
		print('NO')


def canBuildRectangles(A):
	A.sort()
	B = []
	for i in range(0, len(A), 2):
		if A[i] == A[i + 1]:
			B.append(A[i])
			i += 1
		else:
			return False
	area = B[0] * B[-1]
	for i in range(1, len(B) // 2):
		if B[i] * B[-i - 1] != area:
			return False
	return True
q = int(input())
for _ in range(q):
	n = int(input())
	rect = list(map(int, input().split()))
	assert 4 * n == len(rect)
	isch = canBuildRectangles(rect)
	print('YES' if isch else 'NO')


import sys
inf = float('inf')
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

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

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

def int1():
	return int(input())
import string
import math
from itertools import combinations

def main():
	for q in range(int(input())):
		n = int1()
		a = get_array()
		a.sort()
		area = a[0] * a[-1]
		r1 = 0
		for i in range(0, 2 * n, 2):
			p = a[i]
			q = a[i + 1]
			r = a[4 * n - i - 1]
			s = a[4 * n - i - 2]
			if p != q or r != s or p * r != area:
				r1 = 1
				break
		if r1:
			print('NO')
		else:
			print('YES')
		n = n - 1
main()


for _ in range(int(input())):
	n = int(input())
	a = list(sorted(map(int, input().split())))
	b = []
	for i in range(0, len(a), 2):
		if a[i + 1] != a[i]:
			print('NO')
			break
		b.append(a[i])
	else:
		s = b[0] * b[-1]
		for j in range(1, len(a) // 2):
			if b[j] * b[-j - 1] != s:
				print('NO')
				break
		else:
			print('YES')


q = int(input())
ans = list()
for j in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	area = a[0] * a[-1]
	count = 0
	for i in range(n):
		if a[2 * i] == a[2 * i + 1] and a[-2 * i - 1] == a[-2 * i - 2] and (a[2 * i] * a[-2 * i - 1] == area):
			count = count + 1
		else:
			continue
	if count == n:
		ans.append('YES')
	else:
		ans.append('NO')
for j in range(q):
	print(ans[j])


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	mul = arr[0] * arr[-1]
	flag = 0
	freq = dict(Counter(arr))
	for i in freq:
		if freq[i] % 2 == 1:
			flag = 1
			break
	for i in range(4 * n // 2):
		if mul == arr[i] * arr[-1 - i]:
			pass
		else:
			flag = 1
			break
	if flag == 0:
		print('YES')
	else:
		print('NO')


for case in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	sett = []
	ha = {}
	for x in a:
		if not x in ha.keys() or ha[x] == 0:
			ha[x] = 1
		elif ha[x] == 1:
			sett.append(x)
			ha[x] = 0
	sett.sort()
	flg = True
	if len(sett) * 2 != 4 * n:
		flg = False
	if flg:
		area = sett[0] * sett[-1]
		for i in range(1, n + 1):
			if sett[i] * sett[n * 2 - 1 - i] != area:
				flg = False
				break
	print('YES' if flg else 'NO')


for _ in range(int(input())):
	n = int(input())
	lis = sorted(map(int, input().split()))
	i = 1
	ans = 'YES'
	j = 4 * n - 2
	prev = lis[0] * lis[-1]
	while i < j:
		if lis[i] == lis[i - 1] and lis[j] == lis[j + 1] and (lis[i] * lis[j] == prev):
			i += 2
			j -= 2
		else:
			ans = 'NO'
			break
	print(ans)


from __future__ import division, print_function
from sys import stdin, stdout
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
import heapq
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd
from fractions import Fraction

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

def si():
	return str(input())

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

def li():
	return list(mi())

def fii():
	return int(stdin.readline())

def fsi():
	return str(stdin.readline())

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

def fli():
	return list(fmi())
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
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

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

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def dfs(v, c):
	if visited[v]:
		if col[v] != c:
			print('-1')
			exit()
		return
	col[v] = c
	visited[v] = 1
	for i in graph[v]:
		dfs(i, c ^ 1)

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d.keys():
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = {}
	for i in range(n):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			s.add(i)
			n = n // i
	if n > 2:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)
t = ii()
for a0 in range(t):
	n = ii()
	a = sorted(li())
	ok = True
	for i in range(2 * n):
		if a[2 * i] != a[2 * i + 1]:
			ok = False
	x = []
	for i in range(n):
		x.append(a[2 * i] * a[-1 - 2 * i])
	if min(x) == max(x) and ok:
		print('YES')
	else:
		print('NO')


import sys
q = int(next(sys.stdin))
for _ in range(q):
	n = int(next(sys.stdin))
	sticks = sorted(map(int, next(sys.stdin).split(' ')))
	pairs = list()
	f = True
	for i in range(len(sticks) // 2):
		if sticks[2 * i] != sticks[2 * i + 1]:
			print('NO')
			f = False
			break
		pairs.append((sticks[2 * i], sticks[2 * i + 1]))
	if not f:
		continue
	sides = [_[0] for _ in pairs]
	amount_sides = len(sides)
	sq = set()
	f = True
	for i in range(n):
		sq.add(sides[i] * sides[amount_sides - i - 1])
		if len(sq) > 1:
			print('NO')
			f = False
			break
	if f:
		print('YES')


entrada = int(input())
for k in range(entrada):
	retangulos = int(input())
	lista = [int(x) for x in input().split()]
	lista.sort()
	flag = True
	area = -1
	for i in range(0, len(lista), 4):
		a = lista[i]
		b = lista[i + 1]
		c = lista[len(lista) - 1 - i]
		d = lista[len(lista) - 1 - (i + 1)]
		if a != b or c != d:
			flag = False
			break
		if area == -1:
			area = a * d
		elif area != a * d:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

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

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

def getStr():
	return input().strip()
Q = getInt()
for _ in range(Q):
	N = getInt()
	A = getArr()
	D = {}
	for x in A:
		if x not in D:
			D[x] = 0
		D[x] += 1
	keys = list(D.keys())
	keys.sort()
	p = keys[0] * keys[-1]
	if len(keys) == 1:
		print('YES')
	else:
		res = 'YES'
		for k in range(len(keys)):
			if not (keys[k] * keys[-1 - k] == p and D[keys[k]] % 2 == 0 and (D[keys[-1 - k]] == D[keys[k]])):
				res = 'NO'
				break
		print(res)


from collections import defaultdict
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	x = []
	for i in range(0, 2 * n, 2):
		if a[i] == a[i + 1] and a[4 * n - 1 - i] == a[4 * n - 2 - i]:
			x.append(a[i] * a[4 * n - 1 - i])
	if len(x) != n:
		print('NO')
	else:
		q = 0
		for i in range(len(x) - 1):
			if x[i] != x[i + 1]:
				q = 1
				break
		if q == 0:
			print('YES')
		else:
			print('NO')


num_q = int(input())
for i in range(num_q):
	n = int(input())
	lst = input()
	lst = [int(x) for x in lst.split(' ')]
	lst.sort()
	new_lst = []
	flag = 0
	i = 0
	while i < 4 * n - 1:
		if lst[i] != lst[i + 1]:
			flag = 1
			break
		else:
			new_lst.append(lst[i])
		i += 2
	if flag == 1:
		print('NO')
		continue
	area = new_lst[0] * new_lst[2 * n - 1]
	for i in range(n):
		if area != new_lst[i] * new_lst[2 * n - 1 - i]:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


import sys
t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split(' ')))
	arr.sort()
	ans = 'YES'
	area = arr[0] * arr[4 * n - 1]
	for i in range(0, 2 * n):
		if arr[2 * i] != arr[2 * i + 1] or arr[i] * arr[4 * n - i - 1] != area:
			ans = 'NO'
	print(ans)


def proverka(n, a):
	o = 'YES'
	t = True
	a.sort()
	n4 = n * 4
	mp = []
	for i in range(0, n4, 2):
		if a[i] != a[i + 1]:
			o = 'NO'
			t = False
			return o
	if t:
		for i in range(n4):
			mp.append(a[i] * a[-i - 1])
		for i in range(len(mp) - 1):
			if mp[i + 1] != mp[i]:
				o = 'NO'
				return o
	return o
q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	o = proverka(n, a)
	print(o)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	area = 0
	s = 0
	for i in range(n):
		if i == 0:
			if a[2 * i + 1] == a[2 * i] and a[4 * n - 2 * i - 1] == a[4 * n - 2 * i - 2]:
				area = a[2 * i] * a[4 * n - 2 * i - 1]
			else:
				s += 1
				break
		elif a[2 * i + 1] == a[2 * i] and a[4 * n - 2 * i - 1] == a[4 * n - 2 * i - 2]:
			if area != a[2 * i] * a[4 * n - 2 * i - 1]:
				s += 1
				break
		else:
			s += 1
			break
	if s == 0:
		print('YES')
	else:
		print('NO')


import sys, math, queue
MOD = 998244353
sys.setrecursionlimit(1000000)
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	f = {}
	for ai in a:
		if ai in f:
			f[ai] += 1
		else:
			f[ai] = 1
	ans = True
	a = []
	for fi in f:
		if f[fi] % 2 != 0:
			ans = False
			break
		for i in range(f[fi] // 2):
			a.append(fi)
	if not ans:
		print('NO')
		continue
	a.sort()
	(i, j) = (0, len(a) - 1)
	while i <= j:
		if i == j or a[i] * a[j] != a[0] * a[-1]:
			ans = False
			break
		else:
			i += 1
			j -= 1
	print('YES' if ans else 'NO')


from collections import Counter
t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	c = Counter(arr)
	flg = False
	for i in c:
		if c[i] % 2 != 0:
			flg = True
			break
	if flg:
		print('NO')
		continue
	arr.sort()
	req = arr[0] * arr[-1]
	for i in range(2 * n):
		if arr[i] * arr[4 * n - 1 - i] != req:
			flg = True
			break
	if flg:
		print('NO')
	else:
		print('YES')


n = int(input())
while n != 0:
	n -= 1
	p = int(input())
	tem = input()
	tem = tem.split(' ')
	for i in range(4 * p):
		tem.append(int(tem[0]))
		tem.pop(0)
	tem.sort()
	flag = True
	ar = tem[0] * tem[4 * p - 1]
	for i in range(2 * p):
		if tem[2 * i + 1] != tem[2 * i]:
			flag = False
			break
		if tem[i] * tem[4 * p - 1 - i] != ar:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


T = int(input())
for cas in range(T):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	area = a[0] * a[4 * n - 1]
	le = 0
	ri = 4 * n - 1
	flg = 1
	for i in range(n):
		for j in range(2):
			if a[le + j] != a[le] or a[le + j] * a[ri - j] != area:
				flg = 0
		le += 2
		ri -= 2
	if flg == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	f = [0] * 100005
	n = int(input())
	a = [0] + list(map(int, input().split()))
	a.sort()
	if a[1] != a[2] or a[4 * n - 1] != a[4 * n]:
		print('NO')
	else:
		s = a[1] * a[4 * n]
		c = 0
		for i in range(3, 2 * n + 1, 2):
			if a[i] != a[i + 1] or a[4 * n - i] != a[4 * n - i + 1] or a[i] * a[4 * n - i + 1] != s:
				c = 1
				break
		if c == 1:
			print('NO')
		else:
			print('YES')


t = int(input())
for i in range(t):
	n = 4 * int(input())
	l = list(map(int, input().split()))
	l.sort()
	t = l[0] * l[n - 1]
	flag = 0
	for i in range(0, n // 2 - 1, 2):
		if t == l[i] * l[n - i - 1] and l[i] == l[i + 1] and (l[n - i - 1] == l[n - i - 2]):
			continue
		else:
			flag = 1
			print('NO')
			break
	if flag == 0:
		print('YES')


q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	c = 0
	m = a[0] * a[4 * n - 1]
	for i in range(0, n):
		if a[2 * i] == a[2 * i + 1] and a[4 * n - 2 * i - 2] == a[4 * n - 2 * i - 1] and (a[2 * i] * a[4 * n - 2 * i - 1] == m):
			c += 1
		else:
			break
	if c == n:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(1, n + 1):
	m = int(input())
	query = list(map(int, input().split(' ')))
	query.sort()
	iseqrect = True
	for j in range(2 * m):
		if query[2 * j] == query[2 * j + 1]:
			pass
		else:
			iseqrect = False
			break
	area = query[0] * query[-1]
	for j in range(2 * m):
		if query[j] * query[-j - 1] == area:
			pass
		else:
			iseqrect = False
	if iseqrect:
		print('YES')
	else:
		print('NO')


from collections import Counter as C, defaultdict as D, deque as Q
from operator import itemgetter as I
from itertools import product as P
from bisect import bisect_left as BL, bisect_right as BR
from heapq import heappush as HPUSH, heappop as HPOP
from math import floor as MF, ceil as MC, gcd as MG, factorial as F, sqrt as SQRT, inf as INFINITY, log as LOG
from sys import stdin, stdout
INPUT = stdin.readline
PRINT = stdout.write

def player1():
	print('')

def player2():
	print('')

def isPrime(n):
	for i in range(2, MC(SQRT(n)) + 1):
		if n % i == 0:
			return False
	return True

def factors(x):
	ans = []
	for i in range(1, MC(SQRT(x)) + 1):
		if x % i == 0:
			ans.append(i)
			if x % (x // i) == 0:
				ans.append(x // i)
	return ans

def checkPath(source, destination, g):
	visited = [0] * 101
	q = Q()
	q.append(source)
	visited[source] = 1
	while q:
		node = q.popleft()
		if node == destination:
			return 1
		for v in g[node]:
			if not visited[v]:
				q.append(v)
				visited[v] = 1
	return 0

def main():
	for _ in range(int(INPUT())):
		n = int(INPUT())
		a = sorted(map(int, INPUT().split()))
		for i in range(0, 4 * n - 1, 2):
			if a[i] != a[i + 1]:
				break
		else:
			area = a[0] * a[-1]
			(i, j) = (0, 4 * n - 1)
			while i < j:
				if a[i] * a[j] != area:
					break
				i += 1
				j -= 1
			else:
				PRINT('YES\n')
				continue
			PRINT('NO\n')
			continue
		PRINT('NO\n')
main()


import math
from collections import deque, defaultdict
from sys import stdin, stdout
input = stdin.readline
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	a = listin()
	d = defaultdict(int)
	for i in a:
		d[i] += 1
	z = []
	for i in d.items():
		z.append([i[0], i[1]])
	z.sort()
	p = z[0][0] * z[-1][0]
	flag = True
	for i in z:
		if i[1] % 2 == 1:
			print('NO')
			flag = False
			break
	if flag == False:
		continue
	for i in range(len(z)):
		if z[i][0] * z[len(z) - i - 1][0] != p or z[i][1] != z[len(z) - i - 1][1]:
			print('NO')
			flag = False
			break
	if flag:
		print('YES')


k = int(input())
for _ in range(k):
	n = int(input())
	nums = [int(x) for x in input().split()]
	nums = sorted(nums)
	if nums[0] == nums[1] and nums[-1] == nums[-2]:
		area = nums[0] * nums[-1]
	else:
		print('NO')
		continue
	flag = True
	for i in range(n):
		if nums[2 * i] == nums[2 * i + 1] and nums[-2 * i - 1] == nums[-2 * i - 2]:
			if nums[2 * i] * nums[-2 * i - 1] != area:
				flag = False
				break
		else:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


R = lambda : map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	L = sorted(R())
	p = 4 * n
	f = [0] * (L[p - 1] + 1)
	for i in L:
		f[i] += 1
	fg = 0
	for i in f:
		if i % 2:
			fg = 1
			break
	if fg:
		print('NO')
		continue
	pr = L[0] * L[p - 1]
	(i, j) = (0, p - 1)
	while i < j:
		if L[i] * L[j] != pr:
			fg = 1
			break
		i += 2
		j -= 2
	print('YNEOS'[fg::2])


def main():
	for _ in range(int(input())):
		n = int(input())
		l = list(map(int, input().split()))
		p = len(l)
		l.sort()
		fg = 0
		temp = l[0] * l[p - 1]
		for i in range(0, 4 * n, 2):
			if l[i] * l[p - i - 1] == temp and l[i] == l[i + 1]:
				continue
			else:
				fg = 1
		if fg == 0:
			print('YES')
		else:
			print('NO')
	return
main()


import sys
import math
input = sys.stdin.readline

def solve(arr, n):
	prev = -1
	i = 0
	while i < 2 * n:
		if arr[i] == arr[i + 1] and arr[4 * n - i - 1] == arr[4 * n - i - 2]:
			curr = arr[i] * arr[4 * n - i - 1]
			if prev == -1:
				prev = curr
			elif curr != prev:
				return False
		else:
			return False
		i = i + 2
	return True
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	if solve(arr, n):
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
from math import ceil
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	d = {}
	hash = []
	for i in range(4 * n):
		if arr[i] in d:
			d[arr[i]] += 1
		else:
			d[arr[i]] = 1
	for i in d:
		hash.append([i, d[i]])
	l = len(hash)
	hash = sorted(hash, key=lambda x: x[0])
	area = hash[0][0] * hash[l - 1][0]
	flag = True
	for i in range(ceil(l / 2)):
		if hash[i][0] * hash[l - i - 1][0] == area:
			if hash[i][1] != hash[l - 1 - i][1]:
				flag = False
			elif hash[i][1] % 2 != 0:
				flag = False
		else:
			flag = False
	print('YES' if flag else 'NO')


query = int(input())
while query:
	n = int(input())
	x = [int(x) for x in input().split()]
	mp = {}
	for i in x:
		if i in mp:
			mp[i] = mp[i] + 1
		else:
			mp[i] = 1
	answer = True
	x.clear()
	for (key, value) in mp.items():
		if value % 2 == 1:
			answer = False
		for j in range(int(value / 2)):
			x.append(key)
	if answer:
		x.sort()
		a = x[0] * x[-1]
		for i in range(len(x)):
			answer = answer and x[i] * x[-1 - i] == a
	if answer:
		print('YES')
	else:
		print('NO')
	query -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	hsh = [0] * max(a)
	for i in a:
		hsh[i - 1] += 1
	flag = 0
	for i in hsh:
		flag += i % 2
		if flag:
			break
	if flag:
		print('NO')
	else:
		a.sort()
		s = a[0] * a[-1]
		for i in range(2 * n):
			if a[i] * a[4 * n - 1 - i] != s:
				flag = 1
				break
		if flag:
			print('NO')
		else:
			print('YES')


for u in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	d = 0
	k = l[1] * l[-1]
	for i in range(1, n * 2, 2):
		if l[i] != l[i - 1] or l[-i] != l[-i - 1] or l[i] * l[-i] != k:
			d = 1
	if d == 0:
		print('YES')
	else:
		print('NO')


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))

def inpl_1():
	return list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))

def inps():
	return sys.stdin.readline()

def inpsl(x):
	tmp = sys.stdin.readline()
	return list(tmp[:x])

def err(x):
	print(x)
	exit()
for _ in range(inp()):
	n = inp()
	a = inpl()
	c = Counter(a)
	res = 1
	b = []
	for (key, va) in c.items():
		if va % 2:
			res = 0
		for i in range(va // 2):
			b.append(key)
	if res == 0:
		print('NO')
		continue
	b.sort()
	se = set()
	for i in range(n * 2):
		se.add(b[i] * b[-1 - i])
	print('YES' if len(se) == 1 else 'NO')


def xx():
	n = int(input())
	a = list(map(int, input().split()))
	x = []
	d = {}
	for i in range(4 * n):
		try:
			d[a[i]] += 1
		except:
			d[a[i]] = 1
	a = []
	for i in d:
		if d[i] % 2 == 1:
			return 'NO'
		k = d[i] // 2
		a = a + [i] * k
	a.sort()
	i = 0
	j = len(a) - 1
	prev = a[i] * a[j]
	while i < j:
		i += 1
		j -= 1
		if a[i] * a[j] != prev:
			return 'NO'
	return 'YES'
for q in range(int(input())):
	print(xx())


for w in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	c = 0
	for i in range(0, 2 * n, 2):
		if i == 0:
			area = a[0] * a[-1]
			if a[1] == a[0] and a[-2] == a[-1]:
				continue
			else:
				c = 1
				break
		elif a[i] * a[-i - 1] != area:
			c = 1
			break
		elif a[i] != a[i + 1] or a[-i - 1] != a[-i - 2]:
			c = 1
			break
	if c == 1:
		print('NO')
	else:
		print('YES')


q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	d = a[0] * a[4 * n - 1]
	possible = True
	for i in range(0, 2 * n, 2):
		if a[i] != a[i + 1] or a[4 * n - i - 1] != a[4 * n - i - 2] or a[i] * a[4 * n - i - 1] != d:
			possible = False
			break
	if possible:
		print('YES')
	else:
		print('NO')


a = int(input())
l = []
for i in range(a):
	b = int(input())
	c = list(map(int, input().split()))
	g = len(c)
	c.sort()
	p = c[0] * c[-1]
	k = 'YES'
	for j in range(0, g // 2, 2):
		if c[j] * c[-j - 1] != p or c[j] != c[j + 1] or c[-j - 1] != c[-j - 2]:
			k = 'NO'
			break
	print(k)


t = int(input())
while t:
	n = int(input())
	ch = 1
	a = list(map(int, input().split()))
	a.sort()
	s = set()
	for i in range(0, 2 * n, 2):
		if a[i] != a[i + 1] or a[4 * n - i - 1] != a[4 * n - i - 2]:
			ch = 0
			break
		z = a[i] * a[4 * n - i - 1]
		s.add(z)
	if len(s) != 1 or ch == 0:
		print('NO')
	else:
		print('YES')
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	c = sorted(list(map(int, input().split())))
	tar = c[0] * c[-1]
	f = 0
	for i in range(n):
		idx = 2 * i
		if c[idx] != c[idx + 1]:
			f = 1
		if c[-idx - 1] != c[-idx - 2]:
			f = 1
		if c[idx] * c[-idx - 1] != tar:
			f = 1
	if f == 1:
		print('NO')
	else:
		print('YES')


q = int(input())
for i in range(q):
	n = int(input())
	sticks = sorted(list(map(int, input().split())))
	l = 0
	r = n * 4 - 1
	area = sticks[l] * sticks[r]
	flag = False
	while l < r:
		if sticks[l] * sticks[r] != area:
			flag = True
			break
		if sticks[l] != sticks[l + 1] or sticks[r] != sticks[r - 1]:
			flag = True
			break
		l += 2
		r -= 2
	if flag:
		print('NO')
	else:
		print('YES')


q = int(input())
for w in range(q):
	n = int(input())
	a = [int(i) for i in input().split()]
	h = {}
	b = []
	for i in range(len(a)):
		if a[i] not in h:
			h[a[i]] = 1
		else:
			h[a[i]] += 1
		if a[i] in h:
			if h[a[i]] % 2 == 0:
				b.append(a[i])
	if len(b) != 2 * n:
		print('NO')
	else:
		b.sort()
		f = 0
		ans = b[0] * b[len(b) - 1]
		for i in range(len(b) // 2):
			if b[i] * b[len(b) - 1 - i] != ans:
				f = 1
				break
		if f == 1:
			print('NO')
		else:
			print('YES')


cases = int(input())
for i in range(cases):
	n = int(input())
	values = list(map(int, input().split(' ')))
	values.sort()
	flag = 0
	temp = 0
	area = values[0] * values[-1]
	if len(values) % 4 != 0:
		flag = 0
	else:
		for i in range(0, len(values), 2):
			if values[i] == values[i + 1] and values[4 * n - i - 1] == values[4 * n - i - 2] and (values[i] * values[4 * n - i - 1] == area):
				flag = 1
			else:
				flag = 0
				break
	if flag == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	flag = True
	l = 4 * n
	area = a[0] * a[-1]
	for i in range(0, 2 * n, 2):
		if (a[i], a[l - i - 1]) != (a[i + 1], a[l - i - 2]):
			flag = False
		if area != a[i] * a[l - i - 1]:
			flag = False
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	area = int(a[0] * a[-1])
	flag = True
	for i in range(0, 2 * n, 2):
		if a[i] * a[4 * n - 1 - i] != area:
			flag = False
			break
		if a[i] != a[i + 1]:
			flag = False
			break
		if a[4 * n - 1 - i] != a[4 * n - 1 - i - 1]:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	c = Counter(l)
	f = 1
	if any((c[i] % 2 for i in c)):
		f = 0
	if f == 0:
		print('NO')
		continue
	l = []
	for i in c:
		a = c[i]
		l = l + [i] * (a // 2)
	l.sort()
	n = len(l)
	if len(l) == 1:
		print('YES')
		continue
	c = l[0] * l[n - 1]
	f = 1
	for i in range(0, n // 2):
		if l[i] * l[n - i - 1] != c:
			f = 0
	print('YES' if f else 'NO')


T = int(input())
for _ in range(0, T):
	N = int(input())
	s = [int(x) for x in input().split()]
	flag = 0
	r = 0
	for i in range(0, len(s)):
		r = r ^ s[i]
	if r != 0:
		flag = 1
	kk = dict()
	L = []
	for i in range(0, len(s)):
		if kk.get(s[i]) == None:
			kk[s[i]] = 1
			L.append(s[i])
		elif kk[s[i]] % 2 == 0:
			L.append(s[i])
			kk[s[i]] += 1
		else:
			kk[s[i]] += 1
	L = sorted(L)
	G = []
	for i in range(0, len(L) // 2):
		G.append(L[i] * L[len(L) - i - 1])
	if len(set(G)) != 1 or len(L) % 2 != 0 or len(s) % 4 != 0 or (len(L) * 2 != len(s)) or (flag == 1):
		print('NO')
	else:
		print('YES')


import collections
n = int(input())
while n:
	x = int(input())
	l = list(map(int, input().split()))
	l = sorted(l)
	a = []
	p = 0
	for i in range(0, len(l) // 2, 2):
		if l[i] == l[i + 1] and l[-(i + 1)] == l[-(i + 2)]:
			a.append(l[i] * l[-(i + 1)])
		else:
			p = 1
			break
	print('YES' if p == 0 and len(set(a)) == 1 else 'NO')
	n -= 1


for _ in range(int(input())):
	n = int(input())
	cnt = [0] * 10002
	maxd = -1
	mind = 99999
	for d in list(map(int, input().split())):
		cnt[d] += 1
		maxd = max(maxd, d)
		mind = min(mind, d)
	i1 = 0
	i2 = 10001
	ans = 'YES'
	s = maxd * mind
	while i1 < i2:
		while cnt[i1] == 0:
			i1 += 1
		while cnt[i2] == 0:
			i2 -= 1
		if i1 >= i2:
			break
		if cnt[i1] % 2 != 0 or cnt[i2] % 2 != 0:
			ans = 'NO'
			break
		if cnt[i1] != cnt[i2]:
			ans = 'NO'
			break
		if i1 * i2 != s:
			ans = 'NO'
			break
		i1 += 1
		i2 -= 1
	if i1 == i2 and cnt[i1] != 0:
		if cnt[i1] % 4 == 0 and i1 * i1 == s:
			ans = 'YES'
		else:
			ans = 'NO'
	print(ans)


import sys

def can_form(arr, n):
	sticks = [0] * (2 * n)
	for i in range(0, 4 * n, 2):
		if arr[i] != arr[i + 1]:
			return False
		sticks[i // 2] = arr[i]
	prod = sticks[0] * sticks[-1]
	for i in range(1, n):
		if sticks[i] * sticks[2 * n - i - 1] != prod:
			return False
	return True
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	arr.sort()
	print('YES' if can_form(arr, n) else 'NO')


q = int(input())
n = 0
a = 0
kq = 0
b = 0
d = 0
c = []
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	kq = 1
	b = []
	c = []
	b.append(a[0])
	d = 1
	for j in range(1, 4 * n):
		if a[j] != a[j - 1]:
			b.append(a[j])
			if d % 2 == 1:
				kq = 0
				break
			c.append(d)
			d = 1
		else:
			d += 1
	if kq == 1:
		c.append(d)
		t = a[0] * a[4 * n - 2]
		for j in range(1, n):
			if a[2 * j] * a[4 * n - 2 - 2 * j] != t:
				kq = 0
				break
		if kq == 0:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


def square(sides, n):
	check = dict()
	nums = []
	for i in range(len(sides)):
		if sides[i] in check:
			check[sides[i]] += 1
			if check[sides[i]] % 2 == 0 and check[sides[i]] != 2:
				nums.append(sides[i])
		else:
			check[sides[i]] = 1
			nums.append(sides[i])
	nums.sort()
	ans = 0
	s = nums[0] * nums[len(nums) - 1]
	for i in range(len(nums) // 2):
		if check[nums[i]] % 2 != 0 or check[nums[len(nums) - 1 - i]] % 2 != 0:
			return 'NO'
		if nums[i] * nums[len(nums) - 1 - i] != s:
			return 'NO'
		else:
			ans += 1
	if ans == n:
		return 'YES'
	else:
		return 'NO'
q = int(input())
for _ in range(q):
	n = int(input())
	sides = list(map(int, input().split()))
	print(square(sides, n))


for _ in range(int(input())):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	f = True
	e = 0
	for i in range(n):
		(a, b, c, d) = (s[i * 2], s[i * 2 + 1], s[n * 4 - i * 2 - 1], s[n * 4 - i * 2 - 2])
		if a == b and c == d:
			if e == 0:
				e = a * d
			elif e != a * d:
				f = False
				break
		else:
			f = False
			break
	print('YES' if f else 'NO')


def solve(n, s):
	s.sort()
	size = len(s)
	area = s[0] * s[size - 0 - 1]
	i = 0
	while i <= size // 2:
		if s[i] * s[size - i - 1] == area:
			if s[i] == s[i + 1] and s[size - i - 1] == s[size - i - 2]:
				i += 2
				continue
			else:
				return 'NO'
		else:
			return 'NO'
	return 'YES'
t = int(input())
for _ in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	print(solve(n, ar))


import math
from functools import reduce
import operator

def prod(factors):
	return reduce(operator.mul, factors, 1)

def answer():
	n = int(input())
	a_list = sorted(map(int, input().split(' ')))
	for i in range(2 * n):
		if a_list[2 * i] != a_list[2 * i + 1]:
			return 'NO'
	a_list = a_list[::2]
	s = a_list[0] * a_list[-1]
	for i in range(n):
		j = -(i + 1)
		cur_s = a_list[i] * a_list[j]
		if s != cur_s:
			return 'NO'
	return 'YES'
q = int(input())
for i in range(q):
	out = answer()
	print(out)


t = int(input())
for i in range(0, t):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	arr.sort()
	if n == 1:
		if arr[0] == arr[1] and arr[2] == arr[3]:
			print('YES')
		else:
			print('NO')
	else:
		temp = []
		for i in range(1, len(arr), 2):
			if arr[i] == arr[i - 1]:
				temp.append(arr[i])
		l = len(temp)
		if len(arr) != 2 * l:
			print('NO')
		else:
			area = temp[0] * temp[l - 1]
			c = 1
			for i in range(1, l // 2):
				if temp[i] * temp[l - i - 1] == area:
					c += 1
			if c == n:
				print('YES')
			else:
				print('NO')


t = int(input())
for i in range(t):
	f = []
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	l1 = l[1::2]
	l = l[0::2]
	if l1 != l:
		print('NO')
	else:
		p = len(l)
		for i in range(p):
			area = l[i] * l[p - i - 1]
			f.append(area)
		if len(set(f)) == 1:
			print('YES')
		else:
			print('NO')


queries = int(input())
for i in range(queries):
	n = int(input())
	inp = [int(x) for x in input().split()]
	inp.sort()
	poss = True
	area = inp[0] * inp[4 * n - 2]
	for j in range(n):
		if inp[2 * j] != inp[2 * j + 1]:
			poss = False
		if inp[4 * n - 2 * (j + 1)] != inp[4 * n - 2 * (j + 1) + 1]:
			poss = False
		if inp[2 * j] * inp[4 * n - 2 * (j + 1)] != area:
			poss = False
	if poss:
		print('YES')
	else:
		print('NO')


from collections import deque, Counter
import array
from itertools import combinations, permutations
from math import sqrt
import unittest

def read_int():
	return int(input().strip())

def read_int_array():
	return [int(i) for i in input().strip().split(' ')]
for _ in range(read_int()):
	n = read_int()
	a = read_int_array()
	a.sort()

	def allgood():
		if a[0] != a[1] or a[-2] != a[-1]:
			return False
		s = a[0] * a[-1]
		for i in range(1, n):
			if a[i * 2] != a[i * 2 + 1] or a[-i * 2 - 1] != a[-i * 2 - 2]:
				return False
			if a[i * 2] * a[-i * 2 - 1] != s:
				return False
		return True
	print('YES' if allgood() else 'NO')


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	f = 0
	for j in range(0, 4 * n, 2):
		if l[j] != l[j + 1]:
			print('NO')
			f = 1
			break
	if f == 1:
		continue
	a = l[0] * l[4 * n - 1]
	for j in range(0, 2 * n, 2):
		if l[j] * l[4 * n - 1 - j] != a:
			f = 1
			print('NO')
			break
	if f == 1:
		continue
	print('YES')


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

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

def si():
	return input()

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

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
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 getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

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

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

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

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 read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def countDivisors(n):
	ans = 0
	l = ceil(sqrt(n)) + 1
	for i in range(2, l):
		cnt = 0
		if n % i == 0:
			while n % i != 1:
				cnt += 1
				n //= i
		ans += cnt
	return ans + 2

def main():
	for _ in range(ii()):
		n = ii()
		l = li()
		f = [0] * 10002
		for i in range(4 * n):
			f[l[i]] += 1
		d = []
		ff = []
		flag = 1
		for i in range(10002):
			if f[i] != 0:
				if f[i] % 2 == 1:
					print('NO')
					flag = 0
					break
				else:
					d.append(i)
					ff.append(f[i])
		if flag == 0:
			continue
		fff = 1
		if len(d) % 2 == 1 and len(d) != 1:
			fff = 1
			if ff[len(d) // 2] % 4 == 1:
				print('NO')
				continue
			else:
				area = d[len(d) // 2] * d[len(d) // 2]
				fff = 0
		i = 0
		j = len(d) - 1
		flag = 1
		if fff == 0:
			if area != d[0] * d[-1]:
				print('NO')
				continue
		else:
			area = d[0] * d[-1]
		while i < j:
			if ff[i] == ff[j] and d[i] * d[j] == area:
				if ff[i] % 2 == 1:
					print('N0')
					flag = 0
					break
				i += 1
				j -= 1
			else:
				flag = 0
				print('NO')
				break
		if flag == 1:
			print('YES')
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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = []
	ans = True
	for i in range(len(a) // 2):
		if a[i * 2] == a[i * 2 + 1]:
			b.append(a[i * 2])
		else:
			ans = False
			break
	if not ans:
		print('NO')
		continue
	half = len(b) // 2
	b1 = b[:half]
	b2 = b[half:]
	b2.reverse()
	sq = b1[0] * b2[0]
	for i in range(len(b1)):
		if sq != b1[i] * b2[i]:
			ans = False
			break
	print('YES' if ans else 'NO')


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	flag = 0
	r = set()
	for i in range(n):
		if a[2 * i] != a[2 * i + 1] or a[-1 - 2 * i] != a[-1 - (2 * i + 1)]:
			flag = 1
			break
		r.add(a[2 * i] * a[-1 - i * 2])
	if len(r) != 1 or flag == 1:
		print('NO')
	else:
		print('YES')


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

def arp(arr):
	return ' '.join([str(i) for i in arr])
from collections import deque, Counter
for _ in range(int(input())):
	(n,) = rl()
	arr = rl()
	ans = []
	arr.sort()
	arr = deque(arr)
	f = True if all((i % 2 == 0 for i in list(Counter(arr).values()))) else False
	for i in range(2 * n):
		ans.append(arr[-1] * arr[0])
		arr.pop()
		arr.popleft()
	if len(set(ans)) == 1 and f:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	pos = True
	for i in range(0, 4 * n, 2):
		if a[i] != a[i + 1]:
			pos = False
			break
	area = a[0] * a[-1]
	if pos:
		for i in range(2, 2 * n, 2):
			pos = pos and a[i] * a[-i - 1] == area
	print('YES' if pos else 'NO')


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	A = sorted(map(int, input().split()))
	print('YES' if len({A[i] * A[-i - 1] for i in range(2 * n)}) < 2 and all((v % 2 == 0 for v in Counter(A).values())) else 'NO')


q = int(input())
for _ in range(q):
	n = int(input())
	ar = list(map(int, input().split()))
	uniq = []
	pairs = []
	for i in ar:
		if i not in uniq:
			uniq.append(i)
		else:
			uniq.remove(i)
			pairs.append(i)
	if len(uniq) != 0:
		print('NO')
	else:
		pairs.sort()
		b = True
		true_prod = pairs[0] * pairs[-1]
		for i in range(len(pairs) // 2):
			prod = pairs[i] * pairs[-i - 1]
			if prod != true_prod:
				b = False
				break
		print('YES' if b else 'NO')


def soln() -> None:

	def logic() -> None:
		n = int(input())
		arr = sorted([int(x) for x in input().split()])
		for i in range(0, n * 4, 2):
			if arr[i] != arr[i + 1]:
				print('NO')
				return
		prod = []
		for _ in range(n):
			curr = arr.pop() * arr.pop(0)
			prod.append(curr)
			arr.pop()
			arr.pop(0)
		for i in prod:
			if i != prod[0]:
				print('NO')
				return
		else:
			print('YES')
	for _ in range(int(input())):
		logic()
soln()


q = int(input())
for _ in range(q):
	n = int(input())
	v = list(map(int, input().split()))
	v.sort()
	pointer = 0
	possible = True
	area = -1
	while pointer < len(v) / 2:
		if v[pointer] != v[pointer + 1]:
			possible = False
			break
		end_pointer = len(v) - pointer - 1
		if v[end_pointer] != v[end_pointer - 1]:
			possible = False
			break
		if v[pointer] * v[end_pointer] != area and area != -1:
			possible = False
			break
		else:
			area = v[pointer] * v[end_pointer]
		pointer += 2
	if possible:
		print('YES')
	else:
		print('NO')


def rec(a, b):
	for i in range(0, b, 2):
		if p[i] != p[i + 1]:
			return 'NO'
	prod = a[0] * a[len(a) - 1]
	for i in range(b // 2):
		if a[i] * a[len(a) - i - 1] != prod:
			return 'NO'
	return 'YES'
t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	p.sort()
	print(rec(p, 4 * n))


import math

def is_valid(arr):
	arr.sort()
	i = 0
	j = len(arr) - 1
	m = None
	while i < j:
		l = arr[i:i + 2]
		r = arr[j - 1:j + 1]
		if len(set(l)) != 1 or len(set(r)) != 1:
			return 'NO'
		if m is None:
			m = l[0] * r[0]
		elif l[0] * r[0] != m:
			return 'NO'
		i += 2
		j -= 2
	return 'YES'
n = int(input())
for i in range(n):
	input()
	arr = list(map(int, input().split()))
	print(is_valid(arr))


q = int(input())
for i in range(q):
	n = int(input())
	n = n * 4
	arr = list(map(int, input().strip().split()))
	arr.sort()
	i = 0
	j = n - 2
	area = -1
	if arr[i] == arr[i + 1] and arr[j] == arr[j + 1]:
		area = arr[i] * arr[j]
	else:
		print('NO')
		continue
	(i, j) = (i + 2, j - 2)
	ret = True
	while i < j:
		if arr[i] == arr[i + 1] and arr[j] == arr[j + 1] and (arr[i] * arr[j] == area):
			pass
		else:
			ret = False
			break
		(i, j) = (i + 2, j - 2)
	if ret:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	r = list(map(int, input().split()))
	d = dict()
	l = list()
	for i in r:
		if i in d.keys():
			if d[i] == 1:
				l.append(i)
				d[i] += 1
			elif d[i] == 2:
				d[i] = 1
		else:
			d[i] = 1
	l.sort()
	j = len(l)
	f = 0
	if j == 2 * n:
		a = l[0] * l[-1]
		f = 0
		for k in range(0, j // 2):
			if l[k] * l[j - k - 1] != a:
				f = 1
				break
	else:
		f = 1
	if f == 0:
		print('YES')
	else:
		print('NO')


from collections import Counter
Q = int(input())
for q in range(Q):
	n = int(input())
	sticks = list(map(int, input().split()))
	c = Counter(sticks)
	flag = True
	for v in c.values():
		if v % 2 != 0:
			flag = False
			break
	if not flag:
		print('NO')
		continue
	edges = []
	for k in c.keys():
		for i in range(c[k] // 2):
			edges.append(k)
	edges.sort()
	t = edges[0] * edges[-1]
	for i in range(1, len(edges) * 2 // 2):
		if t != edges[i] * edges[-i - 1]:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


def solve():
	n = int(input())
	sticks = sorted([int(x) for x in input().split()])
	area = sticks[0] * sticks[-1]
	for i in range(n * 2):
		if i % 2 == 1 and sticks[i] != sticks[i - 1]:
			return 'NO'
		if area != sticks[i] * sticks[n * 4 - 1 - i]:
			return 'NO'
	return 'YES'
t = int(input())
for i in range(t):
	print(solve())


import sys
inp = sys.stdin.readlines()
ii = 0
out = []
t = int(inp[ii])
ii += 1
for tc in range(t):
	n = int(inp[ii])
	ii += 1
	areas = []
	sticks = [int(st) for st in inp[ii].split()]
	ii += 1
	sticks.sort()
	ans = ' '
	for p in range(1, 4 * n, 2):
		if sticks[p] != sticks[p - 1]:
			ans = 'NO'
	if ans == 'NO':
		out.append(ans)
		continue
	revsticks = sticks[::-1]
	for x in range(2 * n):
		area = sticks[x] * revsticks[x]
		areas.append(area)
	if len(set(areas)) == 1:
		ans = 'YES'
	else:
		ans = 'NO'
	out.append(ans)
sys.stdout.write('\n'.join(out))


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split(' ')))
	ar.sort(reverse=True)
	result = 'YES'
	area = 0
	for i in range(0, n * 2, 2):
		r = -1 - i
		if ar[i] != ar[i + 1] or ar[r] != ar[r - 1]:
			result = 'NO'
			break
		if area == 0:
			area = ar[i] * ar[r]
		elif area != ar[i] * ar[r]:
			result = 'NO'
			break
	if area == 0:
		result = 'NO'
	print(result)


from collections import *
n = int(input())
for i in range(n):
	m = int(input())
	a = sorted(map(int, input().split()))
	k = a[0] * a[-1]
	f = 0
	if all((v % 2 == 0 for (k, v) in Counter(a).items())):
		for i in range(4 * m // 2):
			if k != a[i] * a[4 * m - 1 - i]:
				print('NO')
				f = 1
				break
		if not f:
			print('YES')
	else:
		print('NO')


import sys
q = int(input())
for i in range(0, q):
	n = int(input())
	ln = [int(j) for j in sys.stdin.readline().rstrip().split(' ')]
	ln = sorted(ln)
	f = True
	for j in range(1, len(ln), 2):
		if ln[j] != ln[j - 1]:
			f = False
	ind1 = 0
	ind2 = len(ln) - 2
	sm = ln[ind1] * ln[ind2]
	while ind1 < ind2:
		ind1 += 2
		ind2 -= 2
		if ln[ind1] * ln[ind2] != sm:
			f = False
			break
	if f:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	count = 0
	a = list(map(int, input().split()))
	a.sort()
	f = 0
	p = a[0] * a[4 * n - 1]
	for i in range(0, 4 * n, 2):
		if a[i] * a[4 * n - 1 - i] != p or a[i] != a[i + 1]:
			f = 1
	if f == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = [int(s) for s in input().split()]
	l.sort()
	flag = 0
	ans = []
	for i in range(0, 4 * n, 2):
		if l[i] != l[i + 1]:
			flag = 1
			break
		else:
			ans.append(l[i])
	if flag:
		print('NO')
	else:
		flag = 0
		ar = ans[0] * ans[-1]
		for i in range(1, n):
			if ans[i] * ans[-(i + 1)] != ar:
				flag = 1
				break
		if flag:
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	n = int(input())
	l = sorted(map(int, input().split()))
	a = l[0] * l[-1]
	for i in range(1, 2 * n, 2):
		if l[i] != l[i - 1] or l[-i] != l[-(i + 1)] or l[i] * l[-i] != a:
			print('NO')
			break
	else:
		print('YES')


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
q = ii()
for _ in range(q):
	fn = ii()
	l = il()
	d = dict()
	for i in l:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	(mx, mn) = (max(l), min(l))
	area = mx * mn
	l = sorted(list((i for i in d)))
	ans = 0
	for i in l:
		if area % i == 0 and i <= area // i:
			if i == area // i:
				ans += d[i] // 4
			elif area // i in d:
				ans += min(d[i], d[area // i]) // 2
	if ans == fn:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	r = [0] * (max(a) + 1)
	for i in range(n * 4):
		r[a[i]] += 1
	f = True
	t = []
	for i in range(len(r)):
		if r[i] % 2 != 0:
			if f:
				f = False
				print('NO')
		if r[i] != 0:
			for j in range(r[i] // 2):
				t.append(i)
	if f and len(t) == 2:
		print('YES')
	elif f and len(t) != 2:
		t = sorted(t)
		e = t[0] * t[-1]
		y = True
		for i in range(len(t) // 2 + 1):
			if t[i] * t[len(t) - i - 1] != e:
				print('NO')
				y = False
				break
		if y:
			print('YES')


q = int(input())
for _ in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = a[::-1]
	t = True
	square = 0
	for i in range(n):
		if a[4 * i] != a[4 * i + 1] or b[4 * i] != b[4 * i + 1]:
			t = False
			break
		if i == 0:
			square = a[4 * i] * b[4 * i]
		elif a[4 * i] * b[4 * i] != square:
			t = False
			break
	if t:
		print('YES')
	else:
		print('NO')


from collections import Counter
t = int(input())
for _ in range(0, t):
	n = int(input())
	ss = [int(i) for i in input().split()]
	ed = []
	c = Counter(ss)
	k = 'possible'
	for i in c:
		if c[i] % 2 != 0:
			k = 'notpossible'
			break
		else:
			ed += [i] * (c[i] // 2)
	if k == 'possible':
		kk = True
		ed = sorted(ed)
		ans = ed[0] * ed[-1]
		for i in range(1, len(ed) // 2):
			if ed[i] * ed[-(i + 1)] != ans:
				kk = False
				break
		if kk:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import sys
input = sys.stdin.readline
q = int(input())
for _ in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	l = sorted(l)
	ans = True
	for i in range(0, n * 4, 2):
		if l[i] != l[i + 1]:
			ans = False
			break
	area = l[0] * l[-1]
	for i in range(n * 2):
		if l[i] * l[-i - 1] != area:
			ans = False
			break
	if ans == True:
		print('YES')
	else:
		print('NO')


def f(A, b):
	A.sort()
	for i in range(0, b, 2):
		if A[i] != A[i + 1]:
			return 'NO'
	prod = A[0] * A[-1]
	for i in range(b // 2):
		if A[i] * A[-i - 1] != prod:
			return 'NO'
	return 'YES'
a = int(input())
for j in range(a):
	b = 4 * int(input())
	c = list(map(int, input().split()))
	print(f(c, b))


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	ans = True
	A.sort()
	i = 1
	j = len(A) - 2
	area = None
	while i < j:
		if A[i] != A[i - 1] or A[j] != A[j + 1]:
			ans = False
			break
		temp_area = A[i] * A[j]
		if area is not None and temp_area != area:
			ans = False
			break
		else:
			area = temp_area
		i += 2
		j -= 2
	if ans:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	A = list(map(int, input().split()))
	d = {}
	for a in A:
		if a not in d:
			d[a] = 1
		else:
			d[a] += 1
	m = len(d)
	K = list(d.keys())
	K.sort()
	if m % 2 == 0:
		flag = True
		S = K[0] * K[-1]
		for i in range(m // 2):
			if K[i] * K[-(i + 1)] != S:
				flag = False
			if d[K[i]] % 2 == 1 or d[K[-(i + 1)]] % 2 == 1:
				flag = False
			if d[K[i]] != d[K[-(i + 1)]]:
				flag = False
	else:
		flag = True
		S = K[0] * K[-1]
		for i in range(m // 2):
			if K[i] * K[-(i + 1)] != S:
				flag = False
			if d[K[i]] % 2 == 1 or d[K[-(i + 1)]] % 2 == 1:
				flag = False
			if d[K[i]] != d[K[-(i + 1)]]:
				flag = False
		if d[K[m // 2]] % 4 != 0 or K[m // 2] ** 2 != S:
			flag = False
	if flag:
		print('YES')
	else:
		print('NO')


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(z())
for _ in range(num):
	n = int(z())
	a = szzz()
	area = a[0] * a[-1]
	c = 1
	for i in range(n):
		lf = i * 2
		rg = 4 * n - i * 2 - 1
		if a[lf] != a[lf + 1] or a[rg] != a[rg - 1] or a[lf] * a[rg] != area:
			c = 0
	if c == 0:
		print('NO')
	else:
		print('YES')
exit()
for i in range(len(s)):
	for j in range(i, len(s)):
		pos = 0
		for p in range(len(s)):
			if i <= p and p <= j:
				continue
			if pos < len(t) and t[pos] == s[p]:
				pos += 1
		if pos == len(t):
			ans = max(ans, j - i + 1)
print(ans)


def sol():
	n = int(input())
	m = sorted(map(int, input().split()))
	sq = m[0] * m[-1]
	i = 0
	while i < 4 * n - i - 1:
		if m[i] * m[4 * n - i - 1] != sq:
			return False
		if i % 2 == 1 and m[i] != m[i - 1]:
			return False
		i += 1
	return True
q = int(input())
for i in range(q):
	if sol():
		print('YES')
	else:
		print('NO')


from sys import stdin
from collections import deque
q = int(stdin.readline().strip())
for i in range(q):
	n = int(stdin.readline().strip())
	s = list(map(int, stdin.readline().strip().split()))
	s.sort()
	s = deque(s)
	t = True
	A = s[0] * s[-1]
	while len(s) > 0:
		a1 = s[0] * s[-1]
		if a1 != A or s[0] != s[1] or s[-1] != s[-2]:
			t = False
			break
		s.popleft()
		s.popleft()
		s.pop()
		s.pop()
	if t:
		print('YES')
	else:
		print('NO')


from collections import defaultdict
import math
q = int(input())
for _ in range(q):
	n = int(input())
	a = list(map(int, input().split(' ')))
	s = min(a) * max(a)
	d = defaultdict(int)
	for x in a:
		d[x] += 1
	flag = True
	for x in d.keys():
		if d[x] % 2 != 0:
			flag = False
			break
		if s % x != 0:
			flag = False
			break
		y = s // x
		if d[y] % 2 != 0:
			flag = False
			break
		if d[x] != d[y]:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


import sys
q = int(sys.stdin.readline())
while q:
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	sett = sorted(arr)
	prod = sett[0] * sett[-1]
	flag = 0
	for i in range(0, 4 * n, 2):
		if sett[i] * sett[-(i + 1)] != prod or sett[i] != sett[i + 1]:
			flag = 1
			break
	if flag == 0:
		print('YES')
	else:
		print('NO')
	q -= 1


q = int(input())
while q > 0:
	q = q - 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = [[a[0], 1]]
	cnt = 1
	for i in range(1, 4 * n):
		if a[i] == a[i - 1]:
			b[cnt - 1][1] = b[cnt - 1][1] + 1
		else:
			b.append([a[i], 1])
			cnt = cnt + 1
	i = 0
	j = cnt - 1
	bo = True
	s = b[0][0] * b[cnt - 1][0]
	while i <= j:
		if b[i][0] * b[j][0] != s:
			bo = False
			break
		b[i][1] -= 2
		b[j][1] -= 2
		if b[i][1] < 0 or b[j][1] < 0:
			bo = False
			break
		if b[i][1] == 0:
			i = i + 1
		if b[j][1] == 0:
			j = j - 1
	if bo:
		print('YES')
	else:
		print('NO')


t = int(input())
a = []
for i in range(t):
	n = input()
	b = list(map(int, input().split()))
	a.append(b)
for i in a:
	i.sort()
	p = i.copy()
	i.reverse()
	j = 0
	a = i[0] * p[0]
	q = 0
	while j < len(i):
		if i[j] == i[j + 1] and p[j] == p[j + 1]:
			s = i[j] * p[j]
			if s != a:
				q = 1
				break
		else:
			q = 1
			break
		if q == 1:
			break
		j += 2
	if q == 1:
		print('NO')
	else:
		print('YES')


Q = int(input())
for _ in range(Q):
	N = int(input())
	nums = list(map(int, input().split()))
	nums = sorted(nums)
	cur = 0
	f = 1
	for i in range(N):
		if nums[i * 2] == nums[i * 2 + 1] and nums[-i * 2 - 1] == nums[-i * 2 - 2]:
			if not cur:
				cur = nums[i * 2] * nums[-i * 2 - 1]
			elif nums[i * 2] * nums[-i * 2 - 1] != cur:
				f = 0
		else:
			f = 0
	if f:
		print('YES')
	else:
		print('NO')


from collections import defaultdict
t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = [int(item) for item in input().split(' ')]
	ans = True
	arr.sort()
	area = arr[0] * arr[-1]
	i = 0
	j = 4 * n - 1
	while i < j:
		if not (arr[i] == arr[i + 1] and arr[j] == arr[j - 1] and (arr[i] * arr[j] == area)):
			ans = False
			break
		i += 2
		j -= 2
	print('YES' if ans else 'NO')


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	w = list(sorted(set(l)))
	a = []
	c = 0
	d = 0
	y = int(w[0] * w[-1])
	for i in w:
		if y / i in w:
			k = l.count(i)
			t = l.count(int(y / i))
			if k == t and k % 2 == 0:
				c = c + 1
	if c == len(w):
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	ops = list(map(int, input().split()))
	ops.sort()
	area = ops[0] * ops[-1]
	val = True
	for i in range(n):
		l = i * 2
		r = 4 * n - i * 2 - 1
		if ops[l] != ops[l + 1] or ops[r] != ops[r - 1] or ops[l] * ops[r] != area:
			val = False
	if val:
		print('YES')
	else:
		print('NO')


def main():
	q = int(input())
	for t in range(0, q):
		n = int(input())
		l = input()
		l = l.split(' ')
		l = list(map(lambda x: int(x), l))
		l.sort()
		i = 0
		j = len(l) - 1
		area = l[0] * l[len(l) - 1]
		isPossible = True
		while i < j and isPossible:
			condition = l[i] == l[i + 1] and l[j] == l[j - 1] and (l[i] * l[j] == area)
			if not condition:
				isPossible = False
			else:
				i += 2
				j -= 2
		if isPossible:
			print('YES')
		else:
			print('NO')
main()


from sys import stdin
import math
q = int(stdin.readline())
for i in range(0, q):
	n = int(stdin.readline())
	m = list((int(i) for i in stdin.readline().split()))
	t = dict()
	for j in m:
		try:
			t[j] += 1
		except:
			t[j] = 1
	t = sorted(t.items())
	T = len(t)
	gan = 'YES'
	multi = t[0][0] * t[T - 1][0]
	for j in range(0, math.ceil(T / 2)):
		if t[j][1] != t[T - 1 - j][1]:
			gan = 'NO'
			break
		if t[j][1] % 2 == 1 or t[T - 1 - j][1] % 2 == 1:
			gan = 'NO'
			break
		if t[j][0] * t[T - 1 - j][0] != multi:
			gan = 'NO'
			break
	print(gan)


q = int(input())
for i in range(q):
	n = int(input())
	s = input().split(' ')
	array = []
	output = []
	for j in range(4 * n):
		array.append(int(s[j]))
	array.sort()
	flag = 0
	for k in range(2 * n):
		if array[2 * k] != array[2 * k + 1]:
			print('NO')
			flag = 1
			break
		else:
			output.append(array[2 * k])
	if flag == 0:
		q = output[0] * output[len(output) - 1]
		for l in range(len(output) // 2):
			if q != output[l] * output[len(output) - l - 1]:
				print('NO')
				flag = 1
				break
		if flag == 0:
			print('YES')


for _ in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	a = l[0]
	b = l[-1]
	data = a * b
	flag = 1
	for i in range(2 * n):
		if i % 2 == 0:
			if l[i] * l[-(i + 1)] != data or l[i] != l[i + 1] or l[-(i + 2)] != l[-(i + 1)]:
				flag = 0
	if flag == 0:
		print('NO')
	else:
		print('YES')


q = int(input())
for query in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	c = 0
	for i in range(n * 2):
		if l[2 * i] != l[2 * i + 1]:
			print('NO')
			c = 1
			break
	if c == 0:
		k = [l[2 * i] for i in range(n * 2)]
		pole = k[0] * k[-1]
		for i in range(n):
			if k[i] * k[n * 2 - 1 - i] != pole:
				print('NO')
				c = 1
				break
		if c == 0:
			print('YES')


for i in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a = sorted(a)
	area = a[0] * a[-1]
	t = 0
	for i in range(n):
		lf = i * 2
		rg = 4 * n - i * 2 - 1
		if a[lf] != a[lf + 1] or a[rg] != a[rg - 1] or a[lf] * a[rg] != area:
			t = 1
	print(('YES', 'NO')[t == 1])


a = int(input())
for i in range(a):
	s = int(input())
	z = list(map(int, input().split()))
	z.sort()
	ans = []
	for i in range(1, len(z), 2):
		if z[i] == z[i - 1]:
			ans.append(z[i])
	if len(ans) == 2 * s:
		flag = 0
		maxa = ans[0] * ans[-1]
		for i in range(len(ans) // 2):
			if ans[i] * ans[len(ans) - i - 1] != maxa:
				flag = 1
				break
		if flag == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for i in range(int(input())):
	num_of_rect = int(input())
	nums = sorted(map(int, input().split()))
	st = 0
	end = len(nums) - 1
	area = nums[0] * nums[-1]
	while True:
		if end <= st:
			print('YES')
			break
		if nums[st] == nums[st + 1] and nums[end] == nums[end - 1] and (nums[st] * nums[end] == area):
			end -= 2
			st += 2
			continue
		else:
			print('NO')
			break


t = int(input())
while t > 0:
	n = int(input())
	a = [int(x) for x in input().split()]
	flag = 0
	a.sort()
	rect = []
	for i in range(n):
		j = 2 * i
		rect.append([a[j], a[j + 1], a[4 * n - 1 - j], a[4 * n - 1 - (j + 1)]])
	prod = rect[0][0] * rect[0][1] * rect[0][2] * rect[0][3]
	for i in rect:
		if i[0] != i[1] or i[2] != i[3]:
			flag = 1
			break
		elif i[0] * i[1] * i[2] * i[3] != prod:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = sorted(map(int, input().split()))
	bad = 0
	s = set()
	for i in range(n):
		if a[2 * i] != a[2 * i + 1] or a[4 * n - 2 * i - 1] != a[4 * n - 2 * i - 2]:
			bad = 1
		s.add(a[2 * i] * a[4 * n - 2 * i - 1])
	if bad or len(s) > 1:
		print('NO')
	else:
		print('YES')


for q in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	l2 = []
	d = {}
	f = 0
	for i in l:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	for i in d.keys():
		if d[i] % 2 == 1:
			f = 1
			break
		else:
			for j in range(d[i] // 2):
				l1.append(i)
	l1.sort()
	if len(l1) % 2 == 0:
		while len(l1) > 0:
			a = min(l1)
			b = max(l1)
			l1.remove(a)
			l1.remove(b)
			l2.append(a * b)
		for i in range(len(l2) - 1):
			if l2[i] != l2[i + 1]:
				f = 1
				break
	else:
		f = 1
	if f == 1:
		print('NO')
	else:
		print('YES')


import math

class Read:

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	n = Read.int()
	a = Read.list_int()
	f = []
	d = {}
	for i in a:
		if i in d and d[i]:
			f.append(i)
			d[i] = False
		else:
			d[i] = True
	if len(f) != n * 2:
		print('NO')
		return
	f.sort()
	s = f[0] * f[-1]
	for i in range(n):
		if f[i] * f[n * 2 - 1 - i] != s:
			print('NO')
			return
	print('YES')
query_count = Read.int()
for j in range(query_count):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	a = []
	for i in l:
		if i not in d.keys():
			d[i] = 1
		else:
			d[i] += 1
	for i in l:
		if i not in a:
			a.append(i)
	f = 1
	for x in a:
		if l.count(x) % 2 != 0:
			f = 0
			break
	if f == 0:
		print('NO')
	else:
		f1 = 1
		a.sort()
		m = len(a)
		k = a[0] * a[m - 1]
		i = 0
		j = m - 1
		while i <= j:
			if a[i] * a[j] != k or d[a[i]] != d[a[j]]:
				f1 = 0
				break
			i += 1
			j -= 1
		if f1 == 0:
			print('NO')
		else:
			print('YES')


for i in range(int(input())):
	n = int(input())
	a = [0] * 10001
	arr = list(map(int, input().split()))
	for i in range(4 * n):
		a[arr[i]] += 1
	ans = 'YES'
	for i in a:
		if i % 2 != 0:
			ans = 'NO'
			break
	if sum(a) != n * 4:
		ans = 'NO'
	arr.sort()
	area = arr[0] * arr[-1]
	for i in range(2 * n):
		if arr[i] * arr[-(i + 1)] != area:
			ans = 'NO'
	print(ans)


t = int(input())
while t > 0:
	t -= 1
	flag = 0
	n = int(input())
	a = [int(x) for x in input().split()]
	if a.count(a[0]) == 4 * n:
		print('YES')
		continue
	for i in range(4 * n):
		if a.count(a[i]) % 2 != 0:
			flag = 1
			break
	if flag == 1:
		print('NO')
		continue
	a.sort()
	c = []
	for i in range(0, 4 * n, 2):
		c.append(a[i])
	s1 = c[0] * c[2 * n - 1]
	for i in range(1, 2 * n - 1):
		if s1 != c[i] * c[2 * n - i - 1]:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


from collections import Counter
q = int(input())
for _ in range(q):
	n = int(input())
	ds = sorted(map(int, input().split()))
	s = ds[0] * ds[-1]
	for i in range(n):
		if ds[2 * i] == ds[2 * i + 1] and ds[-1 - 2 * i] == ds[-2 - 2 * i] and (ds[2 * i] * ds[-1 - 2 * i] == s):
			continue
		else:
			print('NO')
			break
	else:
		print('YES')


q = int(input())
for _ in range(q):
	n = 4 * int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	works = True
	area = arr[0] * arr[-1]
	for i in range(0, n // 2, 2):
		if arr[i] != arr[i + 1] or arr[n - i - 1] != arr[n - i - 2]:
			works = False
		if arr[i] * arr[n - i - 1] != area:
			works = False
	print('YES' if works else 'NO')


for j in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	run = 1
	if a[0] == a[1] and a[4 * n - 1] == a[4 * n - 2]:
		p = a[0] * a[4 * n - 1]
		for i in range(n):
			if a[2 * i] == a[2 * i + 1] and a[4 * n - 2 * i - 1] == a[4 * n - 2 * i - 2]:
				if not a[2 * i] * a[4 * n - 2 * i - 1] == p:
					run = 0
					break
			else:
				run = 0
				break
	else:
		run = 0
	if run == 1:
		print('YES')
	else:
		print('NO')


from collections import defaultdict
q = int(input())
for _ in range(q):
	RESOLVED = False
	n = int(input())
	p = [int(t) for t in input().split(' ')]
	d = defaultdict(int)
	for pi in p:
		d[pi] += 1
	n *= 4
	for i in range(n):
		if RESOLVED:
			break
		for j in range(i, n):
			if RESOLVED:
				break
			P = p[i] * p[j]
			can = True
			for k in d:
				if P % k != 0:
					can = False
					break
				prk = P // k
				if prk not in d or d[k] != d[prk] or (k == prk and d[k] % 4 != 0 or (d[k] % 2 != 0 and d[prk] % 2 != 0)):
					can = False
					break
			if can:
				print('YES')
				RESOLVED = True
	if not RESOLVED:
		print('NO')


from collections import Counter
q = int(input())

def rectangle(n, a):
	c = Counter(a)
	s = sorted(c.keys())
	S = s[0] * s[-1]
	for i in range((len(s) + 1) // 2):
		if s[i] * s[len(s) - 1 - i] != S:
			return 'NO'
		if c[s[i]] % 2 != 0 or c[s[i]] != c[s[len(s) - 1 - i]]:
			return 'NO'
	return 'YES'
for _ in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	print(rectangle(n, a))


import sys
q = int(input())
tab = []
for _ in range(q):
	n = int(input()) * 4
	tab = list(map(int, input().split()))
	tab1 = []
	tab.sort()
	all_double = True
	for i in range(1, n, 2):
		if tab[i - 1] != tab[i]:
			all_double = False
			break
		else:
			tab1.append(tab[i])
	if not all_double:
		print('NO')
	else:
		solve = True
		prod_to_find = tab1[0] * tab1[-1]
		n = len(tab1)
		for i in range(0, n // 2 + 1):
			prod = tab1[i] * tab1[n - 1 - i]
			if prod != prod_to_find:
				solve = False
				break
		print('YES' if solve else 'NO')


from math import gcd
import sys

def inpu():
	return sys.stdin.readline().strip()
q = int(inpu())
for i in range(q):
	n = int(input())
	mas = [int(i) for i in inpu().split()]
	mas = sorted(mas)
	mas1 = []
	m = dict()
	no = False
	for j in range(len(mas) - 1):
		if j % 2 == 0 and mas[j] == mas[j + 1]:
			mas1.append(mas[j])
		elif mas[j] != mas[j + 1] and j % 2 == 0:
			print('NO')
			no = True
			break
	if no:
		continue
	co = mas1[0] * mas1[len(mas1) - 1]
	no = False
	for j in range(1, len(mas1) // 2 + 1):
		if mas1[j] * mas1[len(mas1) - j - 1] != co:
			no = True
			break
	if not no:
		print('YES')
	else:
		print('NO')


R = lambda : map(int, input().split())
q = int(input())
for _ in q * [0]:
	n = int(input())
	a = list(R())
	sides = {}
	passed = True
	for side in a:
		if not sides.__contains__(side):
			sides[side] = 1
		else:
			sides[side] += 1
	a = []
	for (side, count) in sides.items():
		if count % 2 != 0:
			passed = False
			break
		for _ in count // 2 * [0]:
			a.append(side)
	if not passed:
		print('NO')
		continue
	a = sorted(a)
	s = a[0] * a[len(a) - 1]
	for i in range(len(a) // 2):
		if a[i] * a[len(a) - 1 - i] != s:
			passed = False
			break
	print('YNEOS'[not passed::2])


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().strip().split(' ')))
	lst.sort()
	f = 0
	p = lst[0] * lst[-1]
	j = 0
	while j < 2 * n:
		if lst[j] == lst[j + 1] and lst[4 * n - j - 1] == lst[4 * n - j - 2] and (lst[j] * lst[4 * n - j - 1] == p):
			j += 2
		else:
			f = 1
			print('NO')
			break
	if f == 0:
		print('YES')


from collections import Counter
import math
t = int(input())
for nt in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	cnt = Counter(l)
	flag = 0
	for i in cnt:
		if cnt[i] % 2 == 1:
			print('NO')
			flag = 1
			break
	if flag == 0:
		temp = []
		for i in cnt:
			for j in range(cnt[i] // 2):
				temp.append(i)
		temp.sort()
		flag = 0
		area = temp[0] * temp[-1]
		for i in range(len(temp) // 2):
			if temp[i] * temp[len(temp) - i - 1] != area:
				print('NO')
				flag = 1
				break
		if flag == 0:
			print('YES')


import math
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(I()):
	n = I()
	a = LI()
	a.sort()
	ans = a[0] * a[-1]
	flag = 1
	for i in range(n):
		if a[2 * i] != a[2 * i + 1] or a[4 * n - (2 * i + 1)] != a[4 * n - (2 * i + 2)] or a[2 * i] * a[4 * n - (2 * i + 1)] != ans:
			flag = 0
			break
	if flag:
		print('YES')
	else:
		print('NO')


def isposs(L):
	p = L[0] * L[-1]
	x = len(L)
	for i in range(0, x, 2):
		if L[i] != L[i + 1] or L[x - 1 - i] != L[x - 2 - i] or p != L[i] * L[x - 1 - i]:
			return 'NO'
	return 'YES'
t = int(input())
for i in range(0, t):
	n = int(input())
	L = list(map(int, input().split()))
	L.sort()
	print(isposs(L))


q = int(input())
for i in range(q):
	n = int(input())
	a = [int(j) for j in input().split()]
	a.sort()
	area = a[0] * a[-1]
	flag = True
	for i in range(n):
		if a[2 * i] == a[2 * i + 1] and a[-2 * i - 1] == a[-2 * i - 2] and (a[2 * i] * a[-2 * i - 2] == area):
			pass
		else:
			flag = False
	print('YES' if flag else 'NO')


for i in range(int(input())):
	n = int(input())
	s = sorted([int(i) for i in input().split()])
	e = s[0] * s[-1]
	c = True
	for i in range(0, 2 * n, 2):
		a = s[-i - 1] * s[i]
		if s[i] != s[i + 1] or s[-i - 1] != s[-i - 2] or a != e:
			c = 0
			break
	if c:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	for i in range(0, 2 * n, 2):
		if a[i] != a[i + 1] or a[-i - 1] != a[-i - 2]:
			print('NO')
			break
		if i == 0:
			area = a[i] * a[-i - 1]
		elif area != a[i] * a[-i - 1]:
			print('NO')
			break
	else:
		print('YES')


for case in range(int(input())):
	n = int(input())
	ha = {}
	sid = []
	a = input().split()
	for i in range(4 * n):
		if a[i] not in ha.keys():
			sid.append(int(a[i]))
			ha[a[i]] = 1
		else:
			ha[a[i]] += 1
	fl = True
	sid = sorted(sid)
	for i in range((len(sid) + 1) // 2 - 1):
		if sid[i] * sid[-i - 1] != sid[i + 1] * sid[-i - 2]:
			fl = False
	for i in range((len(sid) + 1) // 2):
		if ha[str(sid[i])] != ha[str(sid[-i - 1])]:
			fl = False
	for i in sid:
		if ha[str(i)] % 2 != 0:
			fl = False
	print('Yes' if fl else 'No')


from collections import defaultdict
q = int(input())
for i in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	a = l[0] * l[-1]
	flag = True
	for i in range(n * 2):
		if l[i * 2] != l[i * 2 + 1]:
			flag = False
			break
	for i in range(n * 2):
		if a != l[i] * l[n * 4 - 1 - i]:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


import sys
import os
from io import IOBase, BytesIO
import math
import collections
mod = 10 ** 9 + 7
pie = 3.1415926536

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def ain():
	return list(map(int, sin().split()))

def sin():
	return input().strip()

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

def read2DIntArray(row, col):
	arr = []
	for i in range(0, row):
		temp = list(map(int, sin().split()))
		arr.append(temp)
	return arr

def read2DCharArray(row, col):
	arr = []
	for i in range(0, row):
		temp = str(sin())
		arr.append(temp)
	return arr

def smallestNumber(n):
	lst = list(str(n))
	lst.sort()
	tmp = ''
	for (i, n) in enumerate(lst):
		if n != '0':
			tmp = lst.pop(i)
			break
	return str(tmp) + ''.join(lst)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	lst = []
	for p in range(n + 1):
		if prime[p]:
			lst.append(p)
	return lst

def nCr(n, r):
	a = 1
	b = 1
	c = 1
	for i in range(1, n + 1):
		c *= i
	for i in range(1, r + 1):
		b *= i
	for i in range(1, n - r + 1):
		a *= i
	return c // (a * b)

def sieveOfEratosthenes1(N, s):
	prime = [False] * (N + 1)
	for i in range(2, N + 1, 2):
		s[i] = 2
	for i in range(3, N + 1, 2):
		if prime[i] == False:
			s[i] = i
			for j in range(i, int(N / i) + 1, 2):
				if prime[i * j] == False:
					prime[i * j] = True
					s[i * j] = i

def generatePrimeFactors(N):
	s = [0] * (N + 1)
	sieveOfEratosthenes1(N, s)
	curr = s[N]
	cnt = 1
	factors = []
	power = []
	while N > 1:
		N //= s[N]
		if curr == s[N]:
			cnt += 1
			continue
		factors.append(curr)
		power.append(cnt)
		curr = s[N]
		cnt = 1
	return (factors, power)

def main():
	for _ in range(int(sin())):
		n = int(sin())
		a = ain()
		a = sorted(a, reverse=True)
		area = a[0] * a[-1]
		f = 0
		for i in range(0, 2 * n - 1, 2):
			if a[i] == a[i + 1] and a[-(i + 1)] == a[-(i + 2)] and (a[i] * a[-(i + 1)] == area):
				continue
			else:
				f = 1
				break
		if f == 0:
			print('YES')
		else:
			print('NO')
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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))

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


for i in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	ar = a[0] * a[-1]
	flag = 0
	for j in range(n):
		if a[j * 2] * a[4 * n - j * 2 - 1] != ar or a[j * 2 + 1] != a[j * 2] or a[4 * n - j * 2 - 2] != a[4 * n - j * 2 - 1]:
			flag = 1
			break
	if flag == 0:
		print('YES')
	else:
		print('NO')


def solution():
	n = int(input())
	ms = sorted(map(int, input().split()))
	i = 0
	prevl = 0
	sq = ms[0] * ms[-1]
	while i < 4 * n - 1 - i:
		if ms[i] * ms[4 * n - 1 - i] != sq:
			return False
		if i % 2 and ms[i] != ms[i - 1]:
			return False
		i += 1
	return True
q = int(input())
for i in range(q):
	if solution():
		print('YES')
	else:
		print('NO')


def rocess():
	a = input().split()
	b = []
	c = []
	a.sort(key=int)
	for x in range(0, len(a), 2):
		if a[x] != a[x + 1]:
			print('NO')
			return
		b.append(a[x])
	for x in range(len(b) // 2):
		c.append(int(b[x]) * int(b[len(b) - x - 1]))
	for z in range(len(c) - 1):
		if c[z] != c[z + 1]:
			print('NO')
			break
	else:
		print('YES')
q = int(input())
for x in range(q):
	input()
	rocess()


n = int(input())
for iter in range(n):
	s_len = int(input())
	s = [int(x) for x in input().split(' ')]
	s.sort()
	ok = 'YES'
	square = s[0] * s[-1]
	for se in range(1, len(s)):
		if s[se] * s[-1 * (se + 1)] != square or s.count(s[se]) % 2 != 0:
			ok = 'NO'
	print(ok)