You are given an array of $n$ integers $a_1, a_2, \ldots, a_n$. After you watched the amazing film "Everything Everywhere All At Once", you came up with the following operation.

In one operation, you choose $n-1$ elements of the array and replace each of them with their arithmetic mean (which doesn't have to be an integer). For example, from the array $[1, 2, 3, 1]$ we can get the array $[2, 2, 2, 1]$, if we choose the first three elements, or we can get the array $[\frac{4}{3}, \frac{4}{3}, 3, \frac{4}{3}]$, if we choose all elements except the third.

Is it possible to make all elements of the array equal by performing a finite number of such operations?


-----Input-----

The first line of the input contains a single integer $t$ ($1 \le t \le 200$)  — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $n$ ($3 \le n \le 50$)  — the number of integers.

The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le 100$).


-----Output-----

For each test case, if it is possible to make all elements equal after some number of operations, output ${YES}$. Otherwise, output ${NO}$.

You can output ${YES}$ and ${NO}$ in any case (for example, strings ${yEs}$, ${yes}$, ${Yes}$ will be recognized as a positive response).


-----Examples-----

Input
4
3
42 42 42
5
1 2 3 4 5
4
4 3 2 1
3
24 2 22
Output
YES
YES
NO
NO


-----Note-----

In the first test case, all elements are already equal.

In the second test case, you can choose all elements except the third, their average is $\frac{1 + 2 + 4 + 5}{4} = 3$, so the array will become $[3, 3, 3, 3, 3]$.

It's possible to show that it's impossible to make all elements equal in the third and fourth test cases.

Source: codeforces | Difficulty: EASY
Tags: Greedy algorithms


Solutions:
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	res = 'NO'
	s = sum(arr)
	for i in arr:
		if (s - i) / (n - 1) == i:
			res = 'YES'
			break
	print(res)


def solve():
	input()
	nums = list(map(int, input().split()))
	s = sum(nums)
	n = len(nums)
	for x in nums:
		if x * n == s:
			print('YES')
			return
	print('NO')
	return
n = int(input())
for i in range(n):
	solve()


def goc(arr, n):
	for i in range(n):
		if (sum(arr) - arr[i]) / (n - 1) == float(arr[i]):
			return 'YES'
	return 'NO'
t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	print(goc(arr, n))
	t -= 1


inp1 = int(input())
for i in range(inp1):
	inp2 = int(input())
	inp3 = list(map(int, input().split()))
	if sum(inp3) / inp2 in inp3:
		print('YES')
	else:
		print('NO')


import math as m
i = input()
inp = []
for a in range(0, int(i)):
	input()
	inp += [input()]

def dec(arr):
	n = len(arr)
	s = sum(arr)
	target = s / n
	for i in arr:
		if (s - i) / (n - 1) == target:
			return 'YES'
	return 'NO'
for s in inp:
	arr = [int(x) for x in s.split()]
	print(dec(arr))


t = int(input())
while t:
	n = int(input())
	ay = list(map(int, input().split()))
	avg = sum(ay) / n
	if avg in ay:
		print('YES')
	else:
		print('NO')
	t -= 1


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	s = sum(li)
	if s / n in li:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = sum(a) / n
	if b in a:
		print('YES')
	else:
		print('NO')


for x in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if len(set(l)) == 1:
		print('YES')
	else:
		ans = False
		k = sum(l)
		for x in l:
			if (k - x) // (n - 1) == x and (k - x) % (n - 1) == 0:
				ans = True
		if ans:
			print('YES')
		else:
			print('NO')


t = int(input())
i = 0
while i < t:
	n = int(input())
	c = 0
	i += 1
	a = list(map(int, input().split()))
	s = 0
	for n in range(len(a)):
		s = s + a[n]
	for n in range(len(a)):
		if a[n] == s / len(a):
			c = 1
			break
		else:
			c = 0
	if c == 0:
		print('NO')
	else:
		print('YES')


m = int(input())
for i in range(m):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s % n == 0:
		if s // n in a:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if sum(l) / n in l:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) % n == 0 and sum(a) // n in a:
		print('YES')
	else:
		print('NO')


for s in [*open(0)][2::2]:
	a = (*map(int, s.split()),)
	print('NYOE S'[sum(a) / len(a) in a::2])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	s = sum(a)
	ans = 'NO'
	for i in a:
		if (s - i) / (n - 1) == i:
			ans = 'YES'
			break
	print(ans)


def solve(l, n):
	m = sum(l) / n
	for i in range(0, n):
		if m == l[i]:
			return True
	return False
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	if solve(l, n):
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	n = int(input())
	d = [int(i) for i in input().split()]
	total = 0
	for i in d:
		total += i
	res = False
	for i in d:
		if (total - i) / (n - 1) == i:
			res = True
			break
	if res:
		print('YES')
	else:
		print('NO')


def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	Sum = sum(arr) / n
	if Sum in arr:
		print('YES')
	else:
		print('NO')
