Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. 

Andrash study in Uzhland National University. Now is the time of exam results. Andrash similar to other students, hopes that this scores in the exam could fetch him a scholarship/stipendium for his studies.

There are following simple rules to receive stipendium:

University follows 5 point grading system. In an exam, a student can receive any score from 2 to 5. 2 is called an F grade, meaning that student has failed that exam.
Student should not have fail any of the exams.
Student must obtain a full score in some of his/her exams to show that he/she is excellent in some of the subjects.
He/She must have a grade point average not less than 4.0

You are given information regarding the exams and how Andrash performed in those. Can you help him figure out whether he will receive the stipendium or not!!

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

The first line of input contains a single integer T denoting the number of test cases. This will be followed by T test cases.
The first line of each test case contains an integer N denoting the number of examinations.
The next line of each test case contains N space separated integers denoting Andrash's score for each exam.

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

For each of the T test cases, output a single line - "Yes" (without quotes) if Andrash will receive stipendium, or "No" (without quotes) - otherwise.

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

$ 1 ≤ T  ≤ 40 $
$ Let A[i] denote Andrash's score for i-th exam $
 
Subtask #1: 20 points

$1 ≤ N ≤ 100 $
$2 ≤ A[i]  ≤ 5$
 
Subtask #2: 20 points

$ 1 ≤ N  ≤ 10^{5} $
$ 3 ≤ A[i] ≤ 5 $ 
 
Subtask #3: 60 points

$ 1 ≤ N ≤ 10^{5} $
$ 2 ≤ A[i] ≤ 5 $

----- Sample Input 1 ------ 
2

5

3 5 4 4 3

5

3 4 4 4 5
----- Sample Output 1 ------ 
No

Yes
----- explanation 1 ------ 
Example case 1. Student's average grade point score is 3.8 which makes him/her unqualified for obtaining the stipend.
Example case 2. Student satisfies all the criteria for getting stipend.

Difficulty: EASY
Tags: Mathematics

Starter code:

Solutions:
t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	if 2 in s:
		print('No')
	elif sum(s) / n < 4:
		print('No')
	elif 5 not in s:
		print('No')
	else:
		print('Yes')


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	f = 1
	c = 0
	for i in range(n):
		if l[i] <= 2:
			f = 0
			break
		elif l[i] == 5:
			c = c + 1
	if f == 0:
		print('No')
	elif f == 1 and c > 0 and (sum(l) / n >= 4.0):
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	if 2 in a or 5 not in a:
		print('No')
	elif sum(a) < 4 * n:
		print('No')
	else:
		print('Yes')


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	max1 = max(l)
	avg = sum(l) / n
	flag = True
	for i in l:
		if i <= 2:
			flag = False
	if flag == True and max1 == 5 and (avg >= 4.0):
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	x = int(input())
	l = list(map(int, input().split()))
	c = sum(l) / x
	a = 5 in l
	b = 2 not in l
	if a and b and (c >= 4):
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	if 2 not in m and 5 in m and (sum(m) / n >= 4.0):
		print('Yes')
	else:
		print('No')


def solve():
	n = int(input())
	l = list(map(int, input().split()))
	print('Yes' if l.count(2) == 0 and l.count(5) >= 1 and (sum(l) / n >= 4) else 'No')
for _ in range(int(input())):
	solve()


t = int(input())
for ni in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	if 2 in l or 5 not in l:
		print('No')
	else:
		a = sum(l) / n
		if a >= 4.0:
			print('Yes')
		else:
			print('No')


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if 2 not in a and 5 in a and (sum(a) / n >= 4.0):
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	avg = sum(l) / n
	flag = True
	for i in range(n):
		if l[i] < 3:
			flag = False
	if flag and avg >= 4.0 and (5 in l):
		print('Yes')
	else:
		print('No')


for i in range(int(input())):
	exam = int(input())
	score = list(map(int, input().split()))
	a = 'No'
	if 5 in score:
		if sum(score) / exam >= 4 and 2 not in score:
			a = 'Yes'
	print(a)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if 5 not in l:
		print('No')
	elif 2 in l:
		print('No')
	elif sum(l) // n < 4:
		print('No')
	else:
		print('Yes')


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	if s[0] < 3:
		print('No')
	elif s[n - 1] != 5:
		print('No')
	elif sum(s) / n < 4:
		print('No')
	else:
		print('Yes')


