Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken.

CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one — 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly this amount of chicken.

Formally, Ivan wants to know if he can choose two non-negative integers a and b in such a way that a small portions and b large ones contain exactly x chunks.

Help Ivan to answer this question for several values of x!


-----Input-----

The first line contains one integer n (1 ≤ n ≤ 100) — the number of testcases.

The i-th of the following n lines contains one integer x_{i} (1 ≤ x_{i} ≤ 100) — the number of chicken chunks Ivan wants to eat.


-----Output-----

Print n lines, in i-th line output YES if Ivan can buy exactly x_{i} chunks. Otherwise, print NO.


-----Example-----
Input
2
6
5

Output
YES
NO



-----Note-----

In the first example Ivan can buy two small portions.

In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much.

Difficulty: EASY
Tags: Implementation

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
n = int(input())
memo = {}

def check(n):
	if n == 0:
		return True
	if n in memo:
		return memo[n]
	ans = False
	if n >= 3:
		ans |= check(n - 3)
	if n >= 7:
		ans |= check(n - 7)
	memo[n] = ans
	return ans
for i in range(n):
	x = int(input())
	if check(x):
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	nn = int(input())
	a = 0
	for x in range(7, nn + 1, 7):
		if (nn - x) % 3 == 0:
			a = 1
	a = a or nn % 3 == 0
	print('YES' if a else 'NO')


n = int(input())
for i in range(n):
	x = int(input())
	k = x
	f = 0
	while x > 0:
		if x % 3 == 0 or x % 7 == 0:
			print('YES')
			f = 1
			break
		else:
			x -= 3
	x = k
	if f == 1:
		continue
	while x > 0:
		if x % 3 == 0 or x % 7 == 0:
			print('YES')
			f = 1
			break
		else:
			x -= 7
	if f == 1:
		continue
	print('NO')


for t in range(int(input())):
	chicken_chunks = int(input())
	flag = False
	while chicken_chunks > 0:
		if chicken_chunks % 3 == 0 or chicken_chunks % 7 == 0:
			flag = True
		chicken_chunks -= 3
	if flag:
		print('YES')
	else:
		print('NO')


seventhree = [i for i in range(7, 101, 3)]
threeseven = [i for i in range(3, 101, 7)]
sevennine = [i for i in range(9, 101, 7)]
seventwelve = [i for i in range(12, 101, 7)]
seventwelve = [i for i in range(14, 101, 3)]
n = int(input())
for i in range(n):
	x = int(input())
	if x % 3 == 0 or x % 7 == 0 or x in seventhree or (x % 10 == 0) or (x in threeseven) or (x in sevennine) or (x in seventwelve):
		print('YES')
	else:
		print('NO')


[print('YES') if j not in [1, 2, 4, 5, 8, 11] else print('NO') for j in [int(input()) for i in range(int(input()))]]


n = int(input())
while n:
	a = int(input())
	if a < 12:
		if a % 3 == 0 or a % 7 == 0 or a % 10 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')
	n -= 1


import sys
MOD = 1000000007
inp = sys.stdin.readline

def ii():
	return int(inp())

def iis():
	return [int(i) for i in inp().split()]

def solve(x):
	for A in range(50):
		for B in range(50):
			if 3 * A + 7 * B == x:
				return True
	return False
n = ii()
for _ in range(n):
	print('YES' if solve(ii()) else 'NO')


n = int(input())
for i in range(n):
	x = int(input())
	while x >= 7 and x % 3 != 0:
		x -= 7
	if x == 0 or not x % 3:
		print('YES')
	else:
		print('NO')


r = int(input())
for i in range(1, r + 1):
	m = int(input())
	if m == 1 or m == 2 or m == 4 or (m == 5) or (m == 8) or (m == 11):
		print('NO')
	else:
		print('YES')


b = int(input())
a = b * [0]
for i in range(0, b):
	h = int(input())
	a[i] = h
for k in range(0, b):
	l = 0
	if l == 0 and a[k] % 3 == 0 or (l == 0 and a[k] % 7 == 0):
		print('YES')
		l = l + 1
	if l == 0:
		q = 0
		for oi in range(0, a[k]):
			for po in range(0, a[k]):
				if oi * 3 + po * 7 == a[k]:
					q = 1
					break
			if q == 1:
				break
		if q == 1:
			print('YES')
	if l == 0 and q == 0:
		print('NO')


n = int(input())
a = []
p = []
for i in range(n):
	a.append(int(input()))
	if a[i] % 7 == 0 or a[i] % 3 == 0:
		p.append('YES')
		continue
	k7 = a[i] // 7
	k3 = a[i] % 7 // 3
	while k7 * 7 + k3 * 3 != a[i] and k7 >= 0:
		k7 -= 1
		if k7 > 0:
			k3 = (a[i] - k7 * 7) // 3
		else:
			k3 = a[i] // 3
	if k7 * 7 + k3 * 3 == a[i]:
		p.append('YES')
	else:
		p.append('NO')
for i in range(n):
	print(p[i])


def test(n):
	if n == 0:
		return True
	elif n < 0 or 1 < n < 3:
		return False
	else:
		return test(n - 3) or test(n - 7)
n = int(input())
for _ in range(n):
	print('YES' if test(int(input())) else 'NO')


def check(n):
	if n % 3 == 0 or n % 7 == 0 or n % 10 == 0:
		return True
	a = 3
	while a < n:
		b = n - a
		if a % 3 == 0 and b % 7 == 0:
			return True
		a += 3

def solve():
	n = int(input())
	for i in range(n):
		k = int(input())
		if check(k) == True:
			print('YES')
		else:
			print('NO')
solve()


n = int(input())
L = [int(input()) for k in range(n)]
for k in range(n):
	s = L[k]
	while True:
		if s < 0:
			L[k] = 'NO'
			break
		elif s % 7 == 0 or s % 3 == 0:
			L[k] = 'YES'
			break
		else:
			s -= 7
print('\n'.join(L))