cases = int(input())
for i in range(cases):
	solve()


import sys

def solve(A):
	n = len(A)
	s = sum(A)
	ok = False
	for a in A:
		if a * (n - 1) == s - a:
			ok = True
	return 'YES' if ok else 'NO'

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		A = list(map(int, input().split()))
		print(solve(A))
main()


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	s = 0
	for i in range(len(arr)):
		s = s + arr[i]
	if s / len(arr) in arr:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	summ = sum(arr)
	for i in range(n):
		mean = (summ - arr[i]) / (n - 1)
		if mean == arr[i]:
			print('YES')
			break
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	ls = list(map(int, input().split()))
	s = sum(ls)
	if s % n == 0:
		z = s / n
		if z in ls:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	ss = int(input())
	arr = list(map(int, input().split()))
	success = False
	l = sum(arr)
	for i in range(ss):
		tmp = (l - arr[i]) / (ss - 1)
		if tmp == arr[i]:
			success = True
			break
	print('YES' if success else 'NO')


def MakeEqual():
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	for i in l:
		if (s - i) / (len(l) - 1) == float(i):
			return 'YES'
			return
	return 'NO'
for _ in range(int(input())):
	print(MakeEqual())


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	s = sum(arr)
	check = False
	for i in arr:
		if (s - i) / (n - 1) == i:
			check = True
			break
	if check:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	sum = 0
	for i in l:
		sum += i
	flag = 1
	for j in l:
		new = sum - j
		avg = new / (n - 1)
		if avg == j:
			flag = 0
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


test = int(input())
for i in range(test):
	n = int(input())
	arr = list(map(int, input().split()))
	s = sum(arr)
	if s % n != 0:
		print('NO')
	else:
		d = s / n
		if d in arr:
			print('YES')
		else:
			print('NO')


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split(' ')))
	tsum = sum(a)
	ans = 'NO'
	for i in a:
		if (tsum - i) / (n - 1) == i:
			ans = 'YES'
			break
	print(ans)
	t -= 1


import math
for i in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	c = sum(b) / len(b)
	if c in b:
		print('YES')
	else:
		print('NO')


def a():
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	for i in a:
		if i * n == s:
			return 'YES'
	return 'NO'
for _ in range(int(input())):
	print(a())


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	flag = False
	for i in range(n):
		x = s - l[i]
		if x / (n - 1) == l[i]:
			flag = True
			break
	print('YES') if flag else print('NO')


for tc in range(int(input())):
	n = int(input())
	a = list(map(int, input().split(sep=' ', maxsplit=n - 1)))
	if sum(a) / n in a:
		print('YES')
	else:
		print('NO')


test = int(input())
for x in range(test):
	baler_input = int(input())
	l = list(map(int, input().split()))
	sum = 0
	for gg in l:
		sum += gg
	if sum / baler_input in l:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	for i in l:
		if (s - i) % (n - 1) == 0:
			if (s - i) // (n - 1) == i:
				print('YES')
				break
	else:
		print('NO')


def sol(a, n):
	total = sum(a)
	for v in a:
		if v == (total - v) / (n - 1):
			return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(v) for v in input().split()]
	print(sol(a, n))


def func():
	N = int(input())
	a = [int(x) for x in input().split()]
	total = sum(a)
	for x in a:
		now = total - x
		if now % (N - 1) == 0 and now // (N - 1) == x:
			print('YES')
			return
	print('NO')
for _ in range(int(input())):
	func()


for i in range(int(input())):
	n = int(input())
	s = [int(i) for i in input().split()]
	if sum(s) / n in s:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	sum1 = sum(a)
	flag = 0
	for i in range(n):
		sum2 = sum1 - a[i]
		if sum2 % (n - 1) == 0:
			if sum2 / (n - 1) == a[i]:
				flag = 1
				break
	if flag:
		print('YES')
	else:
		print('NO')


testCases = input()
dis = []
j = 1
while j <= int(testCases):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort(key=None, reverse=False)
	sum = 0
	mid = 0
	for i in range(0, n):
		sum = sum + lst[i]
	mid = sum / n
	if lst.count(mid):
		dis.append('YES')
	else:
		dis.append('NO')
	j += 1
print(*dis, sep='\n')


for e in [*open(0)][2::2]:
	f = (*map(int, e.split()),)
	print('NYOE S'[sum(f) / len(f) in f::2])


for _ in range(int(input())):
	a = int(input())
	b = [*map(int, input().split())]
	c = sum(b) / a
	if c in b:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = sum(a)
	f = 0
	for i in range(n):
		if (b - a[i]) / (n - 1) == a[i]:
			f = 1
			print('YES')
			break
	if f == 0:
		print('NO')


def run():
	sum = 0
	input()
	l = list(map(int, input().split()))
	for item in l:
		sum += item
	for item in l:
		sum2 = sum - item
		if sum2 == item * (len(l) - 1):
			print('YES')
			return
	print('NO')
	return

