Read problems statements in Mandarin Chinese  and Russian. 

Sereja conducted a voting about N of his opinions. A_{i} percent of people voted for opinion number i. 
This statistics is called valid if sum of all A_{i} is equal to 100. 

Now let us define rounding up of a statistics A. 
If A_{i} is not an integer, it will be rounded up to next integer. 
Otherwise it will be left as it is. 

e.g. 4.1 became 5, 4.9 became 5 but 6 will still be 6.

Now let us consider a statistics B of size N in which each of B_{i} is an integer. Now he wants to know whether there exists some valid statistic A of size N  (may contain real numbers) such that after rounding it up, it becomes same as B?

------ Input ------ 

First line of input contain integer T - number of test cases. 
For each test, case first line contains integer N - number of opinions. 
Next line contains N integers B_{1}, B_{2}, ..., B_{N} as defined in the problem.

------ Output ------ 

For each test case, output YES or NO denoting the answer of the problem, i.e. if there exists some statistics A which could be rounded to make it B, print YES otherwise NO. 

------ Constraints ------ 

$1 ≤ T ≤ 50$
$1 ≤ N ≤ 10000$
$0 ≤ B_{i} ≤ 1000$

------ Sub tasks ------ 

$Subtask #1: N ≤ 100 (50 points)$
$Subtask #2: original (50 points)$

----- Sample Input 1 ------ 
3
3
30 30 30
4
25 25 25 25
2
50 51
----- Sample Output 1 ------ 
NO
YES
YES
----- explanation 1 ------ 

In test case 1, There can not be any A which could be rounded up to get B. Hence answer is NO.
In test case 2, In this case A = {25, 25, 25, 25}. After rounding we get {25, 25, 25, 25} which is equal to B. Hence answer is YES.
In test case 3, A = {49.5, 50.5}. After rounding up we get {50, 51} which is equal to B. Hence answer is YES.

Source: codechef | Difficulty: MEDIUM
Tags: Mathematics


Solutions:
t = int(input())
for _ in range(t):
	N = int(input())
	B = list(map(int, input().split()))
	total = ones = 0
	flag = 0
	for i in B:
		if i > 0:
			ones += 1
			total += i
		if i > 100:
			flag = 1
	if total - ones < 100 and total >= 100:
		ans = 'YES'
	else:
		ans = 'NO'
	print(ans)


T = int(input())
if T <= 50 and T >= 1:
	for i in range(T):
		N = int(input())
		lst = list(map(int, input().strip().split()))[:N]
		s = sum(lst)
		if s < 100:
			print('NO')
		elif s == 100:
			print('YES')
		elif s > 100:
			if s < 100 + (len(lst) - lst.count(0)):
				print('YES')
			else:
				print('NO')


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	a = sum(arr)
	if a == 100:
		print('YES')
	elif a < 100:
		print('NO')
	else:
		count = 0
		for i in arr:
			if i > 0:
				count += 1
		if count >= a - 100 + 1:
			print('YES')
		else:
			print('NO')


t = int(input())
for tc in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	tot = cnt = 0
	for i in range(0, n):
		tot += b[i]
		if b[i] > 0:
			cnt += 1
	if tot >= 100 and tot - cnt < 100:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ll = []
	for i in range(n):
		if l[i] != 0:
			ll.append(l[i])
	if sum(l) < 100:
		print('NO')
	elif sum(l) == 100:
		print('YES')
	elif sum(ll) - 100 >= len(ll):
		print('NO')
	else:
		print('YES')


(h1, h2) = (1, 1)
kk = h2
o = int(input())
for i in range(o):
	m = int(input())
	l = list(map(int, input().split()))
	p_100 = list(filter(lambda x: x > 100, l))
	if sum(l) < 100 or len(p_100) >= 1:
		print('NO')
	else:
		if sum(l) == 100:
			print('YES')
			continue
		if l.count(0) >= 1:
			z_l = l.count(0) * [0]
			n_l = list(map(lambda x: l.remove(x), z_l))
		flag = sum(l) - 100
		if flag <= len(l) - 1:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if sum(arr) < 100:
		print('NO')
	elif sum(arr) == 100:
		print('YES')
	else:
		z = (sum(arr) - 100) / (n - arr.count(0))
		if z < 1:
			print('YES')
		else:
			print('NO')