t = int(input())
for t in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	flag = 1
	sum = 0
	count = 0
	for a in arr:
		if a < 3:
			flag = 0
			break
		if a == 5:
			count += 1
		sum += a
	avg = sum / n
	if flag == 1 and count >= 1 and (avg >= 4):
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	a = list(map(float, input().split()))
	if sum(a) / n >= 4:
		if 5 in a and 2 not in a:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


for tc in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = 'No'
	fail = 2 in a
	gpa = sum(a) / n
	excellent = 5 in a
	if gpa >= 4.0 and (not fail) and excellent:
		ans = 'Yes'
	print(ans)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().strip().split()))[:n]
	f = True
	s = set(l)
	avg = sum(l) / n
	if 5 in s and 2 not in s and (avg >= 4.0):
		print('Yes')
	else:
		print('No')


import math
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if min(a) < 3 or sum(a) < 4 * n or 5 not in a:
		print('No')
	else:
		print('Yes')


for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	if min(A) < 3 or sum(A) < 4 * N or 5 not in A:
		print('No')
	else:
		print('Yes')


for t in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	avg = sum(x) / n
	if min(x) > 2 and max(x) == 5 and (avg >= 4):
		print('Yes')
	else:
		print('No')


import math
for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	avg = sum(s) / n
	if 5 in s and avg >= 4.0 and (2 not in s):
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	t = sum(l)
	if l[n - 1] == 5 and l[0] != 2 and (t / n >= 4):
		print('Yes')
	else:
		print('No')


t = int(input())
while t > 0:
	n = int(input())
	m = list(map(int, input().split()))
	s = sum(m) / n
	if 5 in m and s >= 4 and (2 not in m):
		print('Yes')
	else:
		print('No')
	t -= 1


for _ in range(int(input())):
	N = int(input())
	x = list(map(int, input().split()))
	if 2 not in x and 5 in x and (sum(x) / N >= 4.0):
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	grades = list(map(int, input().split()))
	avg = sum(grades) / n
	if avg >= 4 and max(grades) == 5 and (min(grades) > 2):
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(1, t + 1):
	n = int(input())
	l = [int(x) for x in input().split()]
	if sum(l) / n >= 4.0 and l.count(2) == 0 and (l.count(5) >= 1):
		print('Yes')
	else:
		print('No')


test = int(input())
for i in range(test):
	number = int(input())
	List = list(map(int, input().split()))
	count = count5 = 0
	for i in List:
		if i == 2:
			count = count + 1
		if i == 5:
			count5 = count5 + 1
	if count != 0:
		print('No')
	else:
		avg = sum(List) / len(List)
		if avg >= 4.0 and count5 > 0:
			print('Yes')
		else:
			print('No')


for _ in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	avg = sum(b) / a
	if 2 in b or 5 not in b or avg < 4.0:
		print('No')
	else:
		print('Yes')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = a.count(1)
	y = a.count(2)
	z = a.count(5)
	w = sum(a) / n
	if x == 0 and y == 0 and (z >= 1) and (w >= 4.0):
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	ans = 'No'
	cond = False
	acc = 0
	for v in s:
		if v == 2:
			cond = False
			break
		if v == 5:
			cond = True
		acc += v
	if cond and acc / n >= 4.0:
		ans = 'Yes'
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if sum(l) / n < 4.0:
		print('No')
	elif 5 in l:
		for k in l:
			if k <= 2:
				print('No')
				break
		else:
			print('Yes')
	else:
		print('No')


v = int(input())
for i in range(v):
	sub = int(input())
	lis = [int(i) for i in input().split()]
	if 2 not in lis:
		if 5 in lis:
			if sum(lis) / sub >= 4:
				print('Yes')
			else:
				print('No')
		else:
			print('No')
	else:
		print('No')


try:
	for _ in range(int(input())):
		N = int(input())
		L = list(map(int, input().split()))
		if 2 in L or 5 not in L or sum(L) / N < 4.0:
			print('No')
		else:
			print('Yes')
except:
	pass


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a) / n
	c = 0
	x = 0
	for i in range(n):
		if a[i] <= 2:
			c += 1
		if a[i] == 5:
			x += 1
	if s < 4.0 or c > 0 or x == 0:
		print('No')
	else:
		print('Yes')


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	avg = sum(A) / n
	f = A.count(2)
	ex = A.count(5)
	if avg >= 4:
		if f < 1:
			if ex >= 1:
				print('Yes')
			else:
				print('No')
		else:
			print('No')
	else:
		print('No')