def main():
	n = int(input())
	for i in range(n):
		run()
main()


for i in range(int(input())):
	x = int(input())
	l = list(map(int, input().strip().split()))
	if sum(l) / x in l:
		print('YES')
	else:
		print('NO')


T = int(input())
while T:
	T -= 1
	n = int(input())
	a = list(map(int, input().split()))
	sum = 0
	for i in a:
		sum += i
	f = 0
	if sum % n:
		f = 1
	f1 = 0
	sum //= n
	for i in a:
		if sum == i:
			f1 = 1
	if f1 and f == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split()))
	tot = sum(a)
	suc = 0
	for j in range(n):
		if (tot - a[j]) % (n - 1) == 0 and (tot - a[j]) // (n - 1) == a[j]:
			print('YES')
			suc = 1
			break
	if suc == 0:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	if sum(l) % len(l) == 0 and sum(l) // len(l) in l:
		print('YES')
	else:
		print('NO')


def solve(lst: list, size: int):
	summ = 0
	for i in lst:
		summ += i
	result = summ / size
	str_result = str(result)
	if str_result[-1] == '0' and str_result[-2] == '.':
		if result in lst:
			return 'YES'
		else:
			return 'NO'
	else:
		return 'NO'
t = int(input())
temp = []
for i in range(t):
	n = int(input())
	lst = [int(i) for i in input().split()]
	temp.append(solve(lst, n))
for j in temp:
	print(j)


for i in range(int(input())):
	num = int(input())
	values = list(map(int, input().split()))
	if sum(values) / num in values:
		print('YES')
	else:
		print('NO')


for cases in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	if sum(a) / n in a:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	v = [*map(int, input().split())]
	print('YES' if sum(v) / n in v else 'NO')


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	me = sum(arr) / n
	if me in arr:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	total = sum(a)
	flag = False
	for x in a:
		if (total - x) % (n - 1) == 0 and (total - x) // (n - 1) == x:
			flag = True
			break
	if flag:
		print('YES')
	else:
		print('NO')


def Everything_Everywhere_All_But_One(lst):
	sum_all = sum(lst)
	count_all_but_one = len(lst) - 1
	for elem in lst:
		if (sum_all - elem) / count_all_but_one == elem:
			return 'YES'
	return 'NO'
t = int(input())
while t:
	n = int(input())
	everything = list(map(int, input().split()))
	print(Everything_Everywhere_All_But_One(everything))
	t -= 1


def loop_test_cases():
	return range(int(input()))

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

def tuple_input():
	return (int(i) for i in input().split())

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

def medium(value):
	avg = sum(value) / len(value)
	return avg
for i in loop_test_cases():
	len_ = int(input())
	lista_ = list_input()
	avg = medium(lista_)
	if avg in lista_:
		print('YES')
	else:
		print('NO')


cases = int(input())
for i in range(cases):
	ok = False
	sze = int(input())
	lst = list(map(int, input().split()))
	totalSum = sum(lst)
	for t in range(sze):
		tempNum = lst[t]
		tempSum = totalSum - tempNum
		tempMean = tempSum / (sze - 1)
		if tempMean == tempNum:
			ok = True
			break
	print('YES' if ok else 'NO')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(j) for j in input().split()]
	su = sum(arr)
	if su % n != 0 or su // n not in arr:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	x = sum(arr)
	flag = 0
	for i in arr:
		if x - i == (n - 1) * i:
			print('YES')
			flag = 1
			break
	if flag == 0:
		print('NO')


def solve():
	n = int(input())
	arr = list(map(int, input().split(' ')))
	s = 0
	for ele in arr:
		s += ele
	s /= n
	for ele in arr:
		if ele == s:
			print('YES')
			return
	print('NO')
t = int(input())
for i in range(t):
	solve()


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	z = Counter(l)
	t = sum(l)
	if t % n == 0 and z[t // n]:
		print('YES')
	else:
		print('NO')


import sys

def rall():
	return sys.stdin.readlines()

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

def rl_types(types):
	str_list = [x for x in sys.stdin.readline().strip().split(' ')]
	return [types[i](str_list[i]) for i in range(len(str_list))]

def pr(something=''):
	sys.stdout.write(str(something) + '\n')

def pra(array):
	sys.stdout.write(' '.join([str(x) for x in array]) + '\n')

def solve(array):
	return array
NT = int(rl())
for ti in range(NT):
	_ = rl()
	array = list(map(int, rl().split(' ')))
	mean = sum(array) / len(array)
	possible = mean in array
	pr('YES' if possible else 'NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(N, A) = (int(input()), list(map(int, input().split())))
	S = sum(A)
	for i in A:
		if (S - i) / (N - 1) == i:
			print('YES')
			break
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	s = sum(lst)
	e = 0
	for j in lst:
		if (s - j) / (n - 1) == j:
			e += 1
			break
	if e > 0:
		print('YES')
	else:
		print('NO')


for tcase in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print('YES' if sum(a) / len(a) in a else 'NO')