x = []
testcase = int(input())
for i in range(testcase):
	n = int(input())
	x = list(map(int, input().strip().split(' ')[:n]))
	if sum(x) < 100:
		print('NO')
	elif sum(x) == 100:
		print('YES')
	elif sum(x) - 100 < len(x) - x.count(0):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	j = sum(b)
	if j >= 100 and j < 100 + n - b.count(0):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	sum_x = sum(x)
	c = 0
	for i in x:
		if i > 0:
			c += 1
	if sum_x < 100:
		print('NO')
	elif sum_x == 100:
		print('YES')
	elif sum_x - c < 100:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	b = []
	n = int(input())
	b = list(map(int, input().split()))
	suma = 0
	count = 0
	valid = True
	for j in b:
		if j > 100:
			valid = False
		if j > 0:
			count += 1
	suma = sum(b)
	if valid and suma - 100 >= 0 and (suma - 100 < count):
		print('YES')
	else:
		print('NO')


import numpy as np
import sys
testcases = int(input())
for i in range(testcases):
	no_op = int(input())
	ops = np.zeros(no_op)
	ops = list(map(int, sys.stdin.readline().split()))
	ops = np.array(ops)
	sum_op = ops.sum()
	count = 0
	for i in range(no_op):
		if ops[i] > 0:
			count = count + 1
	if sum_op < 100:
		print('NO')
	elif sum_op == 100:
		print('YES')
	elif sum_op - count < 100:
		print('YES')
	else:
		print('NO')


try:
	t = int(input())
	for i in range(t):
		n = int(input())
		b = list(map(int, input().split()))
		valid = True
		s = 0
		c = 0
		for i in b:
			if i > 100:
				valid = False
			if i > 0:
				c += 1
		s = sum(b)
		if valid and s - 100 >= 0 and (s - 100 < c):
			print('YES')
		else:
			print('NO')
except:
	pass


T = int(input())
for tc in range(T):
	N = int(input())
	a = []
	s = input().split()
	s1 = 0
	for i in range(N):
		x = int(s[i])
		if x > 0:
			a.append(x)
		s1 = s1 + x
	if s1 >= 100 and s1 < len(a) + 100:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	A = A[:n]
	s = sum(A)
	ans = True
	c = 1
	for i in A:
		if i > 100:
			ans = False
		if i > 0:
			c += 1
	if s == 100:
		print('YES')
	elif s >= 100 and s < 99 + c and (ans == True):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	d = list(map(int, input().split()))
	tot = cnt = 0
	for i in range(0, n):
		tot += d[i]
		if d[i] > 0:
			cnt += 1
	if tot < 100 or tot - (cnt - 1) > 100:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	b = list(map(int, input().split()))
	sum = 0
	for i in b:
		if i == 0:
			n -= 1
		sum += i
	if sum == 100:
		print('YES')
	elif sum > 100 and sum < 100 + n:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	(cnt, s) = (0, 0)
	flag = False
	for i in arr:
		if i > 100:
			flag = True
			break
		if i > 0:
			cnt += 1
		s += i
	if (s >= 100 and s <= 99 + cnt) and (not flag):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(0, t):
	x = int(input())
	y = list(map(int, input().split()))[:x]
	if sum(y) < 100:
		print('NO')
	elif sum(y) == 100:
		print('YES')
	elif sum(y) - 100 < len(y) - y.count(0):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	N = int(input())
	B = list(map(int, input().split()))
	sumB = 0
	for i in B:
		sumB += i
	c = 0
	valid = True
	for i in B:
		if i > 100:
			valid = False
		if i > 0:
			c = c + 1
	if sumB >= 100 and sumB - 100 < c and valid:
		print('YES')
	else:
		print('NO')


import math
for _ in range(int(input())):
	n = int(input())
	B = list(map(int, input().split()))
	s = 0
	l = 0
	f = 0
	for i in B:
		if i > 0:
			l += 1
			s += i
		if i > 100:
			f = 1
	if f == 1:
		ans = 'NO'
	elif s - l < 100 and s >= 100:
		ans = 'YES'
	else:
		ans = 'NO'
	print(ans)