for i in range(int(input())):
	n = int(input())
	list1 = list(map(int, input().split()))
	fail = 0
	full = 0
	agg = 0
	for j in list1:
		if j == 2:
			fail = 1
			break
		agg += j
		if j == 5:
			full = 1
	if agg / n >= 4 and full == 1 and (fail == 0):
		print('Yes')
	else:
		print('No')


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	x = sum(l) / n
	if 2 in l:
		y = 'No'
	elif 5 not in l:
		y = 'No'
	elif x < 4:
		y = 'No'
	else:
		y = 'Yes'
	print(y)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = 'Yes'
	if 2 in a:
		ans = 'No'
	elif 5 not in a:
		ans = 'No'
	elif sum(a) / len(a) < 4:
		ans = 'No'
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	avg = sum(l) / n
	if 2 in l or 5 not in l or avg < 4.0:
		print('No')
	else:
		print('Yes')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	if l.count(2) > 0 or l.count(5) < 1:
		print('No')
	else:
		s = sum(l) / n
		if s < 4.0:
			print('No')
		else:
			print('Yes')


t = int(input())
for i in range(t):
	a = int(input())
	b = list(map(int, input().strip().split()))
	c = sum(b)
	if c / a < 4.0:
		print('No')
	elif 5 not in b:
		print('No')
	elif 2 in b:
		print('No')
	else:
		print('Yes')


def stip(N, arr):
	sm = 0
	flag = 0
	for i in arr:
		if i <= 2:
			return -1
		elif i == 5:
			flag = 1
		sm += i
	z = sm / len(arr)
	if flag == 1 and z >= 4.0:
		return 1
	else:
		return -1
t = int(input())
while t > 0:
	N = int(input())
	arr = list(map(int, input().split()))
	u = stip(N, arr)
	if u == -1:
		print('No')
	else:
		print('Yes')
	t -= 1


vishnesh = int(input())
for vish in range(vishnesh):
	n = int(input())
	arr = list(map(int, input().split()))
	l = 1
	if 5 not in arr:
		l = 0
	if sum(arr) < 4 * n:
		l = 0
	if 2 in arr:
		l = 0
	if l == 1:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	e = list(map(int, input().strip().split()))
	if sum(e) / n < 4.0:
		print('No')
	elif 5 not in e:
		print('No')
	elif 2 in e:
		print('No')
	else:
		print('Yes')


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	avg = sum(l) / n
	t = l.count(5)
	if 2 not in l and avg >= 4 and (t > 0):
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	n = int(input())
	m = list(map(int, input().split()))
	avg = sum(m) / n
	maxi = m.count(5)
	mini = min(m)
	if avg >= 4.0 and mini > 2 and (maxi > 0):
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	x = sum(l) / n
	if x < 4:
		print('No')
	elif l.count(2) == 0:
		if l.count(5) > 0:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	avg = sum(a) / n
	maxi = a.count(5)
	mini = min(a)
	if mini == 2 or maxi == 0:
		print('No')
	elif avg >= 4.0:
		if maxi > 0:
			if mini > 2:
				print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	flag = 0
	c = 0
	sum1 = sum(l)
	avg = sum1 / len(l)
	if 2 not in l:
		if 5 in l:
			if avg >= 4.0:
				print('Yes')
			else:
				print('No')
		else:
			print('No')
	else:
		print('No')


for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	if A.count(2) == 0 and sum(A) / N >= 4.0 and (A.count(5) >= 1):
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	N = int(input())
	l = list(map(int, input().split()))
	pass_ = True
	full_score = False
	gp = sum(l) / len(l)
	for x in l:
		if x == 2:
			pass_ = False
		if x == 5:
			full_score = True
	if pass_ == True and full_score == True and (gp >= 4.0):
		print('Yes')
	else:
		print('No')


t = int(input())
for k in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if 2 not in a:
		if 5 in a:
			if sum(a) / len(a) >= 4.0:
				print('Yes')
			else:
				print('No')
		else:
			print('No')
	else:
		print('No')


for tc in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	count_2 = 0
	count_5 = 0
	for i in b:
		if i == 2:
			count_2 += 1
		if i == 5:
			count_5 += 1
	avg_score = sum(b) / a
	if count_2 == 0 and count_5 >= 1 and (avg_score >= 4.0):
		print('Yes')
	else:
		print('No')


t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	count_2 = 0
	count_5 = 0
	for i in arr:
		if i == 2:
			count_2 += 1
		if i == 5:
			count_5 += 1
	avg_score = sum(arr) / n
	if count_2 == 0 and count_5 >= 1 and (avg_score >= 4.0):
		print('Yes')
	else:
		print('No')
	t = t - 1