n = int(input())
ex = [1, 2, 4, 5, 8, 11]
while n > 0:
	n -= 1
	a = int(input())
	flag = 1
	for i in ex:
		if a == i:
			flag = 0
	if flag == 0:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	n = int(input())
	list1 = [1 for i in range(n // 7 + 1) if (n - 7 * i) % 3 == 0]
	print('YNEOS'[1 not in list1::2])


for _ in range(int(input())):
	n = int(input())
	if n in [1, 2, 4, 5, 8, 11]:
		print('NO')
	else:
		print('YES')


n = int(input())
X = [int(input()) for _ in range(n)]
for x in X:
	a = 0
	while True:
		b = (x - 3 * a) / 7
		if b < 0:
			print('NO')
			break
		elif int(b) == b:
			print('YES')
			break
		a += 1


n = int(input())

def whole_chunks(num):
	x = int(num / 3)
	for i in range(0, x + 1):
		small = 3 * i
		if (num - small) % 7 == 0:
			return 'YES'
	return 'NO'
for test_case in range(n):
	print(whole_chunks(int(input())))


n = int(input())
for i in range(n):
	z = int(input())
	a = 0
	b = 0
	x = 0
	while x <= z:
		if x + 7 <= z:
			b += 1
		elif x + 3 <= z:
			a += 1
		elif ((x + 2 == z) | (x + 1 == z)) & (b > 0):
			a += 2
			b -= 1
		elif x == z:
			print('YES')
			break
		else:
			print('NO')
			break
		x = 3 * a + 7 * b


for _ in range(int(input())):
	i = int(input())
	if i > 11:
		print('YES')
	elif i % (7 + 3) == 0 or i % 3 == 0 or i % 7 == 0:
		print('YES')
	else:
		print('NO')


def is_can(x):
	if x % 3 == 0 or x % 7 == 0:
		return True
	out = 0
	while x > 0:
		x -= 3
		out += 1
		if x % 7 == 0:
			return True
	return False
n = int(input())
output = []
for i in range(n):
	if is_can(int(input())):
		output.append('YES')
	else:
		output.append('NO')
print('\n'.join(output))


n = int(input())
for i in range(n):
	q = int(input())
	t = 0
	for j in range(34):
		for k in range(34):
			if 3 * j + 7 * k == q:
				print('YES')
				t = 1
				break
		if t == 1:
			break
	if t == 0:
		print('NO')


z = int(input())
for y in range(z):
	x = int(input())
	small = 3
	big = 7
	t = False
	if x % small == 0 or x % big == 0:
		print('YES')
		t = True
	for i in range(1, 34):
		if t == True:
			break
		for c in range(1, 15):
			if t == True:
				break
			if i * small + c * big == x:
				print('YES')
				t = True
			elif i == 33 and c == 14:
				print('NO')


n = int(input())
for i in range(n):
	a = int(input())
	k = 0
	for i in range(35):
		flag = 'B'
		for j in range(16):
			if 3 * i + 7 * j == a:
				print('YES')
				flag = 'A'
				break
			else:
				k = k + 1
				continue
		if flag == 'A':
			break
	if k == 35 * 16:
		print('NO')


import sys, math, queue, bisect
MOD = 10 ** 9 + 7
sys.setrecursionlimit(1000000)
dp = [False for i in range(108)]
dp[0] = True
for i in range(101):
	if dp[i]:
		dp[i + 3] = dp[i + 7] = True
for _ in range(int(input())):
	if dp[int(input())]:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	m = int(input())
	print('YES' if any(((m - 3 * j) % 7 == 0 for j in range(m // 3 + 1))) else 'NO')


import sys

def f(n, x):
	ans = []
	for v in x:
		a = 'NO'
		if chunk(v):
			a = 'YES'
		ans.append(a)
	return ans

def chunk(v):
	c = False
	if v % 7 == 0:
		c = True
	elif v % 3 == 0:
		c = True
	else:
		max_n = int(v / 7)
		for i in range(max_n):
			res = v - 7 * (i + 1)
			if res % 3 == 0:
				c = True
				break
	return c
for line in sys.stdin:
	n = int(line)
	x = []
	for i in range(n):
		x.append(int(sys.stdin.readline()))
	ans = f(n, x)
	for s in ans:
		print(s)


def solve():
	n = int(input())
	for i in range(33):
		e = 0
		for j in range(33):
			if 3 * j + 7 * i == n:
				print('YES')
				e += 1
				break
		if e > 0:
			break
	else:
		print('NO')
for _ in range(int(input())):
	solve()


n = int(input())
x = []
for i in range(n):
	x.append(int(input()))
for i in range(n):
	check = 0
	if x[i] % 7 == 0:
		print('YES')
	else:
		while x[i] % 3 != 0:
			x[i] -= 7
			if x[i] <= 0:
				check = -1
				break
		if check == -1:
			print('NO')
		elif x[i] % 3 == 0:
			print('YES')


n = int(input())
l = [1, 2, 4, 5, 8, 11]
for i in range(n):
	x = int(input())
	if x in l:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	n = int(input())
	if n % 3 == 0:
		print('YES')
	elif n % 7 == 0:
		print('YES')
	else:
		k = 0
		while n - 7 > 0:
			n = n - 7
			if n % 3 == 0:
				k = 1
				break
		if k == 1:
			print('YES')
		else:
			print('NO')


n = int(input())
for i in range(n):
	a = int(input())
	if a % 3 == 0 or a % 7 == 0 or a % 10 == 0 or (a >= 12):
		print('YES')
	else:
		print('NO')


def find(n):
	if n < 0:
		return 0
	if n % 3 == 0:
		return 1
	if n % 7 == 0:
		return 1
	if find(n - 3) or find(n - 7):
		return 1
	return 0
for _ in range(int(input())):
	n = int(input())
	if find(n):
		print('YES')
	else:
		print('NO')


testCase = int(input())
for i in range(testCase):
	chunks = int(input())
	if chunks % 3 == 0 or chunks % 7 == 0:
		print('YES')
	elif chunks < 10 or chunks == 11:
		if chunks == 3 or chunks == 7:
			print('YES')
		else:
			print('NO')
	elif chunks % 7 % 3 == 0:
		print('YES')
	else:
		x = chunks % 7
		y = chunks % 3
		x1 = x + y
		y1 = abs(x - y)
		if x1 % 3 == 0 or y1 % 3 == 0:
			print('YES')
		else:
			print('NO')


def check(x):
	global memo
	if x in memo:
		return memo[x]
	if x == 0:
		return True
	elif x < 0:
		return False
	ret = check(x - 3) | check(x - 7)
	memo[x] = ret
	return ret
n = int(input())
xs = []
for _ in range(n):
	x = int(input())
	xs.append(x)
memo = {}
for x in xs:
	if check(x):
		print('YES')
	else:
		print('NO')


def func(a):
	count = 0
	if a % 3 == 0:
		return 'YES'
	elif a % 7 == 0:
		return 'YES'
	elif a > 11:
		return 'YES'
	elif a > 7:
		count += a // 7
		a = a - 7 * count
		if a % 3 == 0:
			return 'YES'
		else:
			return 'NO'
	else:
		return 'NO'
_list = []
t = int(input())
for i in range(t):
	a = input()
	_list.append(func(int(a)))
for i in _list:
	print(i)


n = int(input())
for i in range(n):
	k = int(input())
	if k == 11 or k == 1 or k == 2 or (k == 4) or (k == 5) or (k == 8):
		print('NO')
	else:
		print('YES')


def main():
	n = int(input())
	poss = False
	for i in range(100):
		if 3 * i > n:
			break
		if (n - 3 * i) % 7 == 0:
			poss = True
			break
	print('YES' if poss else 'NO')
T = int(input())
for _ in range(T):
	main()


x = int(input())
for i in range(x):
	ans = 'NO'
	a = int(input())
	for i in range(0, a + 1, 3):
		ans = 'NO'
		if i == a:
			ans = 'YES'
			break
		elif (a - i) % 7 == 0:
			ans = 'YES'
			break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	if n % 7 == 0 or n % 3 == 0:
		print('YES')
		continue
	x = n % 7
	if x % 3 == 0:
		print('YES')
		continue
	s = set()
	m = 1
	while 3 * m < 99:
		e = 1
		while 3 * m + 3 * e < 100:
			s.add(3 * m + 7 * e)
			e = e + 1
		m = m + 1
	if n in s:
		print('YES')
		continue
	print('NO')


n = int(input())
while n:
	n -= 1
	x = int(input())
	while x:
		if x == 7 or x == 3:
			print('YES')
			break
		if x % 3 == 0:
			x -= 3
		elif x > 6:
			x -= 7
		elif x > 2:
			x -= 3
		else:
			print('NO')
			break


n = int(input())
for i in range(1, n + 1):
	temp = int(input())
	if temp % 3 == 0 or temp % 7 == 0:
		print('YES')
	else:
		flag = 0
		for j in range(1, 15):
			for k in range(1, 34):
				if j * 7 + k * 3 == temp:
					flag = 1
					print('YES')
					break
				else:
					continue
			if flag == 1:
				break
		if flag == 0:
			print('NO')


from sys import stdin
_ = int(stdin.readline())
for line in stdin.readlines():
	n = int(line)
	found = False
	a = 0
	while a * 7 <= n:
		if (n - a * 7) % 3 == 0:
			found = True
			break
		a += 1
	print('YES' if found else 'NO')


t = int(input())
for i in range(t):
	n = int(input())
	if n % 3 == 0:
		print('YES')
	elif n % 3 == 1:
		if n // 3 >= 2:
			print('YES')
		else:
			print('NO')
	elif n % 7 == 0:
		print('YES')
	elif n >= 17 and ((n - 17) % 21 == 0 or (n - 20) % 21 == 0 or (n - 23) % 21 == 0 or ((n - 26) % 21 == 0) or ((n - 29) % 21 == 0) or ((n - 32) % 21 == 0)):
		print('YES')
	else:
		print('NO')


N = int(input())
while N:
	A = int(input())
	FLAG = 0
	L = [1, 2, 4, 5, 8, 11]
	for i in L:
		if i == A:
			print('NO')
			FLAG = 1
			break
	if FLAG == 0:
		print('YES')
	N -= 1


n = int(input())
for i in range(n):
	x = int(input())
	if x <= 6:
		if x % 3 == 0:
			print('YES')
		else:
			print('NO')
	elif x <= 14:
		if x % 3 == 0 or x % 3 == 1 or x % 7 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


x77 = '3625140'
n = int(input())
ansi = [0] * n
i = 0
while n > i:
	x = int(input())
	x3 = x % 3
	x7 = x % 7
	x2 = x
	x2 -= x3 * 7
	x -= x77.find(str(x7)) * 3
	if x2 % 3 == 0 and x2 >= 0 or (x % 7 == 0 and x >= 0):
		ansi[i] = 1
	else:
		ansi[i] = 0
	i += 1
for i in range(n):
	if ansi[i] == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
for test in range(n):
	x = int(input())
	if x == 1 or x == 2 or x == 4 or (x == 5) or (x == 8) or (x == 11):
		print('NO')
	else:
		print('YES')


n = int(input())

def d(n):
	a = 0
	for i in range(1, n // 3 + 1):
		for j in range(1, n // 7 + 1):
			if 3 * i + 7 * j == n:
				a += 1
	print('YES') if a >= 1 else print('NO')
for i in range(n):
	x = int(input())
	if x % 7 == 0:
		print('YES')
	elif x % 3 == 0:
		print('YES')
	else:
		d(x)


A = [1, 2, 4, 5, 8, 11]
t = int(input())
for i in range(t):
	if int(input()) in A:
		print('NO')
	else:
		print('YES')


def c(n):
	while n > 1:
		if n % 7 == 0:
			n = n // 7
			print('YES')
			return
		elif n % 3 == 0:
			n = n // 3
			print('YES')
			return
		else:
			if n == 1:
				print('NO')
				return
			if n > 3:
				n = n - 3
			else:
				print('NO')
				return
	if n == 1:
		print('NO')
		return
	print(n)
for i in range(int(input())):
	n = int(input())
	c(n)


n = int(input())
l = []
for k in range(n):
	p = int(input())
	for i in range(p):
		for j in range(p):
			if p == 7 * i + 3 * j:
				l.append(k)
				break
for i in range(n):
	if i in l:
		print('YES')
	else:
		print('NO')


MAX = 100
c = [True] + MAX * [False]
for i in range(MAX + 1):
	if c[i]:
		if i + 3 <= MAX:
			c[i + 3] = True
		if i + 7 <= MAX:
			c[i + 7] = True
for i in range(int(input())):
	print('YES' if c[int(input())] else 'NO')


t = int(input())
for i in range(t):
	x = int(input())
	bool = False
	while x >= 3:
		if x % 3 == 0 or x % 7 == 0:
			print('YES')
			bool = True
			break
		else:
			x -= 7
	if not bool:
		print('NO')


import math
import collections

def solve(x):
	for i in range(34):
		for j in range(15):
			if 3 * i + 7 * j == x:
				return 'YES'
	return 'NO'
n = int(input())
for n in range(n):
	x = int(input())
	result = solve(x)
	print(result)


def solve():
	n = get(int)
	ans = collections.defaultdict(lambda : False)
	for a in range(100):
		for b in range(100):
			ans[3 * a + 7 * b] = True
	ret = []
	for _ in range(n):
		x = get(int)
		if ans[x]:
			ret.append('YES')
		else:
			ret.append('NO')
	return '\n'.join(ret)
_testcases = '\n2\n6\n5\n\nYES\nNO\n'.strip()
from bisect import bisect_left, bisect_right
from functools import lru_cache
from heapq import heapify, heappop, heappush
from operator import itemgetter, attrgetter
import bisect
import collections
import functools
import heapq
import itertools
import math
import operator
import re
import string
import sys
inf = float('inf')
cache = lru_cache(None)
sys.setrecursionlimit(10000)

def tree():
	return collections.defaultdict(tree)

def equal(x, y, epsilon=1e-06):
	if -epsilon <= x - y <= epsilon:
		return True
	if -epsilon <= x <= epsilon or -epsilon <= y <= epsilon:
		return False
	return -epsilon <= (x - y) / x <= epsilon or -epsilon <= (x - y) / y <= epsilon

def get(_type):
	if type(_type) == list:
		if len(_type) == 1:
			_type = _type[0]
			return list(map(_type, input().strip().split()))
		else:
			return [_type[i](inp) for (i, inp) in enumerate(input().strip().split())]
	else:
		return _type(input().strip())
printRecursionTree = timeit = lambda x: x
(_p, print) = (print, lambda *a, **b: None)
_p(solve())


n = int(input())
for i in range(n):
	x = int(input())
	f = True
	for j in range(34):
		for k in range(34):
			if j * 3 + k * 7 == x:
				f = False
	if f:
		print('NO')
	else:
		print('YES')


n = int(input())

def rec(s):
	if s == 0:
		return True
	elif s < 0:
		return False
	return rec(s - 7) or rec(s - 3)
res = []
for i in range(n):
	res.append(rec(int(input().split()[0])))
for x in res:
	if x:
		print('YES')
	else:
		print('NO')


import sys
import math
import collections
input = sys.stdin.readline
t = int(input())
for w in range(t):
	n = int(input())
	if n >= 12 or n == 3 or n == 6 or (n == 7) or (n == 10) or (n == 9):
		print('YES')
	else:
		print('NO')


def lk(n):
	for i in range(105):
		for j in range(105):
			if 3 * i + 7 * j == n:
				return 1
	return 0
t = int(input())
for k in range(t):
	n = int(input())
	if lk(n):
		print('YES')
	else:
		print('NO')


n = int(input())
tasks = []
for i in range(n):
	tasks.append(int(input()))
for i in tasks:
	ch = 'NO'
	m = i // 7
	for j in range(m + 1):
		if (i - j * 7) % 3 == 0:
			ch = 'YES'
			break
	print(ch)


i = input
for _ in [0] * int(i()):
	x = int(i())
	print('YNEOS'[all((x != 3 * a + 7 * b for a in range(50) for b in range(50)))::2])


n = int(input())
for i in range(n):
	x = int(input())
	if x < 7 and x % 3 != 0:
		print('NO')
	elif x == 11 or x == 8:
		print('NO')
	else:
		print('YES')


i = input
exec(int(i()) * "x=int(i());print('YNEOS'[x in[1,2,4,5,8,11]::2]);")


strings = int(input())
arr = []
for i in range(strings):
	arr.append(int(input()))
for j in arr:
	flag = False
	for a in range(100):
		for b in range(100):
			if a * 3 + b * 7 == j:
				flag = True
	if not flag:
		print('NO')
	else:
		print('YES')


t = int(input())
for tc in range(t):
	n = int(input())
	an = 0
	bn = n
	ans = 'NO'
	while an <= n:
		if an % 3 == 0 and bn % 7 == 0 or (an % 7 == 0 and bn % 3 == 0):
			ans = 'YES'
			break
		an += 1
		bn -= 1
	print(ans)


dp = [0] * 110
dp[3] = 1
dp[7] = 1
for i in range(3, 110):
	if dp[i - 3] == 1:
		dp[i] = 1
	if i >= 7:
		if dp[i - 7] == 1:
			dp[i] = 1
for i in range(int(input())):
	print('YES' if dp[int(input())] else 'NO')


n = int(input())
for _ in range(n):
	x = int(input())
	ok = False
	for a in range(0, 34):
		for b in range(0, 15):
			if 3 * a + 7 * b == x:
				print('YES')
				ok = True
				break
		if ok:
			break
	if not ok:
		print('NO')


class CodeforcesTask903ASolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.tests = []

	def read_input(self):
		self.n = int(input())
		for x in range(self.n):
			self.tests.append(int(input()))

	def process_task(self):
		results = []
		for x in range(self.n):
			can_be = False
			for a in range(33):
				for b in range(14):
					if 3 * a + 7 * b == self.tests[x]:
						can_be = True
						break
			if can_be:
				results.append('YES')
			else:
				results.append('NO')
		self.result = '\n'.join(results)

	def get_result(self):
		return self.result
Solution = CodeforcesTask903ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


def lInt(d=None):
	return map(int, input().split(d))
(n, *_) = lInt()
for i in range(n):
	(x, *_) = lInt()
	try:
		for b in range(20):
			a = x - 7 * b
			if a >= 0 and a % 3 == 0:
				raise
	except:
		print('YES')
	else:
		print('NO')


ans = []

def solve(n):
	global ans
	small = 3
	large = 7
	result = '0'
	if n == 0 or n == 1 or n == 2 or (n == 4) or (n == 5) or (n == 8) or (n == 11):
		result = 'NO'
	else:
		result = 'YES'
	ans.append(result)

def main():
	global ans
	t = int(input())
	for _ in range(t):
		n = int(input())
		solve(n)
	for i in ans:
		print(i)
main()


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
n = int(input())
for i in range(n):
	x = int(input())
	ans = 0
	if x % 7 == 0:
		ans = 1
	if x % 3 == 0:
		ans = 1
	for j in range(x + 1):
		y = 3 * j
		newX = x - y
		if newX >= 0:
			if newX % 7 == 0:
				ans = 1
	if ans == 0:
		print('NO')
	else:
		print('YES')


n = int(input())
for i in range(n):
	x = int(input())
	yes = False
	for a in range(x // 3 + 2):
		if (x - a * 3) % 7 == 0:
			print('YES')
			yes = True
			break
	if not yes:
		print('NO')


t = int(input())
while t:
	t -= 1
	n = int(input())
	while n >= 0:
		if not n % 7:
			break
		n -= 3
	if n < 0:
		print('NO')
	else:
		print('YES')


results = {}

def solve(n):
	if n not in results:
		if n < 0:
			results[n] = False
		elif n == 0:
			results[n] = True
		else:
			results[n] = solve(n - 3) or solve(n - 7)
	return results[n]
for a in range(int(input())):
	if solve(int(input())):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	r = 0
	if n % 3 == 0:
		print('YES')
	elif n % 7 == 0:
		print('YES')
	else:
		for i in range(1, n):
			for j in range(1, n):
				if 3 * i + 7 * j == n:
					print('YES')
					r = 1
					break
			if r == 1:
				break
		if r == 0:
			print('NO')


t = int(input())
for i in range(0, t):
	flag = 0
	x = int(input())
	b = 0
	temp = x
	while temp >= 0:
		if temp % 3 == 0:
			flag = 1
			break
		b = b + 1
		temp = x - 7 * b
	if flag == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	x = int(input())
	cnt = 0
	for a in range(x + 1):
		for b in range(x + 1):
			if 3 * a + 7 * b == x:
				cnt = 1
				break
		if cnt == 1:
			break
	if cnt == 1:
		print('YES')
	else:
		print('NO')
	t = t - 1


n = int(input())
list = []
for i in range(n):
	list.append(eval(input()))
for i in list:
	if i % 3 == 0 or i % 7 == 0:
		print('YES')
	else:
		N = i // 7
		c = True
		for j in range(0, N + 1):
			if (i - 7 * j) % 3 == 0:
				print('YES')
				c = False
				break
		if c:
			print('NO')


myset = set()
for i in range(100):
	for j in range(100):
		r = 3 * i + j * 7
		if r >= 1 and r <= 100:
			myset.add(r)
n = int(input())
for _ in range(n):
	x = int(input())
	if x in myset:
		print('YES')
	else:
		print('NO')


import sys
n = sys.stdin.readline()
while n:
	for i in range(int(n)):
		flag = 'NO'
		x = int(sys.stdin.readline())
		for b in range(int(x / 7) + 1):
			if ((x - 7 * b) / 3).is_integer():
				flag = 'YES'
				break
		print(flag)
	n = sys.stdin.readline()


n = int(input(''))
test = []
resp = []
for i in range(n):
	test.append(int(input('')))
for j in range(len(test)):
	resta = test[j]
	cad = ''
	while resta >= 0:
		if resta % 3 == 0:
			cad = 'YES'
			break
		elif resta % 7 == 0:
			cad = 'YES'
			break
		else:
			resta -= 3
	if resta < 0:
		cad = 'NO'
	resp.append(cad)
for k in range(len(resp)):
	print(resp[k])


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
for _ in range(get_int()):
	n = get_int()
	flag = True
	i = 0
	while 7 * i <= n:
		if (n - 7 * i) % 3 == 0:
			print('YES')
			flag = False
			break
		i += 1
	if flag:
		print('NO')


n = int(input())
for _ in range(n):
	x = int(input())
	found = False
	a = 0
	while a * 7 <= x:
		if (x - a * 7) % 3 == 0:
			found = True
			break
		a += 1
	if found:
		print('YES')
	else:
		print('NO')


import sys

def main():
	n = int(sys.stdin.readline().strip())
	for i in range(n):
		x = int(sys.stdin.readline().strip())
		if x not in [1, 2, 4, 5, 8, 11]:
			print('YES')
		else:
			print('NO')
main()


import sys
n = sys.stdin.readline()
n = int(n)
for a in range(n):
	x = sys.stdin.readline()
	x = int(x)
	aux = 0
	bandera = True
	for i in range(-1, x // 3):
		if not bandera:
			break
		for j in range(-1, x // 7):
			if not bandera:
				break
			if 3 * (i + 1) + 7 * (j + 1) == x:
				print('YES')
				bandera = False
	if bandera:
		print('NO')


a = int(input())
b = list()
for c in range(a):
	b.append(int(input()))
for c in range(a):
	if b[c] <= 14:
		if b[c] - 3 >= 0 and b[c] - 3 % 7 == 0 or b[c] == 0 or b[c] == 7 or (b[c] == 9) or (b[c] == 14) or (b[c] == 10) or (b[c] == 12) or (b[c] == 13) or (b[c] - 6 >= 0 and (b[c] - 6) % 7 == 0):
			print('YES')
		else:
			print('NO')
	elif (b[c] - 7) % 3 == 0 or b[c] % 3 == 0 or (b[c] - 14) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	x = int(input())
	s = 3
	l = 7
	if x % s == 0:
		print('YES')
	elif x % l == 0:
		print('YES')
	elif x % s != 0 and x % l != 0:
		while x > 0:
			x = x - s
			if x % s == 0:
				print('YES')
				break
			if x < 0:
				print('NO')
				break
			x = x - l
			if x % l == 0:
				print('YES')
				break
			if x < 0:
				print('NO')
				break
	t = t - 1


import bisect

def list_output(s):
	print(' '.join(map(str, s)))

def list_input(s='int'):
	if s == 'int':
		return list(map(int, input().split()))
	elif s == 'float':
		return list(map(float, input().split()))
	return list(map(str, input().split()))
n = int(input())
for _ in range(n):
	x = int(input())
	ok = False
	for a in range(34):
		for b in range(15):
			if 3 * a + 7 * b == x:
				ok = True
				break
		if ok:
			break
	if ok:
		print('YES')
	else:
		print('NO')


cnt = 1
p = 0
r = []

def init(a):
	for p in range(len(a)):
		a[p] = int(a[p])
	return a
t = int(input())
for i in range(t):
	d = int(input())
	p = 0
	while d - 7 * p >= 0:
		if (d - 7 * p) % 3 == 0:
			r.append('YES')
			break
		p = p + 1
	if d - 7 * p < 0:
		r.append('NO')
for j in range(t):
	print(r[j])


t = int(input())
for i in range(t):
	f = 0
	x = int(input())
	if x % 3 == 0 or x % 7 == 0:
		f = 1
	for p in range(1, x):
		for q in range(1, x):
			if p * 3 + q * 7 == x:
				f = 1
				break
	if f == 1:
		print('YES')
	else:
		print('NO')


t = eval(input())
n = []
i = 0
while i < t:
	c = eval(input())
	n = n + [c]
	i = i + 1
i = 0
while i < t:
	while n[i] > 0:
		if n[i] % 3 == 0 or n[i] % 7 == 0:
			print('YES')
			break
		n[i] = n[i] - 7
	if n[i] <= 0:
		print('NO')
	i = i + 1


n = int(input())
xs = []
for i in range(100):
	for j in range(100):
		if i + j + 2 <= 100:
			xs.append(j * 3 + i * 7)
for i in range(n):
	k = int(input())
	if k in xs:
		print('YES')
	else:
		print('NO')


import sys
n = int(input())
for i in range(0, n):
	x = int(input())
	j = 0
	found = False
	while j <= x / 7 and (not found):
		if (x - 7 * j) % 3 == 0:
			found = True
		else:
			j += 1
	if found:
		print('YES')
	else:
		print('NO')


n = int(input())
l = n * [0]
for i in range(n):
	l[i] = int(input())
for i in range(n):
	f = 'NO'
	for j in range(34):
		for k in range(34):
			if 3 * j + 7 * k > l[i]:
				break
			if 3 * j + 7 * k == l[i]:
				f = 'YES'
				break
	print(f)


def a():
	g = int(input())
	for i in range(36):
		for j in range(17):
			if 3 * i + 7 * j == g:
				return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	print(a())


dp = [0 for i in range(101)]
dp[0] = 1
for i in range(len(dp)):
	if i >= 3 and dp[i - 3] == 1:
		dp[i] = 1
	if i >= 7 and dp[i - 7] == 1:
		dp[i] = 1
n = list(map(int, input('').strip().split()))[0]
for i in range(n):
	a = list(map(int, input('').strip().split()))[0]
	if dp[a] == 1:
		print('YES')
	else:
		print('NO')


l = [1, 2, 4, 5, 8, 11]
for u in range(int(input())):
	if int(input()) in l:
		print('NO')
	else:
		print('YES')


n = int(input())
b = []
for i in range(35):
	for j in range(14):
		b.append(i * 3 + j * 7)
for i in range(n):
	a = int(input())
	if a in b:
		print('YES')
	else:
		print('NO')


x = int(input())
lista = []
for i in range(x):
	a = int(input())
	lista.append(a)
for i in range(len(lista)):
	if lista[i] >= 12 or lista[i] == 3 or lista[i] == 6 or (lista[i] == 7) or (lista[i] == 9) or (lista[i] == 10):
		print('YES')
	else:
		print('NO')


val = []
res = []
n = 0

def entrada_datos():
	global n
	n = int(input())

def respuesta():
	global val
	global res
	aux = ''
	for i in range(n):
		val.append(int(input()))
	for x in range(len(val)):
		resta = val[x]
		aux = ''
		while resta >= 0:
			if resta % 3 == 0:
				aux = 'YES'
				break
			elif resta % 7 == 0:
				aux = 'YES'
				break
			else:
				resta -= 3
			if resta < 0:
				aux = 'NO'
		res.append(aux)
	for x in range(len(res)):
		print(res[x])
entrada_datos()
respuesta()


def run():
	cant = int(input(''))
	numero = 0
	respuesta = []
	for i in range(cant):
		numero = int(input(''))
		while numero > 0:
			if numero % 3 == 0 or numero % 7 == 0:
				respuesta.append('YES')
				break
			else:
				numero = numero - 3
		if numero < 0:
			respuesta.append('NO')
	for j in range(len(respuesta)):
		print(respuesta[j])
run()


n = int(input())
for i in range(n):
	a = int(input())
	if a % 3 == 0:
		print('YES')
	else:
		b = a % 3
		if a - b * 7 >= 0:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	n = int(input())
	while n > 0:
		if n % 3 == 0 or n % 7 == 0:
			print('YES')
			break
		elif n % 3 != 0 or n % 7 != 0:
			if n % 2 == 0:
				n -= 3
			else:
				n -= 7
		if n < 3:
			print('NO')
			break


n = int(input())
for i in range(n):
	x = int(input())
	possible = False
	for s in range(x // 3 + 2):
		for l in range(x // 7 + 2):
			if s * 3 + l * 7 == x:
				possible = True
	print('YES' if possible else 'NO')


n = int(input())
for __ in range(n):
	x = int(input())
	for i in range(x):
		if x - 3 * i >= 0 and (x - 3 * i) % 7 == 0:
			print('YES')
			break
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	f = 0
	for i in range(33):
		for j in range(33):
			if i * 3 + 7 * j == n:
				f = 1
	print(['NO', 'YES'][f])


def main():
	d = int(input())
	data = [int(input()) for v in range(d)]
	res = [0 for _ in range(110)]
	res[0] = 1
	for i in range(0, 101):
		if res[i] != 0:
			res[i + 3] = 1
			res[i + 7] = 1
	for dd in data:
		if res[dd] != 0:
			print('YES')
		else:
			print('NO')
main()


a = int(input())
c = []
for i in range(a):
	b = int(input())
	if b != 2 and b != 1 and (b != 4) and (b != 5) and (b != 11) and (b != 8):
		print('YES')
	else:
		print('NO')


import sys
v = map(int, sys.stdin.readlines()[1:])
for x in v:
	ch = False
	for i in range(15):
		for j in range(33):
			if i * 7 + j * 3 == x:
				ch = True
				break
		if ch:
			break
	print('YES' if ch else 'NO')


testcase = int(input())
while testcase > 0:
	chickenChunk = int(input())
	flag = 0
	if chickenChunk % 3 == 0:
		print('YES')
	else:
		remainder = chickenChunk % 3
		for i in range(1, chickenChunk // 3 + 1):
			if (remainder + i * 3) % 7 == 0:
				print('YES')
				flag = 1
				break
		if flag == 0:
			print('NO')
	testcase -= 1


N = input()
n = int(N)
for i in range(n):
	WANT = input()
	want = int(WANT)
	b = False
	while want > 0:
		if want % 3 == 0:
			b = True
			break
		elif want % 7 == 0:
			b = True
			break
		else:
			want -= 3
	if b:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	c = int(input())
	if c < 3 or c == 4 or c == 5 or (c == 8) or (c == 11):
		print('NO')
	else:
		print('YES')


import itertools
for i in range(int(input())):
	print('YES' if [sum(i) for i in itertools.product(range(0, 100, 3), range(0, 100, 7))].count(int(input())) else 'NO')


n = int(input())
r = list()
for i in range(n):
	x = int(input())
	flag = False
	for j in range(0, x + 1, 7):
		if (x - j) % 3 == 0:
			flag = True
			break
	r.append('YES' if flag else 'NO')
print('\n'.join(r))


n = int(input())
a = [False] * 101
i = 0
while i < 101:
	a[i] = True
	j = i
	while j < 101:
		a[j] = True
		j += 7
	i += 3
for i in range(n):
	q = int(input())
	if a[q]:
		print('YES')
	else:
		print('NO')


def canChange(coinList, totalCoin):
	result = [[0 for i in range(totalCoin + 1)] for j in range(len(coinList) + 1)]
	for j in range(totalCoin + 1):
		result[0][j] = float('inf')
	for i in range(1, len(coinList) + 1):
		for j in range(1, totalCoin + 1):
			if j >= coinList[i - 1]:
				result[i][j] = min(result[i - 1][j], result[i][j - coinList[i - 1]] + 1)
			else:
				result[i][j] = result[i - 1][j]
	return result[i][j]
n = int(input())
coinList = [3, 7]
for i in range(n):
	totalCoin = int(input())
	if canChange(coinList, totalCoin) != float('inf'):
		print('YES')
	else:
		print('NO')


n = int(input())
for _ in range(n):
	m = int(input())
	while m >= 0 and m % 3 != 0:
		m -= 7
	if m >= 0:
		print('YES')
	else:
		print('NO')


tc = int(input().strip())
for _ in range(tc):
	x = int(input().strip())
	found = False
	for a in range(x):
		for b in range(x):
			if 3 * a + 7 * b == x:
				found = True
				break
		if found:
			break
	print('YES' if found else 'NO')


n = int(input())
dp = [0] * 108
dp[0] = 1
for i in range(101):
	if dp[i] == 1:
		dp[i + 3] = 1
		dp[i + 7] = 1
for i in range(n):
	inpt = int(input())
	if dp[inpt]:
		print('YES')
	else:
		print('NO')


n = int(input())
L = []
for i in range(n):
	x = int(input())
	L.append(x)
for num in L:
	a = 0
	Flag = True
	while num - 3 * a >= 0:
		if (num - 3 * a) % 7 == 0:
			print('YES')
			Flag = False
			break
		a += 1
	if Flag == True:
		print('NO')


for i in range(int(input())):
	x = int(input())
	while x > 0:
		if x % 3 != 0:
			x -= 7
		else:
			x = 0
			break
	if x == 0:
		print('YES')
	else:
		print('NO')


def get_data2():
	n = int(input().strip())
	data = [n]
	for i in range(n):
		data.append(int(input().strip()))
	return data

def test3():
	data = get_data2()
	for a in data[1:]:
		b = 'NO'
		for i in range(a // 3 + 1):
			for j in range(a // 7 + 1):
				if 3 * i + 7 * j == a:
					b = 'YES'
			if b == 'YES':
				break
		print(b)
test3()


n = int(input())
cnt = 0
for i in range(n):
	x = int(input())
	k = x // 3
	z = x // 7
	for j in range(k + 1):
		for f in range(z + 1):
			if j * 3 + f * 7 == x:
				print('YES')
				cnt += 1
				break
		if cnt > 0:
			break
	if cnt == 0:
		print('NO')
	cnt = 0


n = int(input())
for i in range(n):
	x = int(input())
	if x > 11 or x % 3 == 0 or x == 7 or (x == 10):
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = int(input())
	b = a % 7
	c = a // 7
	x = b - 7
	if b == 0:
		print('YES')
	else:
		for k in range(c + 1):
			x += 7
			if x % 3 == 0:
				print('YES')
				break
		else:
			print('NO')


n = int(input())
for i in range(0, n):
	bol = 0
	x = int(input())
	for j in range(0, 101):
		z = x - j * 3
		if z % 7 == 0 and z >= 0:
			bol = 1
	if bol == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
for t in range(n):
	k = int(input())
	if k % 7 % 3 == 0:
		print('YES')
	elif k % 7 % 3 == 1:
		if k // 7 >= 2:
			print('YES')
		else:
			print('NO')
	elif k % 7 % 3 == 2:
		if k // 7 >= 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def fun(n):
	lim = n // 3
	lim = int(lim)
	for i in range(0, lim + 1):
		if (n - 3 * i) % 7 == 0:
			return True
	return False
n = input()
n = int(n)
for i in range(0, n):
	tmp = input()
	tmp = int(tmp)
	if fun(tmp):
		print('YES')
	else:
		print('NO')


n = int(input())
m = []
for i in range(n):
	x = int(input())
	a = 0
	k = 0
	while 7 * a <= x:
		if (x - 7 * a) % 3 == 0:
			m.append('YES')
			break
		a += 1
	else:
		m.append('NO')
for i in m:
	print(i)


n = int(input())
a = []
for i in range(n):
	x = int(input())
	r = x % 3
	a.append('YES')
	if r != 0 and r * 7 > x:
		a[i] = 'NO'
for i in range(n):
	print(a[i])


T = int(input())
for t in range(T):
	n = int(input())
	ans = 'n'
	if n % 3 == 0 or n % 7 == 0:
		print('YES')
	else:
		for i in range(50):
			for j in range(50):
				if n == 3 * i + 7 * j:
					print('YES')
					ans = 'y'
					break
			if ans == 'y':
				break
		if ans != 'y':
			print('NO')


def cfk(numb):
	if numb >= 12:
		print('YES')
		return 0
	if numb == 1 or numb == 2 or numb == 4 or (numb == 5) or (numb == 8):
		print('NO')
		return 0
	if numb == 11:
		print('NO')
		return 0
	print('YES')
n = int(input())
pcs = []
for i in range(n):
	temp = int(input())
	pcs.append(temp)
for i in range(n):
	cfk(pcs[i])


def hungry_student(lst):
	(a, b) = (list(), list())
	for i in range(0, 101, 7):
		for j in range(i, 101, 3):
			if j not in a:
				a.append(j)
	for elem in lst:
		if elem in sorted(a):
			b.append('YES')
		else:
			b.append('NO')
	return b
n = int(input())
c = list()
for y in range(n):
	w = int(input())
	c.append(w)
print(*hungry_student(c), sep='\n')


n = int(input())
aa = []
for i in range(n):
	aa.append(int(input()))
for a in aa:
	flag = True
	for t in range(35):
		if (a - t * 3) % 7 == 0 and a - t * 3 >= 0:
			print('YES')
			flag = False
			break
	if flag:
		print('NO')


n = int(input())
for testcase in range(n):
	flag = 0
	a = int(input())
	if a % 3 == 0:
		print('YES')
	elif a % 7 == 0:
		print('YES')
	else:
		for i in range(1, a // 7 + 1):
			r = a - 7 * i
			if r % 3 == 0:
				flag = 1
				break
		if flag == 0:
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	print(('YES', 'NO')[int(input()) in {1, 2, 4, 5, 8, 11}])


t = int(input())
for i in range(t):
	s = 3
	b = 7
	t = int(input())
	if t > 11:
		print('YES')
	elif t % s == 0 or t % b == 0:
		print('YES')
	elif t % b % s == 0:
		print('YES')
	else:
		print('NO')


R = lambda : map(int, input().split())
n = int(input())
ans = [False] * 101
(ans[3], ans[6], ans[7]) = (True, True, True)
for i in range(8, 101):
	ans[i] = ans[i - 7] or ans[i - 3]
for i in range(n):
	inp = int(input())
	if ans[inp]:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	x = int(input())
	if x >= 12 or x == 3 or x == 6 or (x == 7) or (x == 9) or (x == 10):
		print('YES')
	else:
		print('NO')


def check(x):
	for a in range(0, x // 3 + 1):
		if (x - a * 3) % 7 == 0:
			return 'YES'
	return 'NO'
for i in range(int(input())):
	print(check(int(input())))


n = int(input())
chickens = []
for i in range(n):
	chickens.append(int(input()))
for i in range(n):
	if chickens[i] % 3 == 0 or chickens[i] % 7 == 0:
		print('YES')
	else:
		chicken = chickens[i] - 7
		result = 'NO'
		while chicken > 0:
			if chicken % 3 == 0:
				result = 'YES'
				break
			chicken -= 7
		print(result)


n = int(input())
for _ in range(n):
	x = int(input())
	solved = False
	for i in range(0, (x + 5) // 3):
		if (x - i * 3) % 7 == 0:
			solved = True
	if solved:
		print('YES')
	else:
		print('NO')


n = int(input())
res = []
i = 0
for x in range(n):
	res.append('NO')
	a = int(input())
	for y in range(34):
		for z in range(34):
			if y * 7 + z * 3 == a:
				res[x] = 'YES'
				break
for x in res:
	print(x)


ans = set()
for i in range(35):
	for j in range(100 // 7 + 1):
		ans.add(3 * i + j * 7)
for _ in range(int(input())):
	n = int(input())
	print('YES' if n in ans else 'NO')


n = int(input())
for _ in range(n):
	x = int(input())
	if x % 3 == 0 or x % 7 == 0:
		print('YES')
	else:
		flag = False
		for a in range(1, 34):
			for b in range(1, 15):
				if 3 * a + 7 * b == x:
					flag = True
					break
		print('YES' if flag else 'NO')


n = int(input())
l = []
while n > 0:
	l.append(int(input()))
	n -= 1
for i in l:
	for j in range(100):
		x = (i - 7 * j) / 3
		if x < 0:
			print('NO')
			break
		if x.is_integer():
			print('YES')
			break


n = input()
n = int(n)
for i in range(0, n, 1):
	x = input()
	x = int(x)
	while x > 0:
		if (x % 3 == 0) | (x % 7 == 0):
			print('YES')
			break
		x -= 3
		if x <= 0:
			print('NO')
		continue


n = int(input())
for i in range(n):
	a = int(input())
	f = 'NO'
	for j in range(34):
		if j * 3 <= a:
			if (a - j * 3) % 7 == 0:
				f = 'YES'
	print(f)


t = int(input())
i = 0
while i < t:
	n = int(input())
	if n > 11:
		print('YES')
	elif n % 3 == 0:
		print('YES')
	elif n % 7 == 0:
		print('YES')
	elif n % 10 == 0:
		print('YES')
	else:
		while n > 7:
			n -= 7
		while n > 3:
			n -= 3
		if n == 0:
			print('YES')
		else:
			print('NO')
	i += 1


def solve(x):
	maxB = x // 7 + 1
	for b in range(maxB):
		if (x - b * 7) % 3 == 0:
			return True
	return False

def test():
	print(solve(1))
	print(solve(3))
	print(solve(6))
	print(solve(5))
	print(solve(7))
	print(solve(10))
	print(solve(27))
	print(solve(39))

def ni():
	s = input()
	while len(s) == 0:
		s = input()
	try:
		return int(s)
	except:
		return 0
t = ni()
while t > 0:
	t -= 1
	n = ni()
	print('YES' if solve(n) else 'NO')


n = int(input())
for i in range(n):
	s = 0
	x = int(input())
	for x1 in range(100):
		for x2 in range(100):
			if x1 * 3 + x2 * 7 == x:
				s += 1
		if s != 0:
			break
	if s == 0:
		print('NO')
	else:
		print('YES')


import math, fractions
for _ in range(int(input())):
	x = int(input())
	flag = False
	if x % 3 == 0 or x % 7 == 0:
		flag = True
	elif x >= 6 and (x != 8 and x != 11):
		flag = True
	print('YES' if flag else 'NO')


n = int(input())
for i in range(0, n):
	e = int(input())
	if e != 1 and e != 2 and (e != 4) and (e != 5) and (e != 8) and (e != 11):
		print('YES')
	else:
		print('NO')


def hungry_programmer_problem(numbers: list) -> bool:
	(k, r) = ([7 * x for x in range(3)], [])
	for n in numbers:
		r.append(0 in [max(-1, n - b) % 3 for b in k])
	return r

def main():
	(n, l) = (int(input()), [])
	for i in range(n):
		l.append(int(input()))
	for i in hungry_programmer_problem(l):
		print('YES' if i else 'NO')
main()


lines = int(input())
tests = []
for i in range(lines):
	tests.append(input())
tests = list(map(int, tests))
for x in tests:
	if x % 7 == 0 or x % 3 == 0:
		print('YES')
	elif x < 7:
		print('NO')
	elif x % 7 % 3 == 0:
		print('YES')
	else:
		y = x % 7
		while y % 3 != 0 and y + 7 <= x:
			y += 7
			if y % 3 == 0:
				print('YES')
				break
			if y + 7 >= x:
				print('NO')
				break


k = int(input())
l = 0

def f(x):
	l = 0
	if x % 3 == 0 or x % 7 == 0 or x % 10 == 0:
		print('YES')
		l = 1
	if l == 0:
		for n in range(10):
			if (x - 7 * n) % 10 == 0 and x - 7 * n >= 0:
				l = 1
				print('YES')
				break
			elif (x - 3 * n) % 10 == 0 and x - 3 * n >= 0:
				l = 1
				print('YES')
				break
	if l == 0:
		print('NO')
for n in range(k):
	f(int(input()))


def main():
	N = int(input())
	X = tuple((int(input()) for _ in [0] * N))
	for i in X:
		if not i % 3 or not i % 7:
			print('YES')
		else:
			while i > 0:
				if not i % 3:
					print('YES')
					break
				i -= 7
			else:
				print('NO')
main()


n = int(input())
for i in range(n):
	x = int(input())
	ans = 0
	for k in range(1, x // 3 + 1):
		if x % (3 * k) % 7 == 0:
			ans = 1
			break
	for k in range(1, x // 7 + 1):
		if x % (7 * k) % 3 == 0:
			ans = 1
			break
	if ans:
		print('YES')
	else:
		print('NO')


n = int(input())
lis = []

def cek(n):
	if n < 3:
		return False
	if n % 3 == 0 or n % 7 == 0:
		return True
	else:
		for i in range(1, 100):
			for j in range(1, 100):
				if i * 3 + j * 7 == n:
					return True
	return False
for i in range(n):
	lis.append(int(input()))
for i in range(n):
	if cek(lis[i]):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	x = int(input())
	print('YES' if any((3 * i + 7 * j == x for i in range(100) for j in range(100))) else 'NO')


n = int(input())
for kk in range(n):
	tot = int(input())
	m = tot // 7
	boo = False
	for i in range(m + 1):
		if (tot - i) % 3 == 0:
			boo = True
			break
	if boo:
		print('YES')
	else:
		print('NO')


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	f = 1
	if n <= 2:
		print('NO')
	elif n % 3 == 0 or n % 7 == 0:
		print('YES')
	else:
		for i in range(34):
			for j in range(34):
				if 3 * i + 7 * j == n:
					f = 0
					break
		if f == 0:
			print('YES')
		else:
			print('NO')


n = int(input())
l = []
v = []
for i in range(n):
	j = int(input())
	l.append(j)
	if l[i] % 7 in [0, 3, 6] or l[i] % 3 == 0 or l[i] > 12:
		v.append('YES')
	else:
		v.append('NO')
for i in range(n):
	print(v[i])


n = int(input())
for i in range(n):
	p = int(input())
	result = False
	while p >= 3:
		if p % 3 == 0 or p % 7 == 0:
			result = True
			break
		p -= 7
	if result:
		print('YES')
	else:
		print('NO')


def ans(n):
	if n < 3:
		return False
	if n % 3 == 0 or n % 7 == 0:
		return True
	sol = ans(n - 7) or ans(n - 3)
	return sol
test_cases = int(input())
while test_cases != 0:
	x = int(input())
	if ans(x):
		print('YES')
	else:
		print('NO')
	test_cases = test_cases - 1


def is_pos(m):
	if m < 0:
		return False
	if m % 3 == 0:
		return True
	return is_pos(m - 7)
n = int(input())
x = []
for ii in range(n):
	x.append(int(input()))
for ii in range(n):
	if is_pos(x[ii]):
		print('YES')
	else:
		print('NO')


n = int(input())
while n:
	a = int(input())
	if a % 3 == 0:
		print('YES')
	elif a % 7 == 0:
		print('YES')
	else:
		by3 = a // 3
		by7 = a // 7
		by3arr = [i + 1 for i in list(range(by3))]
		by7arr = [i + 1 for i in list(range(by7))]
		r = 0
		for i in by7arr:
			for x in by3arr:
				if a == i * 1 + x * 3:
					r = 1
					break
		print('YES' if r else 'NO')
	n -= 1


n = int(input())
for i in range(n):
	t = int(input())
	a = t % 3
	while a and t >= 7:
		t -= 7
		a = t % 3
	if a:
		print('NO')
	else:
		print('YES')


def solve(x):
	a = 0
	while x - 3 * a >= 0:
		if (x - 3 * a) % 7 == 0:
			return 'YES'
		a += 1
	return 'NO'
n = int(input())
for i in range(n):
	x = int(input())
	print(solve(x))


def solve(x):
	for a in range(0, (x + 2) // 3 + 1):
		for b in range(0, (x + 6) // 7 + 1):
			if 3 * a + 7 * b == x:
				return True
	return False
n = int(input())
for i in range(0, n):
	x = int(input())
	if solve(x):
		print('YES')
	else:
		print('NO')


def divide(val):
	for x in range(1, int(val / 3) + 1):
		for y in range(1, int(val / 7) + 1):
			if 3 * x + 7 * y == val:
				return True
num = int(input())
while num:
	val = int(input())
	if val == 0:
		print('NO')
		continue
	if val % 3 == 0 or val % 7 == 0:
		print('YES')
	elif divide(val):
		print('YES')
	else:
		print('NO')
	num = num - 1


s = int(input())
for i in range(s):
	flag = 0
	n = int(input())
	for j in range(34):
		for k in range(14):
			if 3 * j + 7 * k == n:
				flag = 1
				break
	if flag:
		print('YES')
	else:
		print('NO')


a = []
n = int(input(''))
for i in range(n):
	new_element = int(input())
	a.append(new_element)
for i in range(n):
	if a[i] % 3 == 0 or a[i] % 7 == 0 or a[i] % 7 % 3 == 0 or (a[i] % 3 == 1 and a[i] > 6) or (a[i] % 3 == 2 and a[i] > 12):
		print('YES')
	else:
		print('NO')


def traverse(target, current):
	if current == target:
		return 1
	if current > target:
		return 0
	left = traverse(target, current + 3)
	if left > 0:
		return 1
	return traverse(target, current + 7)

def main():
	n = int(input())
	for i in range(n):
		v = int(input())
		print('NO' if traverse(v, 0) == 0 else 'YES')
main()


a = [False for i in range(3)]
a.append(True)
for i in range(4, 7):
	a.append(a[i - 3])
a.append(True)
for i in range(8, 101):
	a.append(a[i - 3] or a[i - 7])
n = int(input())
for i in range(n):
	x = int(input())
	if a[x]:
		print('YES')
	else:
		print('NO')


n = int(input())
small = 3
large = 7
for i in range(n):
	c = int(input())
	if c % small == 0 or c % large == 0:
		print('YES')
	else:
		need = False
		for j in range(34):
			x = c - small * j
			if x > 0 and x % large == 0:
				print('YES')
				need = True
				break
		if not need:
			print('NO')


def solve(n):
	ans = 'NO'
	for a in range(0, n // 3 + 2):
		for b in range(0, n // 7 + 2):
			if a * 3 + b * 7 == n:
				ans = 'YES'
				break
	return ans
t = int(input())
for _ in range(t):
	n = int(input())
	ans = solve(n)
	print(ans)


x = int(input())
n = [0 for i in range(101)]
n[0] = 1
for i in range(101):
	if n[i] == 1:
		if i + 3 < 101:
			n[i + 3] = 1
		if i + 7 < 101:
			n[i + 7] = 1
for i in range(x):
	y = int(input())
	if n[y] == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	x = int(input())
	f = 0
	for k in range(34):
		for j in range(20):
			if 3 * k + 7 * j == x:
				f = 1
				break
	if f == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
chunks = []
for _ in range(n):
	chunks.append(int(input()))
for c in chunks:
	found = False
	while c > 0:
		if c % 3 == 0 or c % 7 == 0:
			found = True
			break
		c -= 7
	if found:
		print('YES')
	else:
		print('NO')


n = int(input())
for r in range(n):
	chic = int(input())
	while chic > 0:
		if chic % 3 == 0:
			chic = 7
		chic -= 7
	if chic == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
x = [0 for i in range(n)]
count = 0
while count < n:
	x[count] = int(input())
	if x[count] % 3 == 0 or x[count] % 7 == 0:
		x[count] = 0
	else:
		ans = 0
		while x[count] > 0:
			x[count] -= 3
			if x[count] % 7 == 0:
				ans = 1
				break
		if ans == 1:
			x[count] = 0
		else:
			x[count] = x[count]
	count += 1
count = 0
while count < n:
	if x[count] == 0:
		print('YES')
	else:
		print('NO')
	count += 1


import sys
n = int(input())
for i in range(n):
	m = int(input())
	if m % 3 == 0 or m % 7 == 0 or m % 10 == 0 or (m > 11):
		print('YES')
	else:
		print('NO')


n = int(input())
while n:
	x = int(input())
	if x == 1 or x == 2 or x == 4 or (x == 5) or (x == 8) or (x == 11):
		print('NO')
	else:
		print('YES')
	n = n - 1


for _ in range(int(input())):
	n = int(input())
	ans = 'NO'
	for i in range(n):
		Rem = n - 3 * i
		if Rem % 7 == 0 and Rem >= 0:
			ans = 'YES'
	print(ans)


for _ in range(int(input())):
	a = int(input())
	n = a // 7
	b = a % 7
	if b == 0 or (b == 1 and n > 1) or (b == 2 and n > 0) or (b == 3) or (b == 4 and n > 1) or (b == 5 and n > 0) or (b == 6):
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	x = int(input())
	ans = 'NO'
	for k in range(x // 3 + 1):
		for p in range(x // 7 + 1):
			if x == 3 * k + 7 * p:
				ans = 'YES'
	print(ans)


val = [3, 7]

def hun(val, m, n):
	if n == 0:
		return 1
	if n < 0:
		return 0
	if m <= 0 and n >= 1:
		return 0
	return hun(val, m - 1, n) + hun(val, m, n - val[m - 1])
t = int(input())
out = []
for i in range(t):
	if hun(val, 2, int(input())) > 0:
		out.append('YES')
	else:
		out.append('NO')
print(*out, sep='\n')


def calc(n):
	if n > 12:
		return 'YES'
	while n >= 3:
		if n % 7 == 0 or n % 3 == 0:
			return 'YES'
		else:
			n -= 3
	return 'NO'
n = int(input())
for i in range(n):
	print(calc(int(input())))


a = [0] * 120
a[3] = 1
a[7] = 1
for i in range(100):
	if a[i] == 1:
		a[i + 3] = 1
		a[i + 7] = 1
n = int(input())
for i in range(n):
	if a[int(input())] == 1:
		print('YES')
	else:
		print('NO')


a = int(input())
e = []
for i in range(a):
	b = int(input())
	for j in range(int(b / 3) + 1):
		if int((b - 3 * j) / 7) == (b - 3 * j) / 7:
			e.append('YES')
			break
		else:
			j = j + 1
	else:
		e.append('NO')
for i in range(len(e)):
	print(e[i])


def test():
	x = int(input())
	for b in range(20):
		t = x - 7 * b
		if t >= 0 and t % 3 == 0:
			print('YES')
			return
	print('NO')
n = int(input())
for _ in range(n):
	test()


n = int(input())
for i in range(n):
	m = int(input())
	n = 0
	flag = 0
	while 7 * n <= m:
		if (m - 7 * n) % 3 == 0:
			print('YES')
			flag = 1
			break
		n += 1
	if flag == 0:
		print('NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
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 [int(x) for x in sys.stdin.readline().split()]

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 main():
	n = I()
	a = [I() for _ in range(n)]
	r = []
	for c in a:
		f = 0
		for i in range(3):
			if c % 3 == 0:
				f = 1
				break
			c -= 7
			if c < 0:
				break
		if f:
			r.append('YES')
		else:
			r.append('NO')
	return '\n'.join(r)
print(main())


def av(x):
	for i in range(100):
		for j in range(100):
			if 7 * i + 3 * j == x:
				return 'YES'
	return 'NO'
for i in range(int(input())):
	x = int(input())
	print(av(x))


test_cases = int(input())
for _ in range(test_cases):
	num = int(input())
	var = 3
	count = 0
	while num > 0:
		if num % 7 == 0 or num % 3 == 0:
			print('YES')
			count = 1
			break
		num = num - var
		b = num % 7
		if b == 0:
			print('YES')
			count = 1
			break
	if count == 0:
		print('NO')


n = int(input())
for i in range(n):
	x = int(input())
	if x % 7 == 0 or x % 3 == 0:
		print('YES')
		continue
	while True:
		if x < 3:
			print('NO')
			break
		elif x % 3 == 0:
			print('YES')
			break
		x -= 7


n = int(input())
mem = {}

def p(n):
	if n in mem:
		return mem[n]
	if n == 0:
		mem[n] = True
		return True
	if n < 0:
		mem[n] = False
		return False
	if p(n - 3) == True:
		mem[n] = True
		return True
	if p(n - 7) == True:
		mem[n] = True
		return True
	mem[n] = False
	return False
for x in range(n):
	c = int(input())
	if p(c):
		print('YES')
	else:
		print('NO')


n = int(input())
b = []
for i in range(n):
	a = int(input())
	if a == 1 or a == 2 or a == 4 or (a == 5) or (a == 8) or (a == 11):
		b.append('NO')
	else:
		b.append('YES')
for i in range(n):
	print(b[i])


n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
for i in range(n):
	if (a[i] % 3 == 0 or a[i] % 7 == 0) and a[i] > 0:
		print('YES')
	else:
		x = a[i]
		h = 0
		for j in range(7):
			if a[i] > 0:
				a[i] = a[i] - 3
				if a[i] % 7 == 0:
					print('YES')
					h = 1
					break
			else:
				break
		else:
			for j in range(3):
				if x > 0:
					x = x - 7
					if x % 3 == 0:
						print('YES')
						h = 1
						break
				else:
					break
		if h == 0:
			print('NO')


l = [False, False, False, True, False, False, True, True, False, True, True, False] + [True] * 100
for i in range(int(input())):
	print('YES' if l[int(input())] else 'NO')


n = int(input())
ans = list()
for i in range(n):
	x = int(input())
	for j in range((x + 7) // 7):
		if (x - j * 7) % 3 == 0:
			ans.append('YES')
			break
	else:
		ans.append('NO')
print('\n'.join(ans))


N = int(input())
for j in range(N):
	i = int(input())
	if i in [0, 3, 6, 7, 9, 10] or i > 11:
		print('YES')
	else:
		print('NO')


T = int(input())
for I in range(T):
	X = int(input())
	Y = X
	Z = X
	F = 0
	while F == 0 and (Y >= 0 or Z >= 0):
		Y -= 3
		Z -= 7
		if Y % 7 == 0 and (Y >= 7 or Y == 0):
			F = 1
			break
		if Z % 3 == 0 and (Z >= 3 or Z == 0):
			F = 1
			break
	if F == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
lis = []
for i in range(n):
	user = int(input())
	lis.append(user)
for i in range(n):
	flag = 0
	if lis[i] % 3 == 0 or lis[i] % 7 == 0:
		print('YES')
	else:
		num = lis[i]
		while num >= 0:
			num = num - 3
			if num % 7 == 0:
				print('YES')
				flag = 1
				break
		if flag == 0:
			print('NO')


sevens = [7 * i for i in range(3)]
for i in range(int(input())):
	num = int(input())
	print('YES' if 0 in [max(-1, num - seven) % 3 for seven in sevens] else 'NO')


def get_int(string, n):
	i = j = k = 0
	for s in string:
		k += 1
	for s in string:
		if i == n - 1:
			break
		if s == ' ':
			i += 1
		j += 1
	i = 0
	while j < k:
		if string[j] == ' ':
			break
		i = 10 * i + int(string[j])
		j += 1
	return i

def get_ans(y):
	if y < 0:
		print('NO')
	elif y % 3 == 0 or y % 7 == 0:
		print('YES')
		return
	else:
		y -= 3
		get_ans(y)
n = int(input())
for i in range(0, n):
	y = int(input())
	get_ans(y)


n = int(input())
for _ in range(n):
	x = int(input())
	if x % 3 == 0 or x % 7 == 0:
		print('YES')
	else:
		a = b = x
		flag = False
		while a > 0:
			a -= 3
			if a > 0 and a % 7 == 0:
				flag = True
				break
		if not flag:
			while b > 0:
				b -= 7
				if b > 0 and b % 3 == 0:
					flag = True
					break
		print('YES' if flag else 'NO')


n = int(input())
while n:
	n1 = int(input())
	f = 0
	if not n1 % 3 or not n1 % 7:
		f = 1
	else:
		m1 = n1
		while 1:
			n1 -= 3
			if n1 < 7:
				break
			if not n1 % 7:
				f = 1
				break
		while not f:
			m1 -= 7
			if m1 < 3:
				break
			if not m1 % 3:
				f = 1
				break
	if f:
		print('YES')
	else:
		print('NO')
	n -= 1


def check(x):
	if x < 3 or x == 4 or x == 5 or (x == 8) or (x == 11):
		return False
	return True
n = int(input())
for i in range(n):
	x = int(input())
	if check(x):
		print('YES')
	else:
		print('NO')


def c(n):
	for i in range(15):
		for j in range(34):
			if 7 * i + 3 * j == n:
				return True
	return False
for _ in range(int(input())):
	print('YES' if c(int(input())) else 'NO')


n = int(input())
for i in range(n):
	m = int(input())
	ans = 0
	for j in range(m):
		if 3 * j > m:
			break
		if (m - 3 * j) % 7 == 0:
			ans = 1
	if ans == 1:
		print('YES')
	else:
		print('NO')


def chunk(x):
	for i in range(x // 3 + 1):
		if (x - i * 3) % 7 == 0:
			return True
c = []
n = int(input())
for i in range(n):
	m = int(input())
	c.append(m)
for i in range(n):
	if chunk(c[i]) == True:
		print('YES')
	else:
		print('NO')


Aux = []
N = int(input())
Aux = Aux * N
for x in range(0, N):
	j = int(input())
	Aux.append(j)
for k in range(0, N):
	if Aux[k] <= 11:
		if Aux[k] % 3 == 0 or Aux[k] % 7 == 0 or Aux[k] % 10 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


n = int(input())
out = []
for i in range(n):
	x = int(input())
	if x in [1, 2, 4, 5, 8, 11]:
		out.append('NO')
	else:
		out.append('YES')
for e in out:
	print(e)


from math import floor, ceil
n = int(input())
d = [int(input()) for i in range(n)]
for t in d:
	print('YES' if ceil((2 * (t % 3) - t // 3) / 7) <= floor(t % 3 / 3) else 'NO')


n = input()
a = []
i = 0
while i < int(n):
	a.append(input())
	flag = False
	for j in range(0, 100):
		if (int(a[i]) - 3 * j) % 7 == 0 and int(a[i]) - 3 * j >= 0:
			print('YES')
			flag = True
			break
	if flag == False:
		print('NO')
	i += 1


n = int(input())
seter = set([1, 2, 4, 5, 8, 11])
ans = ''
for i in range(n):
	if int(input()) in seter:
		ans += 'NO\n'
	else:
		ans += 'YES\n'
print(ans[0:-1])


n = int(input())
for i in range(n):
	x = int(input())
	found = False
	for a in range(40):
		for b in range(40):
			if 3 * a + 7 * b == x:
				found = True
				break
		if found:
			print('YES')
			break
	if not found:
		print('NO')


n = int(input())
delik = [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93]
deliki = [0, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
for i in range(n):
	x = int(input())
	while 1:
		flag = 0
		for i in delik:
			if (x - i) % 7 == 0 and x - i > 0:
				flag = 1
				break
		for i in deliki:
			if (x - i) % 3 == 0 and x - i > 0:
				flag = 1
				break
		if flag == 1:
			print('YES')
		else:
			print('NO')
		break


n = int(input(''))
A = []
for i in range(n):
	x = int(input(''))
	A.append(x)
for i in A:
	if i % 3 == 0 or i % 7 == 0 or i % 10 == 0:
		print('YES')
	elif i > 12:
		print('YES')
	else:
		print('NO')


def kfc(x):
	while x > 0:
		if x % 10 == 0 or x % 7 == 0 or x % 3 == 0:
			return 'YES'
		if x >= 10:
			x -= 10
		elif x >= 7:
			x -= 7
		elif x >= 3:
			x -= 3
		else:
			break
	if x == 0:
		return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	x = int(input())
	print(kfc(x))


import sys

def solution(n):
	if n > 11:
		return 'YES'
	res1 = n % 3
	result1 = res1 % 7
	res2 = n % 7
	result2 = res2 % 3
	if result1 == 0 or result2 == 0:
		answer = 'YES'
	else:
		answer = 'NO'
	return answer
n = sys.stdin.readline()
test_n = sys.stdin.readline()
while test_n:
	print(solution(int(test_n)))
	test_n = sys.stdin.readline()


M = 110
a = []
a = [0] * M
a[0] = 1
for i in range(M):
	for j in [3, 7]:
		if i - j >= 0 and a[i - j]:
			a[i] = 1
for _ in range(int(input())):
	n = int(input())
	if a[n]:
		print('YES')
	else:
		print('NO')


n = int(input())
l = []
a = 'YES'
b = 'NO'
for i in range(n):
	x = int(input())
	goon = True
	while goon:
		for j in range(34):
			for k in range(34):
				if 3 * k + 7 * j == x:
					l.append(a)
					goon = False
					break
			if goon == False:
				break
		if goon == True:
			l.append(b)
			break
for i in l:
	print(i)


def solve(x):
	if x < 0:
		return False
	elif x == 0:
		return True
	return solve(x - 7) or solve(x - 3)

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


def seven(a):
	small = 3
	big = 7
	k = 0
	while a - big * k >= 3 and (a - big * k) % small != 0:
		k += 1
	if a - big * k > 0 and (a - big * k) % small == 0:
		return True
	else:
		return False
n = int(input())
small = 3
big = 7
for i in range(n):
	a = int(input())
	if a % big % small == 0 or a % small % big == 0 or seven(a):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	c = 0
	n = int(input())
	for j in range(0, n + 1):
		for k in range(0, n + 1):
			if 3 * j + 7 * k == n or 3 * k + j * 7 == n:
				c += 1
				break
	if c == 0:
		print('NO')
	else:
		print('YES')


n = int(input())
for i in range(n):
	p = int(input())
	j = 0
	temp = True
	while p - 7 * j >= 0:
		if (p - 7 * j) / 3 == (p - 7 * j) // 3:
			print('YES')
			temp = False
			break
		j += 1
	if temp:
		print('NO')


k = int(input())
i = 0
while i < k:
	x = int(input())
	answer = 'NO'
	if x % 3 == 0 or x % 7 == 0:
		answer = 'YES'
	while x > 0:
		x -= 3
		if x % 7 == 0:
			answer = 'YES'
			break
	print(answer)
	i += 1


def check(n):
	if n not in {1, 2, 4, 5, 8, 11}:
		return True
A = []
n = int(input())
for i in range(n):
	a = int(input())
	if check(a):
		A.append('YES')
	else:
		A.append('NO')
for x in A:
	print(x)


import sys
from itertools import *
from cmath import *
input = sys.stdin.readline
from math import *

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
for _ in range(int(input())):
	n = inp()
	flag = 'NO'
	for i in range(n + 1):
		for j in range(n + 1):
			if i * 3 + j * 7 == n:
				flag = 'YES'
	print(flag)


for t in range(int(input())):
	n = int(input())
	m = True
	if m:
		for i in range(0, 34):
			for j in range(0, 34):
				if 3 * i + 7 * j == n:
					print('YES')
					m = False
					break
				if 3 * i + 7 * j > n:
					k = False
					break
			if not m or k:
				break
	k = True
	if m:
		for i in range(0, 34):
			for j in range(0, 34):
				if 3 * i + 7 * j == n:
					print('YES')
					m = False
					break
			if not m or k:
				break
	if m:
		print('NO')


n = int(input())
while n > 0:
	f = True
	x = int(input())
	for i in range(0, 111):
		for j in range(0, 111):
			if 3 * i + 7 * j == x and f:
				f = False
				print('YES')
				break
	if f:
		print('NO')
	n -= 1


t = int(input())
for i in range(t):
	x = int(input())
	flag = False
	while x >= 0:
		if x % 3 == 0:
			flag = True
			break
		x -= 7
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	print('YES' if int(input()) in [0, 3, 6, 7, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100] else 'NO')


n = int(input())
A = [False] * n
for i in range(n):
	L = int(input())
	if L % 3 % 7 == 0 or L % 7 % 3 == 0 or L >= 12:
		A[i] = True
for i in range(n):
	if A[i]:
		print('YES')
	else:
		print('NO')


n = int(input())
a = 0
f = True
j = 0
k = 0
for i in range(n):
	a = int(input())
	f = True
	j = 0
	k = 0
	while f and k < 15:
		j = 0
		while f and j < 34:
			if 7 * k + 3 * j == a:
				print('YES')
				f = False
			j += 1
		k += 1
	if f:
		print('NO')


for _ in range(int(input())):
	for s in range(int(input()), -1, -7):
		if s % 3 == 0:
			print('YES')
			break
	else:
		print('NO')


def main():
	x = eval(input())
	list1 = []
	for i in range(x):
		a = eval(input())
		if a > 11:
			list1.append('YES')
			continue
		if a % 7 == 0 or a % 3 == 0:
			list1.append('YES')
			continue
		if a % 7 % 3 == 0:
			list1.append('YES')
			continue
		list1.append('NO')
	for i in list1:
		print(i)
main()


n = int(input())
for i in range(n):
	t = int(input())
	for j in range(7):
		if j * 3 <= t and (t - j * 3) % 7 == 0:
			print('YES')
			break
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	flag = 0
	for j in range(n // 3):
		if (n - 3 * j) % 7 % 3 == 0 or n % 3 == 0:
			print('YES')
			flag = 1
			break
	if flag == 0:
		print('NO')


for _ in range(int(input())):
	x = int(input())
	res = [1] + [0] * x
	for n in [3, 7]:
		for j in range(n, x + 1):
			res[j] += res[j - n]
	print('YES' if res[-1] else 'NO')


n = int(input())
a = []
flag = 0
for i in range(n):
	a.append(int(input()))
for i in range(len(a)):
	if a[i] % 7 == 0:
		print('YES')
	elif a[i] % 3 == 0:
		print('YES')
	else:
		k = a[i] // 7
		while k != 0:
			b = a[i] - k * 7
			if b % 3 == 0:
				print('YES')
				flag = 1
				k = 0
			else:
				k -= 1
				flag = 0
		if flag == 0:
			print('NO')
			k = 0


t = int(input())
al = []
for i in range(t):
	a = int(input())
	al.append(a)
for i in range(len(al)):
	if al[i] == 0 or al[i] == 1 or al[i] == 2 or (al[i] == 4) or (al[i] == 5) or (al[i] == 8) or (al[i] == 11):
		print('NO')
	else:
		print('YES')


n_tests = int(input())
impossible_values = [1, 2, 4, 5, 8, 11]
for i in range(n_tests):
	n_chunks = int(input())
	if n_chunks in impossible_values:
		print('NO')
	else:
		print('YES')


trials = int(input())
while trials > 0:
	n = int(input())
	k = [1, 2, 4, 5, 8, 11]
	if n in k:
		print('NO')
	else:
		print('YES')
	trials -= 1


n = int(input())
x = [int(input()) for i in range(n)]
set_ = set([])
for i in range(100):
	for j in range(100):
		set_.add(7 * i + 3 * j)
for i in range(n):
	if x[i] in set_:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	x = int(input())
	for j in range(15):
		if 7 * j > x:
			print('NO')
			break
		if (x - 7 * j) % 3 == 0:
			print('YES')
			break
	else:
		print('NO')


n = int(input())
o = []
for i in range(n):
	x = int(input())
	x -= x % 3 * 7
	if x < 0:
		o.append('NO')
	else:
		o.append('YES')
print('\n'.join(o))


t = int(input())
for i in range(t):
	k = int(input())
	if k <= 11:
		print(['NO', 'YES'][not k % 7 % 3 or not k % 7 or (not k % 3)])
	else:
		print('YES')


def solve(x):
	for b in range(x // 7 + 1):
		if (x - 7 * b) % 3 == 0:
			return 'YES'
	return 'NO'

def main():
	n_queries = int(input())
	for _ in range(n_queries):
		print(solve(int(input())))
main()


n = int(input())
for case in range(n):
	x = int(input())
	if x in [1, 2, 4, 5, 8, 11]:
		ans = 'NO'
	else:
		ans = 'YES'
	print(ans)


def hihi(x):
	a = [1, 2, 4, 5, 8, 11]
	if x in a:
		return 'NO'
	else:
		return 'YES'
t = int(input())
for i in range(t):
	x = int(input())
	print(hihi(x))


n = int(input())
x = []
s = 3
b = 7
f = 0
for i in range(n):
	x.append(int(input()))
for i in range(n):
	f = 0
	for j in range(x[i] // 2 + 1):
		for k in range(x[i] // 2 + 1):
			if s * j + b * k == x[i]:
				f = 1
				print('YES')
				break
		if f == 1:
			break
	if f == 0:
		print('NO')


def find(x):
	f = False
	while x >= 3:
		if x % 3 == 0 or x % 7 == 0 or x == 10:
			f = True
			break
		else:
			x -= 10
	return f
for i in range(int(input())):
	x = int(input())
	print('NO' if find(x) == False else 'YES')


n = int(input())

def check(x):
	for i in range(40):
		for j in range(20):
			if 3 * i + 7 * j == x:
				return True
	return False
for i in range(n):
	tmp = int(input())
	if check(tmp):
		print('YES')
	else:
		print('NO')


n = int(input())
while n > 0:
	x = int(input())
	s = 0
	while s <= x:
		if x % 7 == 0 or x % 3 == 0:
			print('YES')
			break
		s += 3
		if (x - s) % 7 == 0:
			print('YES')
			break
		else:
			pass
	if s > x:
		print('NO')
	n = n - 1


import sys
n = int(input())
for x in map(int, sys.stdin):
	for i in range(100):
		if x - 3 * i >= 0 and (x - 3 * i) % 7 == 0:
			print('YES')
			break
	else:
		print('NO')


n = int(input())
for i in range(n):
	t = int(input())
	if t % 3 == 0 or t % 7 == 0:
		print('YES')
	else:
		t -= 7
		f = 0
		while t > 0:
			if t % 3 == 0:
				print('YES')
				f = 1
				break
			t -= 7
		if f == 0:
			print('NO')


b = [0] * 101
for k in range(3, 101):
	i = 0
	while k - 3 * i >= 0:
		if (k - 3 * i) % 7 == 0:
			b[k] += 1
			break
		else:
			i += 1
t = int(input())
for i in range(t):
	if b[int(input())] == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
for N in range(n):
	x = int(input())
	f = 0
	for i in range(35):
		for j in range(35):
			if 3 * i + 7 * j == x:
				f = 1
				break
	if f:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	x = int(input())
	f = 0
	for a in range(34):
		for b in range(20):
			if 3 * a + 7 * b == x:
				f = 1
	if f == 1:
		print('YES')
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase
import math
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')
for _ in range(int(input())):
	n = int(input())
	if n <= 2 or n == 4 or n == 5 or (n == 8) or (n == 11):
		print('NO')
	else:
		print('YES')


n = int(input())
a = []
for i in range(n):
	x = int(input())
	a.append(x)
for i in a:
	if i in [0, 3, 6, 7, 9, 10] or i > 11:
		print('YES')
	else:
		print('NO')


import sys
n = int(input())
for i in range(0, n):
	x = int(input())
	while x >= 0:
		if x % 3 == 0:
			print('YES')
			break
		x -= 7
	if x < 0:
		print('NO')


def check(x):
	for a in range(16):
		for b in range(34):
			if 7 * a + 3 * b == x:
				return 'YES'
	return 'NO'
for _ in range(int(input())):
	x = int(input())
	print(check(x))


for _ in range(int(input())):
	x = int(input())
	if x % 3 == 0 or x % 7 == 0:
		print('YES')
	else:
		tmp = x - x % 7
		flag = True
		while (x - tmp) % 3 != 0:
			tmp -= 7
			if tmp <= 0:
				flag = False
				break
		if flag:
			print('YES')
		else:
			print('NO')


n = int(input())
x = []
t = []
for i in range(n):
	x.append(int(input()))
for i in range(34):
	for j in range(15):
		t1 = 3 * i + 7 * j
		if t1 <= 100:
			t.append(t1)
for i in range(n):
	if (x[i] in t) == True:
		print('YES')
	else:
		print('NO')


n = int(input())
d = [0] * 110
d[0] = 1
for i in range(1, 105):
	if i - 3 >= 0:
		d[i] |= d[i - 3]
	if i - 7 >= 0:
		d[i] |= d[i - 7]
for i in range(n):
	m = int(input())
	if d[m]:
		print('YES')
	else:
		print('NO')


n = int(input())
a = []
for x in range(n):
	p = int(input())
	a.append(p)
for i in a:
	if i % 7 == 0 or i % 3 == 0:
		print('YES')
	elif i % 7 != 0 and i % 3 != 0:
		for y in range(15):
			m = i - 3 * y
			if m % 7 == 0 and m >= 0:
				print('YES')
				break
		else:
			print('NO')


import sys
n = sys.stdin.readline()
n = int(n)
for i in range(n):
	x = int(sys.stdin.readline())
	boole = True
	while boole and x > 3:
		if x % 3 == 0 or x % 7 == 0:
			boole = False
		else:
			x -= 7
	if x < 3:
		print('NO')
	else:
		print('YES')


n = int(input())
for i in range(n):
	out = 'NO'
	a = int(input())
	for j in range(a):
		if ((a - 3 * j) % 7 == 0) & (a - 3 * j >= 0):
			out = 'YES'
	print(out)


for n in range(int(input())):
	a = int(input())
	for x in range(a // 3 + 1):
		if (a - 3 * x) % 7 == 0:
			print('YES')
			break
	else:
		print('NO')


for i in range(int(input())):
	a = int(input())
	while a >= 7 and a % 3 != 0:
		a -= 7
	if a == 0 or a % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input().strip())
x = 7
y = 3
for _ in range(0, n):
	z = int(input().strip())
	try:
		for a in range(0, 100):
			for b in range(0, 100):
				if a * x + b * y == z:
					raise Exception('FOUND')
	except:
		print('YES')
	else:
		print('NO')


cases = int(input())
inputs = []
for i in range(0, cases):
	inputs.append(int(input()))
for i in range(0, cases):
	x = inputs[i]
	if x % 7 == 0:
		print('YES')
	elif x % 3 == 0:
		print('YES')
	else:
		temp = 0
		while temp < x:
			temp += 7
			if temp > x:
				print('NO')
			elif (x - temp) % 3 == 0:
				print('YES')
				temp = x + 1


for i in range(int(input())):
	n = int(input())
	if n % 7 == 0 or n % 3 == 0:
		print('YES')
	else:
		n7 = n // 7
		found = False
		while n7 > 0 and (not found):
			if (n - 7 * n7) % 3 == 0:
				found = True
			else:
				n7 -= 1
		if found:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	x = int(input())
	n = x // 3
	n //= 2
	x %= 3
	if x == 0 or x <= n:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = int(input())
	b = a % 7
	c = a % 3
	if b == 0 or c == 0 or b % 3 == 0:
		print('YES')
	elif a > 11:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	z = int(input())
	if z % 3 == 0 or z % 7 == 0:
		print('YES')
	else:
		tr = True
		while z >= 3:
			if z % 3 == 0:
				print('YES')
				tr = False
				break
			z -= 7
		while z >= 7 and tr:
			if z % 7 == 0:
				print('YES')
				break
			j -= 3
		if tr:
			print('NO')


testcase = int(input())
for i in range(testcase):
	x = int(input())
	if x >= 12:
		print('YES')
	elif x % 3 == 0 or x % 7 == 0:
		print('YES')
	elif (x - 3) % 7 == 0:
		print('YES')
	else:
		print('NO')


l = [1, 2, 4, 5, 8, 11]
t = int(input())
while t:
	n = int(input())
	if n in l:
		print('NO')
	else:
		print('YES')
	t -= 1


src = input()
n = int(src)
for i in range(n):
	src = input()
	x = int(src)
	rem = x % 3
	if x >= rem * 7:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	h = int(input())
	if h % 3 == 0:
		print('YES')
	elif h % 3 == 1 and h >= 7:
		print('YES')
	elif h % 3 == 2 and h >= 14:
		print('YES')
	else:
		print('NO')


n = int(input())
chi = []
for i in range(n):
	chi.append(int(input()))
for i in chi:
	for a in range(i // 3 + 1):
		if (i - a * 3) % 7 == 0:
			print('YES')
			break
	else:
		print('NO')


n = int(input())
for o in range(n):
	a = int(input())
	if a == 1 or a == 2 or a == 4 or (a == 5) or (a == 8) or (a == 11):
		print('NO')
	else:
		print('YES')


def main(x):
	b = x // 7
	a = 0
	while b * 7 + a * 3 != x:
		if b * 7 + a * 3 > x:
			b -= 1
		else:
			a += 1
		if b < 0:
			return 'NO'
	return 'YES'

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


n = int(input())

def isBuy(x):
	for i in range(x // 3 + 1):
		for j in range(x // 7 + 1):
			if 3 * i + 7 * j == x:
				return True
	return False
for _ in range(n):
	x = int(input())
	print(['NO', 'YES'][isBuy(x)])


n = int(input())
for i in range(n):
	s = int(input())
	while s > 0:
		if s % 7 != 0:
			s -= 3
		else:
			s = 0
			break
	if s == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
ans = []
for i in range(n):
	r = int(input())
	f = 0
	if r % 7 == 0:
		f = 1
	else:
		while r > 2:
			if r % 3 == 0:
				f = 1
				break
			r -= 7
	if f:
		ans.append(1)
	else:
		ans.append(0)
for i in range(n):
	if ans[i]:
		print('YES')
	else:
		print('NO')


import sys
n = int(input())
arr = []
for i in range(n):
	x = int(input())
	if x > 11:
		arr.append('YES')
		continue
	if x < 10:
		if x % 3 == 0 or x % 7 == 0:
			arr.append('YES')
		else:
			arr.append('NO')
	elif x % 10 == 0:
		arr.append('YES')
	else:
		x = x % 10
		if x % 3 == 0 or x % 7 == 0:
			arr.append('YES')
		else:
			arr.append('NO')
for i in range(n):
	print(arr[i])


n = int(input())
for x in range(n):
	print(('YES', 'NO')[int(input()) in [1, 2, 4, 5, 8, 11]])


T = int(input())
for t in range(0, T):
	x = int(input())
	flag = 0
	for i in range(0, 33):
		for j in range(0, 33):
			if 3 * i + 7 * j == x:
				flag = 1
	if flag == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
l = []
for i in range(0, n):
	for j in range(0, 200):
		l.append(0)
	a = int(input())
	l[2] = 1
	l[6] = 1
	for k in range(0, 100):
		if l[k] == 1:
			l[k + 3] = 1
			l[k + 7] = 1
	if l[a - 1] == 1:
		print('YES')
	else:
		print('NO')


def func(x):
	if x % 3 == 0:
		return 'YES'
	if x % 7 == 0:
		return 'YES'
	if x % 10 == 0:
		return 'YES'
	digit = x % 10
	if digit % 3 == 0:
		return 'YES'
	if digit % 7 == 0:
		return 'YES'
	x -= 10
	while x > 0:
		if x % 3 == 0 or x % 7 == 0:
			return 'YES'
		x -= 10
	return 'NO'

def main():
	t = int(input())
	t_input = [int(input()) for i in range(t)]
	for i in list(map(func, t_input)):
		print(i)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	flag = 0
	for i in range(0, 15):
		for j in range(0, 35):
			if j * 3 + i * 7 == n:
				flag = 1
				break
	print('YES') if flag else print('NO')


x = [0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
i = int(input())
for j in range(i):
	a = int(input())
	if x[a] == 1:
		print('YES')
	else:
		print('NO')


def main():
	n = int(input())
	ch = []
	for i in range(n):
		ch.append(int(input()))
	res = []
	for i in range(1, 101):
		num = i
		ok = False
		while num >= 0:
			if num % 7 == 0:
				res.append('YES')
				ok = True
				break
			elif num % 3 == 0:
				res.append('YES')
				ok = True
				break
			else:
				num -= 3
		if not ok:
			res.append('NO')
	for j in range(n):
		s = ch[j]
		print(res[s - 1])
main()


n = int(input())

def f(p):
	if p <= 0:
		return 0
	elif p % 3 == 0 or p % 7 == 0:
		return 1
	else:
		return f(p - 3) or f(p - 7)
for i in range(n):
	if f(int(input())):
		print('YES')
	else:
		print('NO')


import sys
import math
import bisect
import itertools

def main():
	for _ in range(int(input())):
		x = int(input())
		ans = False
		for i in range(x // 3 + 1):
			if (x - i * 3) % 7 == 0:
				ans = True
				break
		if ans:
			print('YES')
		else:
			print('NO')
main()


rpt = int(input())
for x in range(0, rpt):
	number = int(input())
	yes = 0
	for i in range(0, int(number / 3) + 1):
		if (number - i * 3) % 7 == 0:
			yes = 1
	if yes == 1:
		print('YES')
	else:
		print('NO')


def judge(a):
	while a % 3 != 0 and a >= 7:
		a = a - 7
	if a % 3 == 0:
		print('YES')
	else:
		print('NO')
for i in range(0, int(input()), 1):
	x = int(input())
	judge(x)


N = int(input())
for i in range(N):
	X = int(input())
	Do = True
	if X % 3 == 0 or X % 7 == 0:
		print('YES')
		Do = False
	j = X
	while j >= 3 and Do:
		if j % 3 == 0:
			print('YES')
			Do = False
			break
		j -= 7
	j = X
	while j >= 7 and Do:
		if j % 7 == 0:
			print('YES')
			Do = False
			break
		j -= 3
	if Do:
		print('NO')


for i in range(int(input())):
	t = int(input())
	c = 0
	for b in range(15):
		if (t - 7 * b) % 3 == 0 and t - 7 * b >= 0:
			print('YES')
			break
	if b == 14:
		print('NO')


n = int(input())
f = [0, 3, 6, 7, 9]
for n in range(n):
	x = int(input())
	f = False
	for i in range(x // 10 + 1):
		if (x - i * 10) % 3 == 0 or (x - i * 10) % 7 == 0:
			print('YES')
			f = True
			break
	if not f:
		print('NO')


n = int(input())
while n > 0:
	n -= 1
	t = int(input())
	if t > 11:
		print('YES')
	else:
		K = t % 7
		t = t % 3
		K = K % 3
		t = t % 7
		if t == 0 or K == 0:
			print('YES')
		else:
			print('NO')


n = int(input())
x = [int(input()) for i in range(n)]
for i in range(n):
	if x[i] % 3 == 0 or x[i] % 7 == 0:
		print('YES')
	else:
		k = x[i]
		while True:
			k = k - 7
			if k < 0:
				print('NO')
				break
			if k % 3 == 0:
				print('YES')
				break


n = int(input())
for _ in range(n):
	trg = False
	x = int(input())
	for i in range(14):
		for j in range(33):
			if x - i * 7 - j * 3 == 0:
				print('YES')
				trg = True
				break
		if trg:
			break
	if not trg:
		print('NO')


n = int(input())
for _ in range(n):
	x = int(input())
	if x % 3 == 0:
		print('YES')
		continue
	if x % 7 == 0:
		print('YES')
		continue
	l = x
	while l >= 0:
		if l % 7 == 0:
			print('YES')
			break
		l -= 3
	else:
		l = x
		while l >= 0:
			if l % 3 == 0:
				print('YES')
				break
			l -= 7
		else:
			print('NO')


def solve(n):
	cnt = 'NO'
	for a in range(34):
		for b in range(34):
			if 3 * a + 7 * b == n:
				cnt = 'YES'
				break
	return cnt
t = int(input())
for i in range(t):
	n = int(input())
	print(solve(n))


t = int(input())
while t:
	t -= 1
	f = 0
	n = int(input())
	for a in range(33):
		for b in range(33):
			if a * 3 + b * 7 == n:
				f = 1
				break
		if f == 1:
			break
	if f == 1:
		print('YES')
	else:
		print('NO')


def calculator(a):
	if a % 3 == 0 or a % 7 == 0:
		return 'YES'
	while a >= 3:
		a -= 7
		if a > 0 and a % 3 == 0:
			return 'YES'
	return 'NO'
for i in range(int(input())):
	print(calculator(int(input())))


def maybe(x):
	if x >= 3 and x <= 7:
		if x == 3 or x == 6 or x == 7:
			return True
	elif (x % 3 == 0 or x % 7 == 0 or x % 3 % 7 == 0 or (x % 7 % 3 == 0) or ((x - 7) % 3 == 0) or ((x - 3) % 7 == 0) or (x % 10 % 3 == 0) or (x % 10 % 7 == 0)) and x > 7:
		return True
	else:
		return False

def maybe2(x):
	i = 7
	sch = 1
	res = False
	while i < x:
		b = x - i
		if b >= 3 and b <= 7:
			if b == 3 or b == 6 or b == 7:
				return True
				break
		elif (b % 3 == 0 or b % 7 == 0 or b % 3 % 7 == 0 or (b % 7 % 3 == 0) or ((b - 7) % 3 == 0) or ((b - 3) % 7 == 0) or (b % 10 % 3 == 0) or (b % 10 % 7 == 0)) and b > 7:
			return True
			break
		i = i * sch
		sch += 1
	return res
n = int(input())
for i in range(n):
	x = int(input())
	if maybe(x) == True:
		print('YES', end='')
	elif maybe2(x) == False:
		print('NO', end='')
	else:
		print('YES', end='')
	if i != n - 1:
		print()


t = int(input())
for m in range(t):
	n = int(input())
	l = 0
	for i in range(1000):
		for j in range(1000):
			if 3 * i + 7 * j == n:
				l += 1
	if l == 0:
		print('NO')
	else:
		print('YES')


n = int(input())
for _ in range(n):
	pieces = int(input())
	ans = 'NO'
	for i in range(0, pieces // 7 + 1):
		if (pieces - i * 7) % 3 == 0:
			ans = 'YES'
			break
	print(ans)


for x in range(int(input())):
	a = int(input())
	i = 0
	f = 0
	s = 0
	while s >= 0:
		s = a - 7 * i
		if s % 3 == 0 and s >= 0:
			f = 1
			break
		i += 1
	if f == 0:
		print('NO')
	else:
		print('YES')


from typing import List

def hungry_programmer_problem(nums: List[int]) -> List[bool]:
	k = [7 * x for x in range(3)]
	return [0 in [max(-1, num - b) % 3 for b in k] for num in nums]

def main():
	numbersCount = int(input())
	l = [int(input()) for x in range(numbersCount)]
	[print('YES' if i else 'NO') for i in hungry_programmer_problem(l)]
main()


s = set([1, 2, 4, 5, 8, 11])
ans = []
n = int(input())
for i in range(n):
	t = int(input())
	if t in s:
		ans.append('NO')
	else:
		ans.append('YES')
print('\n'.join((i for i in ans)))


t = int(input())
s = []
for hjbbh in range(0, t):
	x = int(input())
	f = int(x // 7)
	h = 0
	for i in range(0, f + 1):
		if (x - i * 7) % 3 == 0:
			s.append('YES')
			h += 1
			break
	if h == 0:
		s.append('NO')
for i in s:
	print(i)


t = int(input())
for i in range(0, t):
	n = int(input())
	flag = 0
	for j in range(0, 34):
		if 3 * j > n:
			break
		if (n - 3 * j) % 7 == 0:
			flag = 1
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')


l = []
for j in range(0, 101, 7):
	for i in range(j, 101, 3):
		if i not in l:
			l.append(i)
l.sort()
t = int(input())
for i in range(t):
	n = int(input())
	if n in l:
		print('YES')
	else:
		print('NO')


def canBuy(x):
	if x < 0:
		return False
	elif x == 0:
		return True
	else:
		return canBuy(x - 3) or canBuy(x - 7)
TC = int(input())
for x in range(TC):
	x = int(input())
	res = canBuy(x)
	print('YES') if res else print('NO')


n = int(input())
m = [False] * 101
for i in range(100):
	for j in range(100):
		t = i * 3 + j * 7
		if t <= 100:
			m[t] = True
for _ in range(n):
	x = int(input())
	if m[x]:
		print('YES')
	else:
		print('NO')


x = input()
x = int(x)
z = 0
res = []
for i in range(x):
	threes = 0
	y = input()
	y = int(y)
	if y % 3 == 0 or y % 7 == 0:
		res.append('YES')
	else:
		while y >= 3:
			y = y - 3
			threes = threes + 1
		if y == 1:
			if threes >= 2:
				res.append('YES')
			else:
				res.append('NO')
		elif y == 2:
			if threes >= 4:
				res.append('YES')
			else:
				res.append('NO')
for i in res:
	print(i)


n = int(input())
lst = []
for x in range(n):
	x = int(input())
	lst.append(int(x))
array = [None] * 101
array[0] = True
array[1] = False
array[2] = False
for x in range(3, 101):
	if array[x - 3] or array[x - 7]:
		array[x] = True
	else:
		array[x] = False
for x in lst:
	if array[x]:
		print('YES')
	else:
		print('NO')


x = int(input())
for i in range(x):
	t = int(input())
	for i in range(t):
		if t - 7 * i < 0:
			print('NO')
			break
		if t < 7:
			if t % 3 == 0:
				print('YES')
				break
			else:
				print('NO')
				break
		elif t - 7 * i == 0:
			print('YES')
			break
		elif (t - 7 * i) % 3 == 0:
			print('YES')
			break
		elif t - 7 * i < 3:
			print('NO')
			break


n = int(input())
for i in range(n):
	x = int(input())
	flag = False
	if x % 3 == 0 or x % 7 == 0:
		flag = True
	else:
		mul = 1
		while mul <= 33:
			tmp = x - 3 * mul
			if tmp < 0:
				break
			elif tmp % 7 == 0:
				flag = True
				break
			mul += 1
	if flag:
		print('YES')
	else:
		print('NO')


n = int(input())
v = {3, 7}
ps = 0
while len(v) != ps:
	nv = {i for i in v}
	for a in v:
		if a + 3 <= 100:
			nv.add(a + 3)
		if a + 7 <= 100:
			nv.add(a + 7)
	ps = len(v)
	v = nv
for i in range(n):
	x = int(input())
	if x in v:
		print('YES')
	else:
		print('NO')


import sys
import math

def func(n):
	if n == 0:
		return 1
	if n < 0:
		return 0
	return func(n - 3) or func(n - 7)
for i in range(int(input())):
	n = int(input())
	y = func(n)
	if y == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
z = [False] * 101
n = 34
m = 15
for i in range(m):
	for j in range(n):
		if i * 7 + j * 3 < 101:
			z[i * 7 + j * 3] = True
z[0] = False
while t:
	f = int(input())
	if z[f]:
		print('YES')
	else:
		print('NO')
	t -= 1


for _ in range(int(input())):
	x = int(input())
	ok = 0
	for i in range(x // 3 + 1):
		a = i * 3
		b = x - a
		if b % 7 == 0:
			ok = 1
	if ok == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	flag = False
	for i in range(33):
		for j in range(33):
			if i * 3 + j * 7 == n:
				flag = True
	print('YES' if flag else 'NO')


for _ in range(int(input())):
	flag = 0
	x = int(input())
	while x >= 0:
		if x % 10 == 0:
			flag = 1
			break
		if x % 7 == 0:
			flag = 1
			break
		if x % 3 == 0:
			flag = 1
			break
		x -= 3
	print(['NO', 'YES'][flag == 1])


t = int(input())
for y in range(t):
	x = int(input())
	t = x
	done = 0
	if x <= 2 or x == 5 or x == 4:
		print('NO')
	else:
		while x > 0:
			if x % 3 == 0:
				done = 1
				print('YES')
				break
			x -= 7
		if not done:
			while t > 0:
				if t % 7 == 0:
					done = 1
					print('YES')
					break
				t -= 3
			if not done:
				print('NO')


def solve():
	n = int(input())
	i = 1
	while n - 3 * i >= 0:
		if (n - 3 * i) % 7 == 0:
			print('YES')
			return
		else:
			i = i + 1
	i = 1
	while n - 7 * i >= 0:
		if (n - 7 * i) % 3 == 0:
			print('YES')
			return
		else:
			i = i + 1
	print('NO')
	return
try:
	n = int(input())
	for i in range(n):
		solve()
except:
	pass


n = int(input())
deem = int
for i in range(0, n):
	m = int(input())
	for x in range(0, 33):
		for y in range(0, 33):
			r = x * 7
			s = y * 3
			if r + s == m:
				deem = r + s
	if deem == m:
		print('YES')
	else:
		print('NO')


def frac(x):
	i = 1
	while i * 3 <= x:
		if (x - 3 * i) % 7 == 0:
			return True
		if (x - 7 * i) % 3 == 0 and x - 7 * i >= 0:
			return True
		i += 1
count = int(input())
test_cases = []
for i in range(count):
	test_cases.append(int(input().strip()))
for test in test_cases:
	if frac(test):
		print('YES')
	else:
		print('NO')


import sys
n = int(sys.stdin.readline())
possible = ['YES'] + ['NO'] * 100
for i3 in [i * 3 for i in range(33)]:
	possible[i3] = 'YES'
	for i7 in [i * 7 for i in range(14)]:
		if i3 + i7 > 100:
			break
		else:
			possible[i3 + i7] = 'YES'
for i in range(n):
	x = int(sys.stdin.readline())
	print(possible[x])


n = int(input())
p = []
for k in range(n):
	x = int(input())
	a = x % 3
	if x == 1 or x == 2 or x == 4 or (x == 5) or (x == 8) or (x == 11):
		p.append('NO')
	else:
		p.append('YES')
for k in range(n):
	print(p[k])


n = int(input())
for i in range(n):
	qwe = int(input())
	ans = 0
	flag = 0
	for x in range(qwe // 3 + 1):
		for y in range(qwe // 7 + 1):
			ans = 3 * x + 7 * y
			if ans == qwe:
				flag = 1
				break
			ans = 0
		if flag == 1:
			break
	if flag == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
large = [7 * k for k in range(15)]
small = [3 * k for k in range(34)]
for i in range(n):
	flag = 0
	num = int(input())
	for i in large:
		for j in small:
			if i + j == num:
				print('YES')
				flag = 1
				break
		if flag == 1:
			break
	if flag == 0:
		print('NO')


n = int(input())
pz = []
for i in range(n):
	pz.append(int(input()))

def check(k):
	if k <= 0:
		return 'NO'
	if k % 3 == 0 or k % 7 == 0:
		return 'YES'
	k -= 3
	return check(k)
for x in pz:
	print(check(x))


c = int(input())
for i in range(c):
	n = int(input())
	if n > 14 or n % 3 == 0 or n % 7 == 0 or (n % 3 == 1 and n > 7):
		print('YES')
	else:
		print('NO')


import sys
n = int(input())
for i in range(n):
	a = int(input())
	for j in range(100):
		f = 0
		for m in range(100):
			if j * 3 + m * 7 == a:
				print('YES')
				f = 1
				break
			elif j * 3 + m * 7 > a:
				break
		if f:
			break
	if not f:
		print('NO')


n = int(input())

def ist(n):
	for i in range(0, int(n / 3) + 1):
		if (n - i * 3) % 7 == 0:
			return True
	return False
for i in range(n):
	a = int(input())
	if ist(a):
		print('YES')
	else:
		print('NO')


a = []
for i in range(0, 15):
	for j in range(0, 34):
		a.append(i * 7 + j * 3)
n = int(input())
for i in range(n):
	x = int(input())
	if x in a:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	print('NO' if all((s % 3 for s in range(int(input()), -1, -7))) else 'YES')


def check(a):
	if a % 3 == 0 or a % 7 == 0:
		return True
	if a in [1, 2, 4, 5, 8, 11]:
		return False
	return True
n = int(input())
for i in range(n):
	x = int(input())
	if check(x):
		print('YES')
	else:
		print('NO')


tc = int(input())
sv = []
for _ in range(110):
	sv.append(0)
sv[3] = 1
sv[7] = 1
for i in range(101):
	if sv[i] != 0:
		sv[i + 3] = 1
		sv[i + 7] = 1
for i in range(tc):
	if sv[int(input())] == 1:
		print('YES')
	else:
		print('NO')


def chickens(total):
	if total % 3 == 0 or total % 7 == 0:
		return 'YES'
	elif total % 3 == 1 and total // 3 >= 2:
		return 'YES'
	elif total % 3 == 2 and total // 3 >= 4:
		return 'YES'
	return 'NO'
test = int(input())
for x in range(test):
	print(chickens(int(input())))


lines = int(input())
inputs = []
for i in range(lines):
	inputs.append(input())
inputs = list(map(int, inputs))
c = 0
while lines > c:
	x = inputs[c]
	c += 1
	a = x // 7
	b = 0
	while b <= a:
		x = x - 7 * b
		if x % 3 == 0:
			print('YES')
			break
		elif b == a:
			print('NO')
			break
		else:
			x = x + 7 * b
			b += 1


t = int(input())
for T in range(t):
	x = int(input())
	if x % 3 == 0 or x % 7 == 0:
		print('YES')
		continue
	y = x
	f1 = False
	f2 = False
	while y > 0:
		if y % 3 == 0:
			f1 = True
			break
		y -= 7
	y = x
	while y > 0:
		if y % 7 == 0:
			f1 = True
			break
		y -= 3
	if f1 or f2:
		print('YES')
	else:
		print('NO')


test_cases = int(input())
for i in range(test_cases):
	total_chicken = int(input())
	if total_chicken in [1, 2, 4, 5, 8, 11]:
		print('NO')
	else:
		print('YES')


n1 = int(input())
mu = [0, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
mu1 = []
mu1.append(0)
n = 3
while n < 100:
	mu1.append(n)
	n = n + 3
ans = []
for i in mu:
	for j in mu1:
		ans.append(i + j)
while n1 > 0:
	f = 0
	t = int(input())
	if t in ans:
		print('YES')
	else:
		print('NO')
	n1 = n1 - 1


n = int(input())

def can_i(k):
	tr = 0
	while tr <= k:
		if (k - tr) % 7 == 0:
			return 'YES'
		tr += 3
	return 'NO'
for _ in range(n):
	x = int(input())
	print(can_i(x))


def chunks(m):
	f = 0
	if m % 3 == 0 or m % 7 == 0:
		return 'YES'
	else:
		for j in range(1, 34):
			for k in range(1, 16):
				if 3 * j + 7 * k == m:
					return 'YES'
	return 'NO'
n = int(input())
for i in range(n):
	m = int(input())
	print(chunks(m))


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

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

def li():
	return list(mi())
for i in range(ii()):
	x = ii()
	ok = 0
	while x >= 0:
		if x % 3 == 0:
			ok = 1
			break
		x -= 7
	print('YES' if ok else 'NO')


t = int(input())
x = [0] * 130
x[0] = 1
for i in range(101):
	if x[i]:
		x[i + 3] = x[i + 7] = 1
for _ in range(t):
	i = int(input())
	print('YES' if x[i] else 'NO')


t = int(input())
while t:
	t += -1
	x = int(input())
	ch = 0
	for i in range(100):
		for j in range(100):
			if 3 * i + 7 * j == x:
				ch = 1
				break
	if ch:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	x = int(input())
	if x % 3 == 0:
		print('YES')
	elif x % 7 == 0:
		print('YES')
	elif x % 7 % 3 == 0:
		print('YES')
	elif x % 3 == 1 and x > 6:
		print('YES')
	elif x % 3 == 2 and x > 12:
		print('YES')
	else:
		print('NO')
	t = t - 1


n = int(input())
all_x = set()
for i in range(50):
	for j in range(50):
		if 3 * i + 7 * j <= 100:
			all_x.add(3 * i + 7 * j)
for _ in range(n):
	print('YES' if int(input()) in all_x else 'NO')


def find(n):
	for i in range(33):
		for j in range(14):
			r = i * 3 + j * 7
			if r == n:
				print('YES')
				return
	print('NO')
t = int(input())
while t:
	n = int(input())
	find(n)
	t = t - 1


from sys import stdin, stdout
n = int(stdin.readline())
for i in range(n):
	k = int(stdin.readline())
	label = 0
	for c in range(k + 1):
		if k >= c * 3 and (not (k - c * 3) % 7):
			label = 1
	if label:
		stdout.write('YES\n')
	else:
		stdout.write('NO\n')


usable = {3, 7}
for i in range(35):
	for j in range(20):
		usable |= {i * 3 + j * 7}
n = int(input())
for i in range(n):
	x = int(input())
	print('YES' if x in usable and x <= 100 else 'NO')


def program():
	n = int(input())
	if n == 1 or n == 2 or n == 4 or (n == 5) or (n == 8) or (n == 11):
		print('NO')
	else:
		print('YES')
t = int(input())
for i in range(t):
	program()


def chicken(n: int) -> bool:
	f = 0
	n_7 = n // 7
	n_3 = 0
	if n % 3 == 0 or n % 7 == 0:
		return True
	elif n in [1, 2, 4, 5]:
		return False
	while True:
		if (n - n_7 * 7) % 3 == 0:
			n_3 == n - n_7 * 7
			return True
		elif (n - n_7 * 7) % 3 != 0:
			n_7 -= 1
		if n_7 == 0:
			return False
n = int(input())
for i in range(n):
	num = int(input())
	if chicken(num):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	while True:
		if n == 0:
			print('YES')
			break
		if n % 3 == 0:
			print('YES')
			break
		elif n % 7 == 0:
			print('YES')
			break
		elif n - 7 >= 0:
			n -= 7
		elif n - 3 >= 0:
			n -= 3
		else:
			print('NO')
			break


n = int(input())
for i in range(n):
	x = int(input())
	if x % 3 == 1:
		if x / 3 > 2:
			print('YES')
		else:
			print('NO')
	elif x % 3 == 2:
		if x / 3 > 4:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


n = int(input())
y = []
for i in range(n):
	x = int(input())
	(w, s, t) = ('NO', 0, 0)
	while 7 * s <= 100:
		t = 0
		while 3 * t + 7 * s <= 100:
			if x == 3 * t + 7 * s:
				w = 'YES'
				break
			else:
				t += 1
		s += 1
	y.append(w)
for m in y:
	print(m)


n = int(input())
dizi = []
for i in range(n):
	x = int(input())
	dizi.insert(0, x)
dizi.reverse()
for i in range(n):
	if dizi[i] > 12 or dizi[i] % 3 == 0 or dizi[i] == 7 or (dizi[i] == 10):
		print('YES')
	else:
		print('NO')


t = int(input())
f = []
for i in range(101):
	f.append(0)
for i in range(34):
	for j in range(15):
		m = i * 3 + j * 7
		if m <= 100:
			f[m] = 1
for q in range(t):
	n = int(input())
	if f[n] == 1:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	x = int(input())
	if x % 3 == 0:
		print('YES')
	elif x % 3 == 1:
		if x > 6:
			print('YES')
		else:
			print('NO')
	elif x % 3 == 2:
		if x > 13:
			print('YES')
		else:
			print('NO')


n = int(input())
for i in range(n):
	a = int(input())
	temp = False
	if a % 7 == 0 or a % 3 == 0:
		temp = True
	else:
		while a > 0:
			if a % 3 == 0:
				temp = True
			a -= 7
	if temp == True:
		output = 'YES'
	else:
		output = 'NO'
	print(output)


n = int(input())
y = 0
for i in range(n):
	x = int(input())
	a1 = int(x / 3)
	a2 = int(x / 7)
	for i in range(a1 + 1):
		if y == 1:
			break
		for j in range(a2 + 1):
			if 3 * i + 7 * j == x:
				print('YES')
				y = 1
				break
	if y == 0:
		print('NO')
	y = 0


for i in range(int(input())):
	x = int(input())
	can = False
	while can == False and x > 0:
		if x % 3 == 0 or x % 7 == 0:
			can = True
		else:
			x -= 7
	if can:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	ans = []
	for j in range(34):
		for k in range(15):
			if j * 3 + k * 7 == n:
				ans.append(j + k)
	if len(ans) == 0:
		print('NO')
	else:
		print('YES')


r = int(input())
for i in range(0, r):
	x = int(input())
	div = x // 7
	found = -1
	for i in range(0, div + 1):
		if (x - i * 7) % 3 == 0:
			found = 0
			break
	print('YES' if found == 0 else 'NO')


n = int(input())
a = []
for i in range(n):
	z = int(input())
	a.append(z)
for i in a:
	if i < 3:
		print('NO')
	elif i % 3 == 0 or i % 7 == 0:
		print('YES')
	else:
		while i > 3 and i % 3 != 0:
			i -= 7
		if i % 3 == 0 and i >= 0:
			print('YES')
		else:
			print('NO')


def canBuy(n):
	for i in range(100):
		s = 7 * i
		if n - s < 0:
			return False
		if (n - s) % 3 == 0:
			return True
	return False
n = int(input())
tests = []
for i in range(n):
	tests.append(int(input()))
for i in tests:
	print('YES' if canBuy(i) else 'NO')


n = int(input())
while n:
	x = int(input())
	if x >= 7 * (x % 3):
		print('YES')
	else:
		print('NO')
	n -= 1


test = int(input())
ans = []
for i in range(0, test):
	x = int(input())
	for b in range(0, x):
		cur = x - 7 * b
		a = cur / 3
		if cur % 3 == 0 and cur >= 0:
			ans.append('YES')
			break
	else:
		ans.append('NO')
for i in ans:
	print(i)


read = lambda : list(map(int, input().split()))
n = int(input())
for i in range(n):
	x = int(input())
	if x not in [1, 2, 4, 5, 8, 11]:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	x = int(input())
	f = False
	for i in range(x):
		if x - 3 * i >= 0 and (x - 3 * i) % 7 == 0:
			f = True
			break
	if f:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	w = int(input())
	f = 0
	for i in range(0, w // 3 + 1):
		if (w - i * 3) % 7 == 0:
			f = 1
			print('YES')
			break
	if f == 0:
		print('NO')


a = list()
for i in range(50):
	for j in range(50):
		if 3 * i + j * 7 < 101:
			a.append(3 * i + j * 7)
for i in range(int(input())):
	print('YES' if int(input()) in a else 'NO')


n = int(input())

def solution(inp):
	if inp < 3:
		print('NO')
		return
	else:
		if inp % 7 == 0:
			print('YES')
			return
		if inp % 3 == 0:
			print('YES')
			return
		else:
			while inp > 3:
				inp = inp - 3
				if inp % 7 == 0:
					print('YES')
					return
	print('NO')
	return
for l in range(n):
	inp = int(input())
	solution(inp)


n = int(input())
for i in range(n):
	x = int(input())
	flag = 0
	for a in range(x):
		for b in range(x):
			ans = a * 3 + b * 7
			if ans == x:
				flag = 1
				break
	if flag == 1:
		print('YES')
	else:
		print('NO')


def f(x):
	if x == 0 or x == 6 or x == 7:
		return True
	elif x == 1 or x == 2 or x == 4 or (x == 5):
		return False
	else:
		return f(x - 3) or f(x - 7)
n = int(input())
l = []
for k in range(n):
	a = int(input())
	l.append(f(a))
for k in l:
	if k:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	t = int(input())
	if t % 3 == 0:
		print('YES')
	elif t % 3 == 1:
		if t >= 7:
			print('YES')
		else:
			print('NO')
	elif t >= 14:
		print('YES')
	else:
		print('NO')


n = int(input())
for el in range(n):
	z = int(input())
	mas = [1, 2, 4, 5, 8, 11]
	if z in mas:
		print('NO')
		continue
	else:
		print('YES')


n = int(input())
setA = {1, 2, 4, 5, 8, 11}
for i in range(n):
	s = int(input())
	if s in setA:
		print('NO')
	else:
		print('YES')


a = int(input())
hh = []
for x in range(a):
	t = 'NO'
	b = int(input())
	for x in range(0, 100):
		h = (b - 7 * x) / 3
		if h // 1 == h and h >= 0:
			t = 'YES'
			break
	hh.append(t)
for x in hh:
	print(x)


def c(a):
	if a == 0:
		return 0
	elif a < 0:
		return -1
	for i in [3, 7]:
		k = c(a - i)
		if k == 0:
			return 0
	return -1
t = int(input())
for i in range(t):
	a = int(input())
	if c(a) == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	x = int(input())
	k = x
	flag = 0
	while x > 0:
		if x % 3 == 0:
			flag = 1
			break
		else:
			x -= 7
	while k > 0 and flag == 0:
		if k % 7 == 0:
			flag = 1
			break
		else:
			k -= 3
	if flag:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	x = int(input())
	while x not in [0, 1, 2, 4, 5]:
		if x % 3 != 0:
			x = x - 7
		else:
			x = x % 3
	if x == 0:
		print('YES')
	else:
		print('NO')


n_test_cases = int(input())
for i in range(n_test_cases):
	n_chunks = int(input())
	keep_going = True
	for n_small in range(int(110 / 3)):
		if not keep_going:
			break
		for n_big in range(int(120 / 7)):
			if not keep_going:
				break
			if n_small * 3 + n_big * 7 == n_chunks:
				keep_going = False
	if keep_going:
		print('NO')
	else:
		print('YES')


N = int(input())
data = [False, False, False, True, False, False, True, True, False, True, True, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]
for i in range(N):
	print('YES' if data[int(input())] else 'NO')


t = int(input())
for i in range(t):
	r = int(input())
	if r % 3 == 0:
		print('YES')
		continue
	elif r % 7 == 0:
		print('YES')
		continue
	else:
		e = r % 7
		q = r % 3
		if r > 8:
			if e == 3 or e == 2:
				print('YES')
			elif r == 11:
				print('NO')
			elif r > 11:
				print('YES')
		else:
			print('NO')


n = int(input())
for _ in range(n):
	a = int(input())
	n = a // 3
	flag = 0
	for s in range(0, n + 1):
		if (a - 3 * s) % 7 == 0:
			flag = 1
			break
	if flag == 0:
		print('NO')
	elif flag == 1:
		print('YES')


def judge(x):
	for i in range(x + 1):
		if 3 * i > x:
			break
		if (x - 3 * i) % 7 == 0:
			return 'YES'
	return 'NO'
n = int(input())
for cas in range(n):
	x = int(input())
	print(judge(x))


n = int(input())
for _ in range(n):
	x = int(input())
	if x > 11:
		print('YES')
	elif x == 0 or x == 3 or x == 6 or (x == 7) or (x == 9) or (x == 10):
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = int(input()) + 7
	flag = False
	while a > 0:
		a -= 7
		if a >= 0 and a % 3 == 0:
			flag = True
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	n = int(input())
	if not (n % 3 and n % 7):
		print('YES')
		continue
	else:
		flag = 1
		big = n // 7
		reminder = n - big * 7
		while big > 0 and flag:
			if not reminder % 3:
				print('YES')
				flag = 0
				continue
			else:
				big -= 1
				reminder += 7
		if not flag:
			continue
	print('NO')


n = int(input())
for i in range(n):
	x = int(input())
	valid = False
	for i in range(40):
		for j in range(20):
			if 3 * i + 7 * j == x:
				valid = True
				break
		if valid:
			break
	if valid:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	t = int(input())
	flag = 0
	if t % 3 == 0 or t % 7 == 0:
		print('YES')
	else:
		for a in range(1, 101):
			for b in range(1, 101):
				if t % (3 * a + 7 * b) == 0:
					print('YES')
					flag = 1
					break
			if flag == 1:
				break
		if flag == 0:
			print('NO')


tc = int(input())
for t in range(tc):
	n = int(input())
	f = 0
	for x in range(n):
		if n - 7 * x < 0:
			break
		elif (n - 7 * x) % 3 == 0:
			f = 1
			break
	if f == 1:
		print('YES')
	else:
		print('NO')


import sys, math
from itertools import permutations
DEBUG = 0
if DEBUG:
	f = open('input.txt', 'r')
	input = f.readline
else:
	input = sys.stdin.readline

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

def main():
	INF = int(1000000000.0)
	n = int(input())
	for i in range(n):
		x = int(input())
		if x > 3 * 7 - 10:
			print('YES')
		elif x % 3 == 0 or x == 7 or x == 10:
			print('YES')
		else:
			print('NO')
main()


def fun(z):
	i = 0
	while i <= z:
		if (z - i) % 3 == 0:
			return True
		i += 7
n = int(input())
for i in range(n):
	if fun(int(input())):
		print('YES')
	else:
		print('NO')


n = int(input())
a = []
for _ in range(n):
	x = int(input())
	ans = 'NO'
	for i in range(0, x // 7 + 1):
		if (x - i * 7) % 3 == 0:
			ans = 'YES'
			break
	a.append(ans)
for i in a:
	print(i)


n = int(input())
a = []
for i in range(101):
	for j in range(101):
		a.insert(0, i * 3 + j * 7)
for i in range(n):
	x = int(input())
	print('YES' if x in a else 'NO')


def ret(x):
	for i in range(0, 100, 3):
		for i2 in range(0, 100, 7):
			if i == x or i2 == x or i + i2 == x:
				return 'YES'
	return 'NO'
n = int(input())
m = []
for i in range(n):
	m.append(int(input()))
for i in m:
	print(ret(i))


def main():
	t = int(input())
	x = []
	for i in range(t):
		y = 0
		n = int(input())
		while n > 0:
			if n % 3 == 0 or n % 7 == 0:
				y = 1
				break
			n = n - 7
		if y == 1:
			x.append('YES')
		else:
			x.append('NO')
	for i in x:
		print(i)
main()


n = int(input())
a = []
output = []
for i in range(1, 15):
	for m in range(1, 101):
		if (m - 7 * i) % 3 == 0 and m - 7 * i > 0:
			a.append(m)
		elif m % 3 == 0 or m % 7 == 0:
			a.append(m)
for i in range(0, n):
	k = int(input())
	if k in a:
		output.append('YES')
	else:
		output.append('NO')
for i in range(0, n):
	print(output[i])


import sys
nk = int(sys.stdin.readline())
while nk:
	pieces = int(sys.stdin.readline())
	ans = 'NO'
	while pieces > 0:
		if pieces % 3 == 0 or pieces % 7 == 0 or pieces % 3 == 7 or (pieces % 7 == 3):
			ans = 'YES'
			break
		else:
			pieces -= 3
	print(ans)
	nk -= 1


mas = []
n = int(input())
for i in range(n):
	x = int(input())
	while x >= 0:
		if x % 3 == 0 or x % 7 == 0:
			mas.append('YES')
			break
		x -= 3
	if x < 0:
		mas.append('NO')
print('\n'.join(mas))


n = int(input())
for _ in range(n):
	a = int(input())
	if a % 3 == 0 or a % 7 == 0:
		print('YES')
		continue
	if a % 3 == 1 and a >= 7:
		print('YES')
		continue
	if a % 3 == 2 and a >= 14:
		print('YES')
		continue
	print('NO')


import sys
sys.version
n = int(input())
for i in range(1, n + 1):
	x = int(input())
	ans = 0
	if x % 3 == 0 or x % 7 == 0:
		ans = 1
	for y in range(1, x + 1):
		if x - y * 3 >= 0 and (x - y * 3) % 7 == 0:
			ans = 1
	if ans == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	flag = 0
	no_chunks = int(input())
	for a in range(0, 34):
		for b in range(0, 34):
			if 3 * a + 7 * b == no_chunks:
				flag = 1
				break
		if flag == 1:
			break
	if flag == 1:
		print('YES')
	else:
		print('NO')


def isValidTotal(n):
	if n < 0:
		return False
	if n == 0 or n % 3 == 0 or n % 7 == 0:
		return True
	return isValidTotal(n - 3) or isValidTotal(n - 7)
for _ in range(int(input())):
	n = int(input())
	print('YES' if isValidTotal(n) else 'NO')


for _ in range(int(input())):
	n = int(input())
	flag = 0
	for i in range(n // 3 + 1):
		if (n - i * 3) % 7 == 0:
			flag = 1
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')


n = int(input())
chicken_chunks = []
for i in range(n):
	inp = int(input())
	chicken_chunks.append(inp)
result = []
for i in range(n):
	num = chicken_chunks[i]
	if num < 3:
		result.append('NO')
	elif num % 3 == 0 or num % 7 == 0:
		result.append('YES')
	elif num < 7:
		if num % 3 == 0:
			result.append('YES')
		else:
			result.append('NO')
	else:
		while num > 0:
			if num % 3 == 0:
				num = num % 3
				result.append('YES')
				break
			num -= 7
		if num != 0:
			result.append('NO')
for i in range(n):
	print(result[i])


freq = input()
tiga = [x * 3 for x in range(34)]
tujuh = [x * 7 for x in range(15)]
kombin = [x + y for x in tiga[1:] for y in tujuh[1:]]
semua = set(tiga) | set(tujuh) | set(kombin)
for i in range(int(freq)):
	n = input()
	if int(n) in semua:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	b = int(input())
	if b < 3:
		print('NO')
	elif b == 8 or b == 5 or b == 11 or (b == 4):
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	x = int(input())
	a = 0
	ok = False
	while 7 * a <= x:
		if (x - 7 * a) % 3 == 0:
			print('YES')
			ok = True
			break
		a += 1
	if not ok:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	f = 0
	tr = [i for i in range(34)]
	se = [i for i in range(15)]
	for j in range(len(se)):
		for k in range(len(tr)):
			if 3 * tr[k] + 7 * se[j] == n:
				print('YES')
				f = 1
				break
		if f == 1:
			break
	if f == 0:
		print('NO')


n = int(input())
for _ in range(n):
	x = int(input())
	if x % 3 == 0:
		print('YES')
	elif x % 7 == 0:
		print('YES')
	else:
		d = x // 7
		f = 0
		for i in range(d + 1):
			val = i * 7
			if (x - val) % 3 == 0:
				f = 1
				print('YES')
				break
		if f == 0:
			print('NO')


def check(x):
	if x < 3:
		return False
	if x == 3:
		return True
	if x % 7 == 0:
		return True
	if x % 3 == 0:
		return True
	else:
		return check(x - 3)
n = int(input())
for _ in range(n):
	x = int(input())
	if check(x):
		print('YES')
	else:
		print('NO')


teCas = int(input())
lisIn = []
while teCas > 0:
	lisIn.append(int(input()))
	teCas -= 1

def solve(n):
	if n % 3 == 0 or n % 7 == 0 or n % 7 % 3 == 0:
		print('YES')
		return
	else:
		while n > 0:
			n -= 3
			if n > 0 and n % 7 == 0:
				print('YES')
				return
	print('NO')
for i in lisIn:
	solve(i)


a = int(input())
for i in range(a):
	b = int(input())
	for i in range(0, b):
		if b - 3 * i >= 0 and (b - 3 * i) % 7 == 0:
			print('YES')
			break
	else:
		print('NO')


for _ in range(int(input())):
	inp = int(input())
	if inp % 7 == 0 or inp % 3 == 0:
		print('YES')
	elif inp < 3:
		print('NO')
	else:
		for x in range(1, inp):
			if inp - 7 * x >= 0:
				if (inp - 7 * x) % 3 == 0:
					print('YES')
					break
			else:
				print('NO')
				break


def validator(chunk: int) -> int:
	for i in range(101):
		for j in range(101):
			if 7 * i + 3 * j == chunk:
				print('YES')
				return 0
	print('NO')
	return 1
test_case = int(input())
for i in range(test_case):
	validator(int(input()))


import math

def getAns(x):
	a = 0
	b = 0
	while b < x / 7 + 1:
		a = (x - 7 * b) / 3
		if a % 1 == 0.0 and a >= 0:
			return 'YES'
		b += 1
	return 'NO'
t = int(input())
for x in range(t):
	x = int(input())
	if x < 3:
		print('NO')
	else:
		print(getAns(x))


import math
n = int(input())
for i in range(n):
	x = int(input())
	for j in range(math.floor(x / 7) + 1):
		if (x - j * 7) % 3 == 0:
			print('YES')
			x = -1
			break
	if x % 3 == 0 and x != -1:
		print('YES')
	elif x != -1:
		print('NO')


def solve(x):
	for b in range(15):
		if 7 * b > x:
			break
		if (x - 7 * b) % 3 == 0:
			return True
	return False
n = int(input())
for i in range(n):
	x = int(input())
	if solve(x) == True:
		print('YES')
	else:
		print('NO')


isPos = [False for _ in range(100 + 1)]
isPos[0] = True
for i in range(100 + 1):
	if isPos[i]:
		if i + 3 <= 100:
			isPos[i + 3] = True
		if i + 7 <= 100:
			isPos[i + 7] = True
tc = int(input())
for _ in range(tc):
	x = int(input())
	if isPos[x]:
		print('YES')
	else:
		print('NO')


n = int(input())
no = [1, 2, 4, 5, 8, 11]
for i in range(n):
	t = int(input())
	if t not in no:
		print('YES')
	else:
		print('NO')


import sys
import math
input = sys.stdin.readline
for _ in range(int(input())):
	x = int(input())
	found = False
	for b in range(0, x):
		if (x - 7 * b) % 3 == 0 and x - 7 * b >= 0:
			found = True
			break
	print('YES') if found else print('NO')


size = int(input())
i = 0
num = []
while i < size:
	num.append(int(input()))
	i += 1
i = 0
while i < size:
	if num[i] == 1 or num[i] == 2 or num[i] == 4 or (num[i] == 5) or (num[i] == 8) or (num[i] == 11):
		print('NO')
	else:
		print('YES')
	i += 1


import sys
import math
import os
from collections import Counter
n = sys.stdin.readline()
n = int(n)
for i in range(n):
	x = int(sys.stdin.readline())
	did = False
	for a in range(30):
		for b in range(15):
			if x == a * 3 + b * 7:
				did = True
	if did:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	x = int(input())
	flag = 0
	for i in range(x):
		for j in range(x):
			if 3 * i + 7 * j == x:
				ans = 'YES'
				flag = 1
				break
	if flag == 0:
		print('NO')
	else:
		print('YES')


n = int(input())
for _ in range(n):
	m = int(input())
	valid = False
	for i in range(m // 3 + 1):
		s = m - 3 * i
		if s >= 0 and s % 7 == 0:
			print('YES')
			valid = True
			break
	if not valid:
		print('NO')


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping
from itertools import groupby as gb
from fractions import Fraction as fr

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

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

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

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 get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))

def ceildiv(x, y):
	return (x + y - 1) // y

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

def li():
	return list(map(int, input().split()))
n = int(input())
while n:
	n -= 1
	x = int(input())
	if x % 3 == 0 or x % 7 == 0:
		print('YES')
	else:
		ch = 1
		for i in range(1, 101):
			ss = i * 3
			if (x - ss) % 7 == 0 and x - ss > 0:
				ch = 0
				print('YES')
				break
			if x - ss < 0:
				break
		if ch:
			print('NO')


n = int(input())
l = []
for i in range(n):
	l.append(int(input()))
for i in range(len(l)):
	if l[i] % 7 == 0 or l[i] % 3 == 0 or l[i] == 10:
		print('YES')
	elif l[i] > 11:
		print('YES')
	else:
		print('NO')


n = int(input())
answers = []
for i in range(n):
	current = int(input())
	if current % 3 == 0:
		answers.append('YES')
	elif current % 7 == 0:
		answers.append('YES')
	else:
		answer = 'NO'
		for j in range(1, 100 + 2):
			for k in range(1, 100 + 2):
				if j * 3 + k * 7 == current:
					answer = 'YES'
					break
			if answer == 'YES':
				break
		answers.append(answer)
for item in answers:
	print(item)


for i in range(int(input())):
	opx = int(input())
	while 1:
		if opx % 7 == 0 or opx % 3 == 0:
			print('YES')
			break
		elif opx >= 10:
			opx -= 7
		else:
			print('NO')
			break


n = int(input())
for i in range(0, n):
	m = int(input())
	flag = False
	for j in range(0, m // 3 + 1):
		if (m - 3 * j) % 7 == 0:
			flag = True
	if flag:
		print('YES')
	else:
		print('NO')