t = int(input())
while t != 0:
	n = int(input())
	is_possible = True
	nums = list(map(int, input().split()))
	non_zero_numbers = 0
	for x in nums:
		if x != 0:
			non_zero_numbers = non_zero_numbers + 1
		if x > 100:
			is_possible = False
	if sum(nums) < 100 or sum(nums) - 100 >= non_zero_numbers or (not is_possible):
		print('NO')
	else:
		print('YES')
	t = t - 1


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	sum = 0
	for i in range(n):
		sum = sum + l[i]
	c = 0
	valid = True
	for i in l:
		if i > 100:
			valid = False
		if i > 0:
			c = c + 1
	if valid and sum >= 100 and (sum - 100 < c):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	k = l.count(0)
	sum1 = sum(l) - 100
	if sum1 >= 0 and sum1 <= n - k - 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	flag = True
	sum = count = 0
	for i in lst:
		if i > 100:
			flag = False
		if i > 0:
			count += 1
		sum += i
	if flag and sum >= 100 and (sum < 100 + count):
		print('YES')
	else:
		print('NO')


t = int(input())
for uefh in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	s = sum(b)
	c = b.count(0)
	l = n - c
	if s < 100:
		print('NO')
	elif s > l + 99:
		print('NO')
	else:
		print('YES')


from math import *
from collections import *
from functools import *

def rvi():
	return [*map(int, input().split())]
for _ in range(int(input())):
	n = int(input())
	b = rvi()
	S = sum(b)
	s = 0
	for x in b:
		s += max(0, x - 1)
	print(('NO', 'YES')[S >= 100 and s < 100])


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s1 = sum(l)
	k = 0
	count = 0
	for i in l:
		if i > 0:
			count += 1
		if i > 100:
			k == 1
			break
	if k == 1:
		print('NO')
		continue
	elif s1 - 100 >= 0 and s1 - 100 < count:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	N = int(input())
	B = list(map(int, input().split()))
	suma = 0
	valid = True
	count = 0
	for i in B:
		if i > 100:
			valid = False
		if i > 0:
			count += 1
	suma = sum(B)
	if valid and suma - 100 >= 0 and (suma - 100 < count):
		print('YES')
	else:
		print('NO')


for T in range(int(input())):
	N = int(input())
	B = input().strip().split()
	for i in range(len(B)):
		B[i] = int(B[i])
	check = False
	temp = B.copy()
	nonzero = B.count(0)
	if sum(B) < 100:
		check = False
	elif sum(B) == 100:
		check = True
	elif sum(B) > 100:
		if sum(B) < 100 + (len(B) - nonzero):
			check = True
	if check == False:
		print('NO')
	elif check == True:
		print('YES')


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	sumb = 0
	count = 0
	valid = True
	for j in l:
		if j > 100:
			valid = False
		if j > 0:
			count += 1
	sumb = sum(l)
	if valid and 0 <= sumb - 100 < count:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	N = int(input())
	x = list(map(int, input().split()))
	s = sum(x)
	c = 0
	for i in x:
		if i > 0:
			c += 1
	if s < 100:
		print('NO')
	elif s == 100:
		print('YES')
	elif s - c < 100:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	m = int(input())
	l = list(map(int, input().split()))
	gt_100 = list(filter(lambda x: x > 100, l))
	if sum(l) < 100 or len(gt_100) >= 1:
		print('NO')
	else:
		if sum(l) == 100:
			print('YES')
			continue
		if l.count(0) >= 1:
			z_l = l.count(0) * [0]
			n_l = list(map(lambda x: l.remove(x), z_l))
		limit = sum(l) - 100
		if limit <= len(l) - 1:
			print('YES')
		else:
			print('NO')


T = int(input())
for tc in range(T):
	N = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	Ncount = N - l.count(0)
	if s >= 100 and s - Ncount < 100:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	s = 0
	v = True
	c = 0
	for j in b:
		if j > 100:
			v = False
		if j > 0:
			c += 1
	s = sum(b)
	print('YES' if v and s - 100 >= 0 and (s - 100 < c) else 'NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(float, input().split()))
	if sum(a) >= 100 and sum(a) - n + a.count(0) < 100:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = int(input())
	d = 0
	count = 0
	b = list(map(int, input().split()))
	x = sum(b)
	for j in b:
		if j > 100:
			d = d + 1
		if j > 0:
			count = count + 1
	if d == 0 and x - 100 < count and (x - 100 >= 0):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	N = int(input())
	b = list(map(int, input().split(' ')))
	sumb = 0
	n = 0
	for j in b:
		if j != 0:
			sumb += j
			n += 1
	if sumb - n < 100 and sumb >= 100:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	N = int(input())
	b = list(map(int, input().split(' ')))
	lower_lim = 0
	upper_lim = 0
	addl = 0
	for j in b:
		if j != 0:
			addl = 1
		lower_lim += max(0, j - 1)
		upper_lim += j
	if lower_lim + addl <= 100 and 100 <= upper_lim:
		print('YES')
	else:
		print('NO')


t = int(input())
for test in range(t):
	n = int(input())
	num = list(map(int, input().split()))
	s = sum(num)
	c = 0
	for i in num:
		if i > 0:
			c += 1
	if s < 100:
		print('NO')
	elif s == 100:
		print('YES')
	elif s - c < 100:
		print('YES')
	else:
		print('NO')


t = int(input())
for tc in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if sum(a) < 100:
		print('NO')
	elif sum(a) == 100:
		print('YES')
	else:
		z = (sum(a) - 100) / (n - a.count(0))
		if z < 1:
			print('YES')
		else:
			print('NO')


k = int(input())
for _ in range(k):
	m = int(input())
	num_list = list(map(int, input().split()))
	zero_ct = num_list.count(0)
	non_zero_ct = len(num_list) - zero_ct
	if sum(num_list) == 100:
		print('YES')
	elif sum(num_list) < 100:
		print('NO')
	elif sum(num_list) > 100:
		diff = sum(num_list) - 100
		each_val_deviation = diff / non_zero_ct
		if each_val_deviation < 1:
			print('YES')
		else:
			print('NO')


def check(s, n, arr):
	count = 0
	v = True
	for i in arr:
		if i > 100:
			v = False
		if i > 0:
			count += 1
	if v and s - 100 >= 0 and (s - 100 < count):
		return 'YES'
	else:
		return 'NO'
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	s = sum(arr)
	print(check(s, n, arr))


for t in range(int(input())):
	n = int(input())
	L = list(map(int, input().split()))
	print('YES' if 100 <= sum(L) <= 100 + n - L.count(0) - 1 else 'NO')


t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	k = l.count(0)
	if s == 100:
		print('YES')
	elif s < 100:
		print('NO')
	elif s - (n - k - 1) <= 100 and s > 100:
		print('YES')
	else:
		print('NO')
	t = t - 1


for i in range(int(input())):
	sum = 0
	B = []
	N = int(input())
	ele = list(map(float, input().strip().split()))[:N]
	total = 0
	ones = 0
	flag = 0
	for i in ele:
		if i > 0:
			total += i
			ones += 1
		if i > 100:
			flag == 1
	if flag == 1:
		print('NO')
	elif total - ones < 100 and total >= 100:
		print('YES')
	else:
		print('NO')


import math

def main_check(array, array_len):
	if sum(array) >= 100 and sum(array) - (array_len - array.count(0)) < 100:
		return 'YES'
	else:
		return 'NO'
for i in range(int(input())):
	array_len = int(input())
	array = list(map(int, input().split()))
	result = main_check(array, array_len)
	print(result)


for _ in range(int(input())):
	n = int(input())
	s = 0
	l = input().split()
	for i in l:
		if int(i) <= 100:
			s += int(i)
			if not int(i):
				n -= 1
		else:
			print('NO')
			break
	else:
		a = s - 100
		if a >= 0 and a < n:
			print('YES')
		else:
			print('NO')


for T in range(int(input())):
	N = int(input())
	B = list(map(int, input().split()))
	if 100 <= sum(B) < 100 + N - B.count(0):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	if 100 <= sum(A) < 100 + n - A.count(0):
		print('YES')
	else:
		print('NO')


import io, sys, os
t = int(input())
for _ in range(t):
	N = int(input())
	B = list(map(int, input().split()))
	total = ones = 0
	flag = 0
	for i in B:
		if i > 0:
			ones += 1
			total += i
		if i > 100:
			flag = 1
	if flag == 1:
		ans = 'NO'
	elif total - ones < 100 and total >= 100:
		ans = 'YES'
	else:
		ans = 'NO'
	print(ans)