You are playing a variation of game 2048. Initially you have a multiset $s$ of $n$ integers. Every integer in this multiset is a power of two. 

You may perform any number (possibly, zero) operations with this multiset.

During each operation you choose two equal integers from $s$, remove them from $s$ and insert the number equal to their sum into $s$.

For example, if $s = \{1, 2, 1, 1, 4, 2, 2\}$ and you choose integers $2$ and $2$, then the multiset becomes $\{1, 1, 1, 4, 4, 2\}$.

You win if the number $2048$ belongs to your multiset. For example, if $s = \{1024, 512, 512, 4\}$ you can win as follows: choose $512$ and $512$, your multiset turns into $\{1024, 1024, 4\}$. Then choose $1024$ and $1024$, your multiset turns into $\{2048, 4\}$ and you win.

You have to determine if you can win this game.

You have to answer $q$ independent queries.


-----Input-----

The first line contains one integer $q$ ($1 \le q \le 100$) – the number of queries.

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

The second line of each query contains $n$ integers $s_1, s_2, \dots, s_n$ ($1 \le s_i \le 2^{29}$) — the description of the multiset. It is guaranteed that all elements of the multiset are powers of two. 


-----Output-----

For each query print YES if it is possible to obtain the number $2048$ in your multiset, and NO otherwise.

You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).


-----Example-----
Input
6
4
1024 512 64 512
1
2048
3
64 512 2
2
4096 4
7
2048 2 2048 2048 2048 2048 2048
2
2048 4096

Output
YES
YES
NO
NO
YES
YES



-----Note-----

In the first query you can win as follows: choose $512$ and $512$, and $s$ turns into $\{1024, 64, 1024\}$. Then choose $1024$ and $1024$, and $s$ turns into $\{2048, 64\}$ and you win.

In the second query $s$ contains $2048$ initially.

Difficulty: EASY
Tags: Complete search

Mathematics

Greedy algorithms
Skill types: Complete search

Greedy algorithms

Starter code:

Solutions:
q = int(input())
for i in range(q):
	n = int(input())
	lst = list(map(int, input().split()))
	x = [j for j in lst if j < 2049]
	if sum(x) >= 2048:
		print('YES')
	else:
		print('NO')


from sys import stdin
input = stdin.readline
from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	if 2048 in lis:
		print('YES')
		continue
	for i in range(n):
		if lis[i] > 2048:
			lis[i] = -1
	while -1 in lis:
		lis.remove(-1)
	d = defaultdict(int)
	for i in lis:
		d[i] += 1
	while True:
		l = sorted(d)
		for i in l:
			if d[i] > 1:
				x = d[i] // 2
				d[i] = 1
				d[2 * i] += x
				break
		else:
			break
		if l[-1] > 2048:
			break
	if d[2048] > 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = [int(x) for x in l if x <= 2048]
	if l.count(2048) > 0:
		print('YES')
	elif sum(l1) >= 2048:
		print('YES')
	else:
		print('NO')


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	d = defaultdict(int)
	for i in s:
		d[i] += 1
	j = 1
	while j < 2048:
		d[2 * j] += d[j] // 2
		j *= 2
	if d[2048] != 0:
		print('YES')
	else:
		print('NO')


import sys
query_num = int(sys.stdin.readline())
for i in range(query_num):
	elem_num = int(sys.stdin.readline())
	lst = sys.stdin.readline().split()
	for k in range(elem_num):
		lst[k] = int(lst[k])
	step_var = 1
	curr_val = 1
	num = 0
	res = 0
	while step_var:
		for x in lst:
			if x == curr_val:
				num += 1
				if curr_val == 2048:
					res = 1
					step_var = 0
					break
				if num == 2:
					lst.remove(curr_val)
					lst.remove(curr_val)
					lst.append(2 * curr_val)
					if curr_val == 1024:
						res = 1
					break
		if num < 2:
			curr_val *= 2
		if curr_val == 4096:
			if num > 0:
				res = 1
			step_var = 0
		num = 0
	if res == 0:
		print('NO')
	else:
		print('YES')


import math
import itertools
import collections

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

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

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

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

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

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

def wr(arr):
	return ' '.join(map(str, arr))

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

def revn(n):
	m = 0
	while n > 0:
		m = m * 10 + n % 10
		n = n // 10
	return m
q = ii()
for i in range(q):
	n = ii()
	a = li()
	newa = []
	for j in range(n):
		if a[j] < 2049:
			newa.append(a[j])
	if sum(newa) > 2047:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	d = {}
	for i in range(0, 13):
		d[2 ** i] = 0
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	for i in lst:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	for i in sorted(d.keys()):
		f = d[i] // 2
		if f == 0:
			continue
		if 2 * i not in d:
			d[2 * i] = 0
		d[2 * i] += f
	if 2048 in d and d[2048] >= 1:
		print('YES')
	else:
		print('NO')


for q in range(int(input())):
	n = input()
	data = [int(i) for i in input().split()]
	dic = {}
	for i in range(30):
		dic[1 << i] = i
	cnt = [0] * 31
	for d in data:
		cnt[dic[d]] += 1
	for i in range(11):
		cnt[i + 1] += cnt[i] // 2
	if cnt[11]:
		print('YES')
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections
import math
for j in range(int(input())):
	n = int(input())
	vals = list(map(int, input().split()))
	vals.sort()
	dict1 = collections.defaultdict(int)
	for s in range(n):
		power = math.log2(vals[s])
		dict1[power] += 1
	count = 1
	found = False
	for s in range(11, -1, -1):
		if dict1[s] >= count:
			found = True
			break
		else:
			count = 2 * (count - dict1[s])
	if found == True:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	s = [int(x) for x in input().split()]
	s = [x for x in s if x <= 2048]
	if sum(s) >= 2048:
		print('YES')
	else:
		print('NO')


import sys
for i in sys.stdin:
	for j in range(int(i.strip('\n'))):
		input()
		if sum(filter(lambda n: n <= 2048, map(int, input().split()))) >= 2048:
			print('YES')
		else:
			print('NO')


n = int(input())
for i in range(n):
	length = int(input())
	nums = list(input().split(' '))
	for j in range(len(nums)):
		nums[j] = int(nums[j])
	valid = False
	while not valid:
		nums.sort(reverse=True)
		for j in range(len(nums)):
			num = nums[j]
			if 2048 in nums:
				print('YES')
				valid = True
				break
			if j == len(nums) - 1:
				print('NO')
				valid = True
				break
			if nums.count(num) >= 2:
				for k in range(2):
					nums.pop(nums.index(num))
				nums.append(num * 2)
				break


def csa(number, multiset, original):
	for k in range(number):
		if multiset[k] <= 2048:
			original += multiset[k]
	if original < 2048:
		print('NO')
	else:
		print('YES')
lxz = int(input())
for m in range(lxz):
	y = int(input())
	a = [int(x) for x in input().split()]
	q = 0
	csa(y, a, q)


q = int(input())
for _ in range(q):
	n = int(input())
	arr = [int(x) for x in input().split() if int(x) <= 2048]
	print('Yes' if sum(arr) >= 2048 else 'No')


def solve(arr, n):
	nums = {}
	for i in range(30):
		nums[2 ** i] = 0
	for i in arr:
		nums[i] += 1
	for i in range(29):
		nums[2 ** (i + 1)] += nums[2 ** i] // 2
	if nums[2048] > 0:
		print('yes')
		return
	print('no')

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


u = []
a = int(input())
for i in range(a):
	b = int(input())
	c = list(map(int, input().split()))
	c.sort()
	t = 0
	if c[0] == 2048:
		t = 1
	for f in range(b):
		for j in range(b - 1):
			if c[j] == 2048 or c[j + 1] == 2048:
				t = 1
			if c[j] == c[j + 1]:
				c[j] *= 2
				c[j + 1] = 0
		c.sort()
	if t == 1:
		u.append('YES')
	else:
		u.append('NO')
for i in range(a):
	print(u[i])


q = int(input())
for _ in range(q):
	n = int(input())
	ar = sorted(list(map(lambda x: int(x), input().split())))
	flag = False
	i = 0
	while i < len(ar) and ar[i] <= 2048:
		i += 1
	ar = ar[:i]
	if sum(ar) >= 2048:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = 1
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	hm = {}
	for i in a:
		if i > 2048:
			continue
		hm[i] = hm.get(i, 0) + 1
	curr = 1
	flag = 0
	while curr <= 2048:
		if hm.get(curr, 0) * curr >= 2048:
			flag = 1
			break
		prev = hm.get(curr, 0)
		curr = curr << 1
		hm[curr] = hm.get(curr, 0) + prev // 2
	if flag:
		print('YES')
	else:
		print('NO')


def funk(a: list):
	s = 0
	for i in a:
		if i == 2048:
			return 'YES'
		elif i < 2048:
			s += i
			if s >= 2048:
				return 'YES'
	return 'NO'
for z in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(funk(a))


q = int(input())
for i in range(q):
	n = int(input())
	set = list(map(int, input().split()))
	sums = 0
	output = 'NO'
	for j in range(n):
		if set[j] == 2048:
			output = 'YES'
			break
		elif set[j] < 2048:
			sums += set[j]
	if sums >= 2048:
		output = 'YES'
	print(output)


from collections import Counter
input_len = int(input().strip())
result = []
for i in range(input_len):
	xxxxx = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
	yyyyy = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]
	flag = False
	n = int(input().strip())
	test_cases = input().strip().split()
	test_cases = map(int, test_cases)
	count_dict = dict(Counter(test_cases))
	for j in range(len(xxxxx) - 1, -1, -1):
		value = count_dict.get(xxxxx[j], 0)
		if value == 0:
			yyyyy[j - 1] = int((yyyyy[j] - 0) * 2)
			continue
		elif value >= yyyyy[j]:
			flag = True
			break
		else:
			yyyyy[j - 1] = int((yyyyy[j] - value) * 2)
	result.append(flag)
for item in result:
	if item:
		print('YES')
	else:
		print('NO')


import collections
t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().strip().split(' ')))
	if lst.count(2048) >= 1:
		print('yes')
	elif lst.count(1024) >= 2:
		print('yes')
	else:
		a1 = lst.count(1)
		a2 = lst.count(2) + a1 // 2
		a3 = lst.count(4) + a2 // 2
		a4 = lst.count(8) + a3 // 2
		a5 = lst.count(16) + a4 // 2
		a6 = lst.count(32) + a5 // 2
		a7 = lst.count(64) + a6 // 2
		a8 = lst.count(128) + a7 // 2
		a9 = lst.count(256) + a8 // 2
		a10 = lst.count(512) + a9 // 2
		a11 = lst.count(1024) + a10 // 2
		a12 = lst.count(2048) + a11 // 2
		if a12 >= 1:
			print('yes')
		else:
			print('no')


def solve(data):
	dic = {}
	for num in data:
		if num == 2048:
			return True
		elif num < 2048:
			dic.setdefault(num, 0)
			dic[num] += 1
	while dic:
		if dic.get(2048):
			return True
		k = min(dic)
		if k > 2048:
			return False
		next_k = k * 2
		dic.setdefault(next_k, 0)
		while dic[k] >= 2:
			dic[k] -= 2
			dic[next_k] += 1
		dic.pop(k)
	return False
tests = int(input())
for _ in range(tests):
	num = input()
	data = [int(x) for x in input().split()]
	res = solve(data)
	if res:
		print('YES')
	else:
		print('NO')


t = int(input())
for nt in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	new = []
	for i in l:
		if i <= 2048:
			new.append(i)
	new.sort()
	if 2048 in new:
		print('YES')
	else:
		s = 0
		flag = 0
		for i in range(len(new) - 1, -1, -1):
			s += new[i]
			if s == 2048:
				print('YES')
				flag = 1
				break
		if flag == 0:
			print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	numbers = list(map(int, input().split(' ')))
	if 2048 in numbers:
		print('YES')
	else:
		numbers.sort()
		if max(numbers) > 1024:
			for j in range(len(numbers)):
				if numbers[j] > 1024:
					numbers = numbers[:j]
					break
		results = sum(numbers)
		if results >= 2048:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	n = int(input())
	lst = filter(lambda x: x <= 2048, map(int, input().split()))
	print('yes' if sum(lst) >= 2048 else 'no')


p = int(input())
for i in range(p):
	n = int(input())
	l = input().split()
	if '2048' in l:
		print('YES')
		continue
	count = 0
	for j in range(n):
		if int(l[j]) < 2048:
			count += int(l[j])
	if count >= 2048:
		print('YES')
	else:
		print('NO')


import collections
stdin = lambda type_='int', sep=' ': list(map(eval(type_), input().split(sep)))
q = int(input())
for _ in range(q):
	_ = int(input())
	nums = stdin()
	counts = collections.Counter(nums)
	i = 1
	while i <= 1024:
		counts[i * 2] += counts[i] // 2
		i *= 2
	print('YES' if 2048 in counts and counts[2048] > 0 else 'NO')


n = int(input())
for i in range(n):
	input()
	l = [int(i) for i in input().split()]
	sum = 0
	if 2048 in l:
		print('YES')
	else:
		for i in l:
			if i < 2048:
				sum += i
			else:
				sum += 0
		if sum >= 2048:
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	s = 0
	for j in a:
		if j <= 2048:
			s += j
		if s == 2048:
			print('YES')
			break
	else:
		print('NO')


q = int(input())
for tmp in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	s = [i for i in s if i <= 2048]
	s = sorted(s, reverse=False)
	i = len(s) - 1
	flag = True
	if 2048 not in s:
		flag = False
		while True:
			t = 0
			for j in range(len(s) - 1, 0, -1):
				if s[j] == s[j - 1]:
					t += 1
					s.pop(j)
					s[j - 1] *= 2
					j -= 1
				if 2048 in s:
					flag = True
					break
			if t == 0 and (not flag) or flag:
				break
	if flag:
		print('YES')
	else:
		print('NO')


T = int(input())
for i in range(0, T):
	n = int(input())
	arr = [int(i) for i in input().strip().split()]
	a = []
	for i in range(len(arr)):
		if arr[i] <= 2048:
			a.append(arr[i])
	res = 2048
	if res in a:
		print('YES')
	elif len(a) == 0:
		print('NO')
	elif len(a) == 1:
		print('NO')
	elif len(a) == 2:
		if res in a:
			print('YES')
		elif sum(a) == res:
			print('YES')
		else:
			print('NO')
	else:
		a.sort()
		count = 0
		for i in range(len(a) - 1):
			a.sort()
			count = count + 1
			if a[i] == a[i + 1]:
				a[i + 1] = 2 * a[i]
				a[i] = 0
				if res in a:
					print('YES')
					break
			if count == len(a) - 1:
				print('NO')


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	x = [i for i in s if i <= 2048]
	if sum(x) >= 2048:
		print('YES')
	else:
		print('NO')


from sys import setcheckinterval, stdin, setrecursionlimit
setcheckinterval(1000)
setrecursionlimit(10 ** 7)

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

def lin():
	return list(map(int, stdin.readline().split()))
for _ in range(iin()):
	n = iin()
	a = lin()
	a.sort(reverse=True)
	sol = 0
	i = 0
	while i < n:
		if sol == 2048:
			print('YES')
			break
		elif sol > 2048:
			sol -= a[i - 1]
		if a[i] <= 2048:
			sol += a[i]
		i += 1
	else:
		if sol == 2048:
			print('YES')
		else:
			print('NO')


q = int(input())
l = []
for _ in range(q):
	n = int(input())
	l = filter(lambda x: x <= 2048, map(int, input().split()))
	if sum(l) >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum([i for i in a if i <= 2048])
	if s >= 2048:
		print('yes')
	else:
		print('no')


def func(n, li):
	if 2048 in li:
		return 1
	else:
		li = sorted(li)
		x = 0
		sumo = 0
		for i in range(0, len(li)):
			sumo += li[i]
			if sumo > 2048:
				while sumo > 2048:
					sumo -= li[x]
					x += 1
			if sumo == 2048:
				return 1
		if sumo == 2048:
			return 1
	return 0
q = int(input())
for _ in range(0, q):
	n = int(input())
	li = list(map(int, input().split(' ')))
	x = func(n, li)
	if x == 1:
		print('YES')
	else:
		print('NO')


def zzz(x):
	l = []
	for num in x:
		if num not in l:
			l.append(num)
		else:
			l.remove(num)
			l.append(num * 2)
	return l
for i in range(int(input())):
	input()
	l = list(map(int, input().split()))
	while 2048 not in l and zzz(l) != l:
		l = zzz(l)
	print(['YES', 'NO'][2048 not in l])


def make_dict(di, array):
	di.clear()
	for x in array:
		if x not in di:
			di[x] = 1
		else:
			di[x] += 1

def multiple_present(dic):
	for j in dic.values():
		if j > 1:
			return 1
	return 0

def game(res):
	T = int(input())
	while T > 0:
		T -= 1
		d = {}
		n = int(input())
		arr = list(map(int, input().split()))
		if n == 1 and arr[0] == 2048:
			res.append('YES')
			continue
		make_dict(d, arr)
		while multiple_present(d) and 2048 not in arr:
			for i in range(len(arr) - 1):
				if arr[i] in arr[i + 1:]:
					boo = arr[i]
					arr.pop(i)
					index = arr.index(boo)
					arr[index] += arr[index]
					make_dict(d, arr)
					break
		if 2048 in arr:
			res.append('YES')
		else:
			res.append('NO')
result = []
game(result)
for c in result:
	print(c)


for i in range(int(input())):
	o = int(input())
	otv = filter(lambda x: x <= 2048, map(int, input().split()))
	if sum(otv) >= 2048:
		print('YES')
	else:
		print('NO')


import collections
q = int(input())
for _ in range(q):
	n = int(input())
	S = collections.Counter([int(i) for i in input().split()])
	chk = False
	rem = 2048
	for i in reversed(range(12)):
		rem -= S[2 ** i] * 2 ** i
		if rem <= 0:
			chk = True
			break
	print('YES' if chk else 'NO')


for i in range(int(input())):
	n = int(input())
	a = filter(lambda x: x <= 2048, map(int, input().split()))
	if sum(a) >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	for j in range(11):
		while s.count(2 ** j) > 1:
			s.remove(2 ** j)
			s.remove(2 ** j)
			s.append(2 ** (j + 1))
	if 2048 in s:
		print('YES')
	else:
		print('NO')


q = int(input())
while q:
	q -= 1
	n = int(input())
	se = list(map(int, input().split()))
	se.sort()
	if 2048 in se:
		print('YES')
		continue
	ans = 0
	for i in [2 ** x for x in range(0, 12)]:
		if i not in se:
			continue
		ans += se.count(i) // 2 * i * 2
		for j in range(se.count(i) // 2):
			se.append(i * 2)
		for j in range(se.count(i) // 2 * 2):
			se.remove(i)
		if 2048 in se:
			print('YES')
			break
	if not 2048 in se:
		print('NO')


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	mp = {}
	for i in range(12):
		tmp = 2 ** i
		mp[tmp] = 0
	for i in a:
		if i <= 2048:
			mp[i] += 1
	for i in range(11):
		tmp = 2 ** i
		tmp1 = 2 * tmp
		mp[tmp1] += mp[tmp] // 2
	if mp[2048] > 0:
		print('YES')
	else:
		print('NO')
	t -= 1


n = int(input())
for i in range(n):
	l = int(input())
	s = list(str(input()).split())
	s = [int(i) for i in s]

	def findRepeatedNum(s):
		for i in range(len(s)):
			e = s[i]
			if e in s[i + 1:]:
				position = s[i + 1:].index(e)
				return (i, i + 1 + position)
	if 2048 in s:
		print('YES')
		continue
	while findRepeatedNum(s) is not None:
		(i, j) = findRepeatedNum(s)
		s[j] = 2 * s[j]
		s.remove(s[i])
		if 2048 in s:
			print('YES')
			s = []
			continue
	if s != []:
		print('NO')


t = int(input())
s = []
for ide in range(0, t):
	n = int(input())
	x = input().split()
	r = {1: 0, 2: 0, 4: 0, 8: 0, 16: 0, 32: 0, 64: 0, 128: 0, 256: 0, 512: 0, 1024: 0, 2048: 0}
	for i in x:
		i = int(i)
		if i in r:
			r[i] += 1
	for i in r:
		if i < 2048:
			xx = r[i] // 2
			yy = r[i] % 2
			r[i * 2] += xx
			r[i] = yy
	if r[2048] != 0:
		s.append('YES')
	else:
		s.append('NO')
for i in s:
	print(i)


import collections
q = int(input())
for _ in range(q):
	n = int(input())
	A = [int(x) for x in input().split()]
	Dict = collections.Counter(A)
	B = list(set(A))
	B.sort()
	for i in range(1, len(B)):
		Dict[B[i]] += Dict[B[i - 1]] // (B[i] // B[i - 1])
	flag = 0
	for i in range(11, -1, -1):
		if Dict.get(2 ** i, 0) >= 2048 // 2 ** i:
			print('YES')
			flag = 1
			break
	if flag == 0:
		print('NO')


q = int(input())
for _ in range(q):
	n = input()
	a = map(int, input().split())
	s = 0
	for x in a:
		if x <= 2048:
			s += x
	if s >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
n = [None] * q
s = [[]] * q
for i in range(q):
	n[i] = int(input())
	s[i] = list(map(int, input().split()))
for i in range(q):
	if sum([j for j in s[i] if j <= 2048]) >= 2048:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split(' ')))
	l.sort()
	sum = 0
	req = 'NO'
	for i in range(len(l) - 1, -1, -1):
		if l[i] > 2048:
			continue
		else:
			sum += l[i]
			if sum >= 2048:
				req = 'YES'
				break
	print(req)


def f(l):
	cnt = 0
	for i in l:
		if i <= 2048:
			cnt = cnt + i
	if cnt >= 2048:
		print('YES')
	else:
		print('NO')
n = int(input())
for i in range(n):
	s = int(input())
	l = list(map(int, input().split()))
	f(l)


q = int(input())
Ans = []
for i in range(q):
	n = int(input())
	S = [int(x) for x in input().split()]
	for j in range(11):
		if S.count(2 ** j) >= 2:
			for _ in range(S.count(2 ** j) // 2):
				S.remove(2 ** j)
				S.remove(2 ** j)
				S.append(2 ** (j + 1))
	if 2048 in S:
		Ans.append('YES')
	else:
		Ans.append('NO')
for x in Ans:
	print(x)


from math import log
q = int(input())
for i in range(q):
	pl = int(input())
	qw = [int(i) for i in input().split()]
	w2048 = [0 for i in range(12)]
	for u in range(pl):
		if qw[u] <= 2048:
			w2048[int(log(qw[u], 2))] += 1
	for u in range(11):
		w2048[u + 1] += w2048[u] // 2
	if w2048[-1] != 0:
		print('YES')
	else:
		print('NO')


import math
for q in range(int(input())):
	n = int(input())
	s = [*map(lambda x: int(math.log2(int(x))), input().split())]
	done = False
	Arr = [0] * 14
	for a in s:
		if a < 13:
			Arr[a] += 1
	if Arr[11] > 0:
		done = True
	else:
		for i in range(13):
			Arr[i] += Arr[i - 1] // 2
		if Arr[11] > 0:
			done = True
	if done:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = input()
	print('yes' if sum([int(x) for x in input().split() if int(x) <= 2048]) >= 2048 else 'no')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = [i for i in a if i <= 2048]
	b.sort(reverse=True)
	s = 0
	f = 0
	for j in b:
		s += j
		if s == 2048:
			print('YES')
			f = 1
			break
	if not f:
		print('NO')


def A(s):
	m = 2048
	if m in s:
		print('YES')
		return
	i = 0
	j = 0
	while i < len(s):
		if s.count(s[i]) > 1:
			s[i] = s[i] * 2
			s.remove(s[i] // 2)
			j += 1
		i += 1
	if j == 0:
		print('NO')
		return
	A(s)
q = int(input())
for i in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	A(s)


import sys

def fun(item_list):
	index = {}
	for item in item_list:
		index.setdefault(item, 0)
		index[item] += 1
	if 2048 in index:
		return 'YES'
	res = ''
	while 1:
		answer = 3
		count = 0
		for (k, num_len) in index.items():
			if num_len >= 2:
				weight = 2 * k
				if weight == 2048:
					answer = 1
					res = 'YES'
				index[k] -= 2
				if weight in index:
					index[weight] += 1
				else:
					index[weight] = 1
				break
			else:
				count += 1
		if count == len(index):
			answer = 0
			res = 'NO'
		if answer != 0 and answer != 1:
			continue
		else:
			break
	return res
count = 0
for line in sys.stdin:
	if count == 0:
		num_tmp = int(line.strip())
		count += 1
		continue
	if count % 2 == 1:
		count += 1
		continue
	num_list = [int(i) for i in line.strip().split(' ')]
	print(fun(num_list))
	count += 1


q = int(input())
for i in range(q):
	input()
	s = list(map(int, input().split()))
	tmp = []
	for j in s:
		if j <= 2048:
			tmp.append(j)
	if sum(tmp) >= 2048:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	summ = 0
	x = int(input())
	li = list(map(int, input().split()))
	if len(li) == x:
		for j in li:
			if j <= 2048:
				summ += j
		if summ >= 2048:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	l = []
	f = 0
	s = 0
	for i in range(n):
		if li[i] == 2048:
			print('YES')
			f = 1
			break
		elif li[i] < 2048:
			s += li[i]
		if s >= 2048:
			f = 1
			print('YES')
			break
	if f == 1:
		continue
	else:
		print('NO')


from sys import stdin, stdout
import math
t = int(stdin.readline())
while t != 0:
	t -= 1
	n = int(stdin.readline())
	l = [int(x) for x in stdin.readline().split()]
	l.sort()
	s = 0
	for n in l:
		if n > 2048:
			break
		s += n
		if s >= 2048:
			break
	if s >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	s = list(map(int, input().strip().split()))[:n]
	f = 0
	if s.count(2048) >= 1:
		f = 1
	else:
		s.sort()
		j = 0
		while j < n - 1:
			z = j + 1
			if s[j] == s[z]:
				b = s[j] + s[z]
				s.remove(s[j])
				s.remove(s[j])
				s.append(b)
				s.sort()
				n = len(s)
				if s.count(2048) >= 1:
					f = 1
					break
			else:
				j = j + 1
	if f == 1:
		print('YES')
	if f == 0:
		print('NO')


n = int(input())
for i in range(n):
	k = int(input())
	num = input()
	l = [int(n) for n in num.split()]
	if 2048 in l:
		print('YES')
	else:
		for i in l[:]:
			if i > 2048:
				l.remove(i)
		b = sum(l)
		if b >= 2048:
			print('YES')
		else:
			print('NO')


tc = int(input())
for T in range(1, tc + 1):
	N = int(input())
	arr = list(map(int, input().split()))
	chk = [0] * 12
	nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
	if 2048 in arr:
		print('YES')
	else:
		for num in arr:
			if num <= 2048:
				chk[nums.index(num)] += 1
		for i in range(11):
			chk[i + 1] += chk[i] // 2
		if chk[-1] > 0:
			print('YES')
		else:
			print('NO')


q = eval(input())
for i in range(q):
	n = eval(input())
	L = input().split()
	s = sum([int(x) * (int(x) <= 2048) for x in L])
	if s >= 2048:
		print('YES')
	else:
		print('No')


import datetime
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if 2048 in arr:
		print('YES')
	else:
		arr.sort()
		while True:
			flag = 0
			for i in range(0, len(arr) - 1):
				if arr[i] == arr[i + 1]:
					arr[i] += arr[i + 1]
					flag = 1
					arr.pop(i + 1)
					break
			arr.sort()
			if flag == 0:
				if 2048 in arr:
					print('YES')
					break
				else:
					print('NO')
					break
			elif 2048 in arr:
				print('YES')
				break


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	arr = filter(lambda a: a <= 2048, map(int, input().split()))
	print('YES' if sum(arr) >= 2048 else 'NO')


total = int(input())
for i in range(total):
	n = int(input())
	datas = list(map(int, input().split()))
	dic = dict()
	for data in datas:
		if dic.get(data) == None:
			dic[data] = 1
		else:
			dic[data] += 1
	if dic.get(2048) != None:
		answer = 'Yes'
	while True:
		is_ok = False
		for d in dic:
			if dic[d] >= 2:
				if dic.get(d * 2) == None:
					dic[d * 2] = 1
				else:
					dic[d * 2] += 1
				dic[d] -= 2
				is_ok = True
				break
		if is_ok == False:
			break
	if dic.get(2048) != None:
		answer = 'YES'
	else:
		answer = 'NO'
	print(answer)


t = int(input())
for i in range(t):
	n = int(input())
	numbers = sorted(list(map(int, input().split())))
	numbers.sort(reverse=True)
	j = 0
	while j < n:
		if len(numbers) == 0:
			break
		if numbers[j] > 2048:
			numbers.remove(numbers[j])
		else:
			break
	s = sum(numbers)
	if s >= 2048:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	true = True
	worthless = int(input())
	string = [int(i) for i in input().split()]
	mnogh = set(string)
	while len(string) != len(mnogh) and true:
		lst = [0 for i in range(len(mnogh))]
		for i in range(len(string)):
			if 2048 in lst:
				true = False
				break
			if string[i] not in lst:
				lst.append(string[i])
			else:
				lst[lst.index(string[i])] += string[i]
		for i in range(lst.count(0)):
			lst.remove(0)
		string = [i for i in lst]
		mnogh = set(string)
	if 2048 in string:
		print('yes')
	else:
		print('no')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	s = sum(arr)
	arr.sort()
	start = 0
	if s < 2048:
		print('NO')
	elif 2048 in arr:
		print('YES')
	elif s == 2048:
		print('YES')
	else:
		newarr = []
		for i in arr:
			if i < 2048:
				newarr.append(i)
		if sum(newarr) >= 2048:
			print('YES')
		else:
			print('NO')


from sys import stdout, stdin
ans = []
for i in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, stdin.readline().split())))
	while True:
		if len(a) == 1 or a[0] == 2048:
			break
		elif a[0] == a[1]:
			a[1] += a[0]
		del a[0]
		a.sort()
	ans.append('yes' if a[0] == 2048 else 'no')
stdout.write('\n'.join(ans))


import math, sys
from collections import Counter, defaultdict
from sys import stdin, stdout
lili = lambda : list(map(int, sys.stdin.readlines()))
li = lambda : list(map(int, input().split()))
q = int(input())
for i in range(0, q):
	n = int(input())
	a = li()
	a.sort()
	i = 0
	while len(set(a)) != len(a):
		i = 0
		a.sort()
		if 2048 in a:
			break
		while i < len(a) - 1:
			if 2048 in a:
				break
			if a[i] == a[i + 1]:
				a[i] = a[i] + a[i + 1]
				del a[i + 1]
			else:
				i = i + 1
	if 2048 in a:
		print('YES')
	else:
		print('NO')


import math
q = int(input())
yeah = 'YES'
nil = 'NO'

def solve(a, n):
	count = [0 for i in range(0, 12)]
	for i in range(0, n):
		r = math.log2(a[i])
		r = int(r)
		if r >= 0 and r < 12:
			count[r] += 1
	for i in range(0, 12):
		x = count[i]
		if i + 1 < 12:
			count[i + 1] += int(x / 2)
	if count[11] > 0:
		print(yeah)
	else:
		print(nil)
while q > 0:
	q -= 1
	n = int(input())
	a = list(map(int, input().split()))
	solve(a, n)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = Counter((int(i) for i in input().split()))
	for i in (1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096):
		if i == 2048:
			if l[2048]:
				print('YES')
				break
		l[2 * i] += l[i] // 2
	else:
		print('NO')


def getAllSums(arr, i, ret):
	if i < len(arr):
		els = [0, arr[i]]
		for el in els:
			ret2 = getAllSums(arr, i + 1, ret + el)
			if ret2 == res:
				return ret2
	return ret

def checkParity(arr, arr_un):
	par = [arr.count(el) % 2 for el in arr_un]
	if par.count(1) > 0:
		return 1
	else:
		return 2

def unique(arr):
	checked = []
	for el in arr:
		if checked.count(el) == 0:
			checked.append(el)
	return checked

def solve(arr):
	arr2 = []
	flag = 0
	for el in arr:
		if el < res:
			arr2.append(el)
	if sum(arr2) >= res:
		print('YES')
	elif arr.count(res) > 0:
		print('YES')
	else:
		print('NO')
t = int(input())
res = 2048
for tt in range(0, t):
	n = input()
	arr = [int(el) for el in input().split(' ')]
	solve(arr)


for j in range(int(input())):
	n = int(input())
	x = [int(i) if int(i) <= 2048 else 0 for i in input().split()]
	if sum(x) >= 2048:
		print('YES')
	else:
		print('NO')


ii = lambda : int(input())
kk = lambda : map(int, input().split())
ll = lambda : list(kk())
for _ in range(ii()):
	(n, ls) = (ii(), sorted((k for k in kk() if k <= 2048)))
	n = len(ls)
	prev = 0
	ind = 0
	for i in range(12):
		prev //= 2
		while ind < n and ls[ind] == 2 ** i:
			ind += 1
			prev += 1
	print('yes' if prev else 'no')


from collections import Counter
from operator import itemgetter
Q = int(input())
data = []
for _ in range(Q):
	N = int(input())
	A = list(map(int, input().split()))
	data.append([N, A])
for (N, A) in data:
	A.sort()
	B = list(Counter(A).items())
	B.sort(key=itemgetter(0))
	ok = False
	a = 0
	for (k, n) in B:
		if k == 2048:
			ok = True
		if k < 2048:
			a += k * n
	if a >= 2048 or ok:
		print('YES')
	else:
		print('NO')


q = int(input())
for _q in range(q):
	n = int(input())
	s = map(int, input().split())
	mset = {}
	for _s in s:
		mset[_s] = mset.get(_s, 0) + 1
	for i in (2 ** x for x in range(12)):
		mset[2 * i] = mset.get(2 * i, 0) + mset.get(i, 0) // 2
	print('YES' if mset.get(2048, 0) > 0 else 'NO')


for t in range(int(input())):
	n = input()
	s = input().split()
	l = [int(x) for x in s if int(x) <= 2048]
	print('YES' if sum(l) >= 2048 else 'NO')


def solve(arr):
	dic = {}
	for v in arr:
		curr = v
		if curr == 2048:
			return 'YES'
		while dic.get(curr, 0) > 0:
			tmp = curr
			curr *= 2
			if curr == 2048:
				return 'YES'
			dic[tmp] -= 1
		dic[curr] = 1
	return 'NO'
t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	print(solve(arr))
	t -= 1


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	sim = 0
	if 2048 in s:
		print('yes')
	else:
		for i in range(n):
			if s[i] < 2048:
				sim += s[i]
		if sim >= 2048:
			print('yes')
		else:
			print('no')


for i in range(int(input())):
	n = int(input())
	b = list()
	suma = 0
	a = list(map(int, input().split()))
	for i in a:
		if i <= 2048:
			b.append(i)
	for i in b:
		suma = suma + i
	if suma >= 2048:
		print('yes')
	else:
		print('no')


for cas in range(int(input())):
	n = input()
	a = [int(x) for x in input().split() if int(x) <= 2048]
	print('YES' if sum(a) >= 2048 else 'NO')


Q = int(input())
for _ in range(Q):
	n = int(input())
	bit = [0] * 40
	for num in map(int, input().split()):
		bit[num.bit_length()] += 1
	for i in range(12):
		bit[i + 1] += bit[i] // 2
	print('YES' if bit[12] > 0 else 'NO')


import os, sys
q = int(sys.stdin.readline().strip())
lists = []
for _ in range(q):
	n = int(sys.stdin.readline().strip())
	lists.append(list(reversed(sorted([z for z in map(int, sys.stdin.readline().strip().split()) if z < 3000]))))
numbers = [1 << i for i in range(12)]
dicts = []
for l in lists:
	if sum(l) >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
for query in range(q):
	n = int(input())
	a = list(map(int, input().split(' ')))
	new = []
	flag = 0
	for i in range(n):
		if a[i] <= 1024:
			new.append(a[i])
		elif a[i] == 2048:
			flag = 1
			break
	if flag == 1:
		print('YES')
	else:
		new = sorted(new, reverse=True)
		check = 0
		for i in range(len(new)):
			check += new[i]
			if check == 2048:
				flag = 1
				break
			elif check > 2048:
				flag = 0
				break
		if flag == 1:
			print('YES')
		else:
			print('NO')


def gns():
	return list(map(int, input().split()))
t = int(input())
tb = [1]
for i in range(11):
	tb.append(tb[-1] << 1)
for i in range(t):
	n = int(input())
	ns = gns()
	d = {}
	for i in range(12):
		d[tb[i]] = i
	v = [0] * 12
	for c in ns:
		if c in d:
			v[d[c]] += 1
	for i in range(11):
		v[i + 1] += v[i] // 2
	if v[-1] > 0:
		print('YES')
	else:
		print('NO')


returnList = []
length = int(input())
tempLength = length
tempList = []
while tempLength > 0:
	tempLength -= 1
	number = int(input())
	numbers = input().split()
	for x in numbers:
		x = int(x)
		tempList.append(x)
	tempList.sort(reverse=True)
	counter = 0
	for x in tempList:
		if x >= 4096:
			continue
		counter += x
		if counter == 2048:
			returnList.append('YES')
			break
	if counter != 2048:
		returnList.append('NO')
	tempList.clear()
for x in returnList:
	print('{}'.format(x))


a = int(input())
for i in range(a):
	number = int(input())
	number_str = str(input())
	number_list = [int(n) for n in number_str.split()]
	for k in range(0, 11):
		num = 2 ** k
		m = 0
		for j in range(100):
			if num in number_list:
				number_list.remove(num)
				m = m + 1
		for x in range(m // 2):
			number_list.append(num * 2)
	if 2048 in number_list:
		print('YES')
	else:
		print('NO')


def solve():
	n = int(input())
	a = sorted(list(map(int, input().split())))
	ans = 'NO'
	while True:
		if 2048 in a:
			ans = 'YES'
			break
		changed = False
		for i in range(1, len(a)):
			if a[i - 1] == a[i]:
				changed = True
				a[i - 1] *= 2
				del a[i]
				a.sort()
				break
		if not changed:
			break
	print(ans)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	array = list(map(int, input().split()))
	sums = 0
	for i in range(n):
		if array[i] <= 2048:
			sums += array[i]
		if sums >= 2048:
			break
	if sums >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(0, q):
	n = int(input())
	s = list(map(int, input().split()))
	if 2048 in s:
		print('YES')
	else:
		t = 0
		for j in range(0, 11):
			t1 = s.count(2 ** j) + t
			t = t1 // 2
		if t > 0:
			print('YES')
		else:
			print('NO')


q = int(input())
while q > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	flag = 0
	flag2 = 0
	while flag == 0 and flag2 == 0:
		for i in range(n - 1, -1, -1):
			if arr[i] == 2048:
				print('YES')
				flag = 1
				break
			if i > 0 and arr[i] == arr[i - 1]:
				arr[i] += arr[i]
				arr.pop(i - 1)
				n -= 1
			if i < n - 1 and arr[i] + arr[i + 1] == 2048:
				flag = 1
				print('YES')
				break
		flag2 = 1
		for i in range(n - 1):
			if arr[i] == arr[i + 1]:
				flag2 = 0
				break
	if flag == 0:
		print('NO')
	q -= 1


for _ in range(int(input())):
	n = int(input())
	array = sorted(list(map(int, input().split())), reverse=True)
	if n == 1:
		if array[0] == 2048:
			print('YES')
		else:
			print('NO')
	else:
		sums = 0
		for i in range(n):
			if array[i] <= 2048:
				sums += array[i]
			if sums >= 2048:
				break
		if sums >= 2048:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	n = int(input())
	p = 0
	k = 1
	a = sorted(list(map(int, input().split())))
	if 2048 in a:
		print('YES')
		continue
	for i in a:
		p = p + i
		if p >= 2048 and p < 4096:
			print('YES')
			k = 0
			break
	if k:
		print('NO')


from sys import stdin, setrecursionlimit
setrecursionlimit(10 ** 6)
input = stdin.readline
q = int(input().rstrip())
for _ in range(q):
	n = int(input().rstrip())
	a = [int(i) for i in input().split()]
	b = [0] * 30
	for i in range(n):
		cnt = 0
		while a[i] > 0:
			cnt += 1
			a[i] >>= 1
		b[cnt - 1] += 1
	for i in range(11):
		if b[i] >= 2:
			tmp = b[i] // 2
			b[i] %= 2
			b[i + 1] += tmp
	print('YES' if b[11] > 0 else 'NO')


q = int(input(''))
for i in range(q):
	n = int(input(''))
	S = input('').split()
	if '2048' in S:
		print('YES')
	else:
		t = 0
		for i in S:
			if int(i) <= 1024:
				t = t + int(i)
		if t >= 2048:
			print('YES')
		else:
			print('NO')


def main():
	q = int(input())
	for _ in range(q):
		input()
		seq = [int(c) for c in input().split()]
		psum = sum((e for e in seq if e <= 2048))
		print('yes' if psum >= 2048 else 'no')
main()


n = int(input())
i = 1
opts = []
while i <= n:
	g = int(input())
	inpt = [int(x) for x in input().split()]
	inp = [x for x in inpt if x <= 2048]
	if sum(inp) < 2048:
		opts.append('NO')
	else:
		opts.append('YES')
	i += 1
for opt in opts:
	print(opt)


q = int(input())
for _ in range(q):
	_ = input()
	a = [int(x) for x in input().split() if int(x) <= 2048]
	print('Yes' if sum(a) >= 2048 else 'No')


import sys
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right
import math
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	x = dc(int)
	for i in l:
		x[i] += 1
	c = 1
	while c <= 2048:
		if x[c] > 1:
			x[2 * c] += x[c] // 2
		c = 2 * c
	if x[2048] == 0:
		print('NO')
	else:
		print('YES')


import math
t = int(input())

def fn():
	n = int(input())
	a = list(map(int, input().split()))
	x = [0] * 30
	for val in a:
		i = int(math.log(val, 2))
		x[i] = x[i] + 1
	for i in range(1, 12, 1):
		x[i] += x[i - 1] // 2
	if x[11]:
		print('YES')
	else:
		print('NO')
while t:
	t -= 1
	fn()


n = int(input())
for i in range(n):
	m = int(input())
	l = list(map(int, input().split(' ')))
	l = sorted(l)
	sum = int
	sum = 2048
	flag = 0
	for j in l[::-1]:
		if j > 2048:
			continue
		sum = sum - j
		if sum == 0:
			flag = 1
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')


t = int(input())

def f(n, a):
	a.sort()
	b = list(set(a))
	b.sort()
	s = []
	if b == a:
		if a.count(2048) == 0:
			print('No')
		else:
			print('Yes')
	elif b.count(2048) >= 1:
		print('Yes')
	else:
		c = [i for i in a if i <= 2048]
		if sum(c) >= 2048:
			print('Yes')
		else:
			print('No')
for j in range(t):
	n = int(input())
	a = [i for i in map(int, input().split())]
	f(n, a)


def do(vals):
	res = [vals[0]]
	ok = False
	for i in range(1, len(vals)):
		if vals[i] == res[-1] and vals[i] < 2048:
			res[-1] = res[-1] * 2
			ok = True
		else:
			res.append(vals[i])
	return (res, ok)

def main():
	d = int(input())
	for i in range(d):
		c = int(input())
		vals = [int(v) for v in input().split()]
		vals.sort()
		while 2048 not in vals:
			(vals, ok) = do(vals)
			vals.sort()
			if not ok:
				break
		print('YES' if 2048 in vals else 'NO')
main()


def game(list):
	list.sort(reverse=True)
	k = 0
	checker = False
	for i in list:
		if i <= 2048:
			k += i
		if k == 2048:
			checker = True
			break
	if checker == True:
		return 'Yes'
	else:
		return 'No'
q = int(input())
for i in range(q):
	t = input()
	newlist = list(map(int, input().split()))
	print(game(newlist))


for _ in range(int(input())):
	n = int(input())
	l = [0] * 30
	for x in input().split():
		x = int(x)
		k = 0
		while x:
			x //= 2
			k += 1
		l[k - 1] += 1
	for j in range(12):
		l[j + 1] += l[j] // 2
	if l[11]:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	x = int(input())
	lt = list(map(int, input().split()))
	for n in range(11):
		a = lt.count(2 ** n)
		lt = lt + [2 ** (n + 1)] * (a // 2)
	if 2048 in lt:
		print('YES')
	else:
		print('NO')


t = int(input())
sol = []

def baza_2(k):
	nr = 0
	while k % 2 == 0:
		nr += 1
		k //= 2
	return nr
while t:
	t -= 1
	n = int(input())
	a = [int(i) for i in input().split()]
	if 2048 in a:
		sol.append('YES')
	else:
		a = [i for i in a if i < 2048]
		d = [0 for i in range(12)]
		for i in a:
			d[baza_2(i)] += 1
		del a
		for i in range(11):
			d[i + 1] += d[i] // 2
		if d[11]:
			sol.append('yes')
		else:
			sol.append('no')
print(*sol, sep='\n')


def solve(n, s):
	f = 1
	i = 0
	while f:
		f = 0
		for i in range(n - 1):
			for j in range(i + 1, n):
				if s[i] == s[j] and s[i] + s[j] <= 2048 and (s[i] != 0):
					s[i] += s[i]
					s[j] = 0
					f = 1
	if 2048 in s:
		return 'YES'
	return 'NO'

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		a = [int(i) for i in input().split()]
		print(solve(n, a))
main()


for k in range(int(input())):
	n = int(input())
	t = list(map(int, input().split()))[::-1]
	if 2048 in t:
		print('YES')
	else:
		v = sum(t)
		for j in t:
			if j > 2048:
				v -= j
		if v >= 2048:
			print('YES')
		else:
			print('NO')


t = int(input())
for v in range(t):
	n = int(input())
	x = [int(q) for q in input().split() if int(q) <= 2048]
	if sum(x) >= 2048:
		print('YES')
	else:
		print('NO')


import sys

def ku():
	a = int(input())
	o = map(int, sys.stdin.readline().split())
	po = [0] * 2049
	for su in o:
		if su <= 2048:
			po[su] += 1
			if po[2048] == 1:
				return print('YES')
			while po[su] == 2:
				po[su] = 0
				su *= 2
				po[su] += 1
				if po[2048] == 1:
					return print('YES')
	print('NO')
n = int(input())
for i in range(n):
	ku()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	c = {}
	for i in range(n):
		if a[i] not in c:
			c[a[i]] = 1
		else:
			c[a[i]] += 1
	k = [0 for i in range(12)]
	for i in range(12):
		if 2 ** i in c:
			k[i] = c[2 ** i]
	for i in range(11):
		k[i + 1] += k[i] // 2
	if k[11] >= 1:
		print('yes')
	else:
		print('no')


def check(nums):
	store = {}
	for num in nums:
		if num == 2048:
			return True
		if num in store:
			store[num] += 1
			while num in store and store[num] >= 2:
				newNum = num * 2
				if newNum == 2048:
					return True
				if newNum in store:
					store[newNum] += 1
				else:
					store[newNum] = 1
				store[num] -= 2
				num = newNum
		else:
			store[num] = 1
	return False
times = int(input())
for i in range(times):
	length = int(input())
	Nums = list(map(int, input().split(' ')))
	if check(Nums):
		print('YES')
	else:
		print('NO')


import math
from decimal import Decimal
import heapq

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def lol(lst, k):
	k = k % len(lst)
	ret = [0] * len(lst)
	for i in range(len(lst)):
		if i + k < len(lst) and i + k >= 0:
			ret[i] = lst[i + k]
		if i + k >= len(lst):
			ret[i] = lst[i + k - len(lst)]
		if i + k < 0:
			ret[i] = lst[i + k + len(lst)]
	return ret

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)

def Factor(n):
	Ans = []
	d = 2
	while d * d <= n:
		if n % d == 0:
			Ans.append(d)
			n //= d
		else:
			d += 1
	if n > 1:
		Ans.append(n)
	return Ans
q = int(input())
for i in range(q):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	tc = 0
	for j in l:
		if j <= 2048:
			tc += j
	if tc >= 2048:
		print('YES')
	else:
		print('NO')


def subsum(a, n, sum):
	curr_sum = a[0]
	start = 0
	i = 1
	while i <= n:
		while curr_sum > sum and start < i - 1:
			curr_sum = curr_sum - a[start]
			start += 1
		if curr_sum == sum:
			return 1
		if i < n:
			curr_sum = curr_sum + a[i]
		i += 1
	return 0
q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	flag = subsum(a, n, 2048)
	if flag == 1:
		print('YES')
	else:
		print('NO')


import sys
import math
relevant = []
power = 1
while True:
	relevant.append(power)
	power *= 2
	if power > 2048:
		break
query = int(input())
while query != 0:
	n = int(input())
	mp = dict(zip(relevant, [0 for i in range(len(relevant))]))
	nums = list(map(int, input().split()))
	for i in range(n):
		inp = nums[i]
		if inp > 2048:
			continue
		mp[inp] += 1
	for p in relevant:
		if p == 2048:
			break
		full = mp[p] / 2
		mp[p * 2] += full
	if mp[2048] >= 1:
		print('YES')
	else:
		print('NO')
	query -= 1


import sys
tc = int(sys.stdin.readline())
for _ in range(tc):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	arr.sort()
	if 2048 in arr:
		print('YES')
	else:
		key = [pow(2, i) for i in range(12)]
		cnt = dict().fromkeys(key, 0)
		for i in arr:
			if i in cnt:
				cnt[i] += 1
		flag = False
		while True:
			any = False
			for i in cnt:
				if cnt[i] >= 2:
					any = True
					if 2 * i == 2048:
						flag = True
						print('YES')
						break
					elif 2 * i in cnt:
						cnt[2 * i] += 1
					cnt[i] -= 2
			if flag:
				break
			if not any:
				print('NO')
				break


q = int(input())
out = []
for i in range(q):
	n = int(input())
	lst = sorted(map(int, input().split()))
	lst = [i for i in lst if i <= 2048]
	while 2048 not in lst and len(lst) > 1 and (len(lst) != len(set(lst))):
		if lst[0] == lst[1]:
			lst.append(lst[0] * 2)
			del lst[0]
			del lst[0]
			lst = sorted(lst)
		else:
			del lst[0]
	if 2048 not in lst:
		out.append('NO')
	else:
		out.append('YES')
print('\n'.join(out))


from collections import defaultdict, Counter
from math import ceil, floor, log2, gcd
from itertools import permutations, combinations
from functools import reduce
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	c = Counter(a)
	for x in [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]:
		if x not in c:
			continue
		co = c[x]
		c[x * 2] += co // 2
	if c[2048] > 0:
		print('YES')
	else:
		print('NO')


from bisect import insort
n = int(input())
ans = []
for i in range(n):
	k = int(input())
	a = list(map(int, input().split()))
	a.sort()
	j = 1
	while j < k:
		if 2048 in a:
			break
		if j > 0 and a[j] == a[j - 1]:
			insort(a, a[j] * 2)
			a.pop(j)
			a.pop(j - 1)
			j -= 1
			k -= 1
		j += 1
	if 2048 in a:
		ans.append('YES')
	else:
		ans.append('NO')
print(*ans, sep='\n')


from math import log
q = int(input())
n = input()
s = [list(map(int, input().split()))]
for i in range(q - 1):
	n = input()
	s.append(list(map(int, input().split())))
for game in s:
	counter = [0 for _ in range(12)]
	for num in game:
		d = int(log(num, 2))
		if d > 11:
			continue
		counter[d] += 1
		if counter[11] > 0:
			print('YES')
			break
		for i in range(11):
			if counter[i] >= 2:
				temp = counter[i] // 2
				counter[i + 1] += temp
				counter[i] -= temp * 2
		if counter[11] > 0:
			print('YES')
			break
	else:
		print('NO')


t = int(input())
while t:
	n = int(input())
	l = [int(i) for i in input().split(' ')]
	l.sort(reverse=True)
	s = 0
	a = 0
	for i in range(n):
		s = s + l[i]
		if s == 2048:
			print('YES')
			a = 1
			break
		elif s < 2048:
			continue
		else:
			s = 0
	if a == 0:
		print('NO')
	t = t - 1


q = int(input())
for h in range(q):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	res = 0
	for i in a:
		if i > 2048:
			continue
		res += i
	if res >= 2048:
		print('Yes')
	else:
		print('No')


q = int(input())
for rew in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	while True:
		if 2048 in l:
			print('YES')
			break
		if len(l) == 0:
			print('NO')
			break
		if len(l) > 1 and l[0] == l[1]:
			l = [2 * l[0]] + l[2:]
		else:
			l = l[1:]
		l.sort()


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	x = 1
	reserve = 0
	while x <= 1024:
		reserve = (l.count(x) + reserve) // 2
		x = x * 2
	if l.count(2048) + reserve > 0:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	tot = 0
	for x in a:
		if x <= 2048:
			tot += x
	print('YES' if tot >= 2048 else 'NO')


def takeFirst(elem):
	return elem[0]
n = int(input())
for i in range(n):
	input()
	l = list(map(int, input().split()))
	while True:
		if 2048 in l:
			print('YES')
			break
		elif sum(l) < 2048:
			print('NO')
			break
		else:
			d = dict()
			for i in l:
				d[i] = d.get(i, 0) + 1
			a = []
			for i in d:
				a.append((i, d[i]))
			a.sort(key=takeFirst, reverse=True)
			G = False
			for (i, j) in a:
				if j >= 2:
					G = True
					l.pop(l.index(i))
					l[l.index(i)] *= 2
					break
			if G == False:
				print('NO')
				break


n = int(input())
for i in range(n):
	m = int(input())
	L = list(map(int, input().split()))
	L = sorted(L)
	f = 0
	s = 0
	L1 = []
	for i in range(len(L) - 1, -1, -1):
		if L[i] < 2048:
			L1.append(L[i])
		if sum(L1) == 2048 or L[i] == 2048:
			print('YES')
			f = 1
			break
	if f == 0:
		print('NO')


def check(li):
	sum = 0
	for i in li:
		if i <= 2048:
			sum += i
	if sum >= 2048:
		return 'YES'
	else:
		return 'NO'
n = int(input())
for x in range(n):
	num = int(input())
	li = list(map(int, input().split(' ')))
	print(check(li))


for i in range(int(input())):
	(cant, suma, numb) = (int(input()), 0, list(map(int, input().split(' '))))
	for i_2 in numb:
		if i_2 <= 2048:
			suma -= -i_2
	if suma >= 2048:
		print('YES')
	else:
		print('NO')


tt = int(input())
for _ in range(tt):
	n = int(input())
	l = list(map(int, input().split(' ')))
	if sum(l) >= 2048:
		sum1 = 0
		for i in range(len(l)):
			if l[i] <= 2048:
				sum1 += l[i]
		if sum1 >= 2048:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


T = int(input())
for testcase in range(T):
	num = int(input())
	arr = [int(i) for i in input().split()]
	dp = [arr.count(2 ** i) for i in range(12)]
	for i in range(11):
		dp[i + 1] += dp[i] // 2
	if dp[11] > 0:
		print('YES')
	else:
		print('NO')


d = {1: 0, 2: 1, 4: 2, 8: 3, 16: 4, 32: 5, 64: 6, 128: 7, 256: 8, 512: 9, 1024: 10, 2048: 11}
m = eval(input())
for times in range(m):
	n = eval(input())
	cnt = []
	for i in range(12):
		cnt.append(0)
	s = list(map(lambda x: d.get(eval(x), 100), input().split()))
	for i in s:
		if i != 100:
			cnt[i] += 1
	for i in range(11):
		cnt[i + 1] += int(cnt[i] / 2)
	if cnt[-1] > 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	array = list(map(int, input().split()))
	ttl = 0
	for val in array:
		if val <= 2048:
			ttl += val
	if ttl >= 2048:
		print('YES')
	else:
		print('NO')


for case in range(int(input())):
	LmaDaMostwaElmasaelBeta3tnaTapMasaelElJuniors3amlaEzayS3bhaShewya = input()
	print('YES' if sum([int(x) for x in input().split() if int(x) <= 2048]) >= 2048 else 'NO')


from math import log

def play_2048(s):
	if 2048 in s:
		return 'YES'
	x = 2048
	b = True
	while s and b:
		b = False
		for (i, v) in enumerate(s):
			if v in s[i + 1:]:
				b = True
				x -= v * 2
				s.pop(s.index(v))
				s[s.index(v)] = v * 2
			if 2048 in s:
				return 'YES'
	return 'NO'
q = int(input())
for _ in range(q):
	n = int(input())
	s = sorted(filter(lambda i: i <= 2048, map(int, input().strip().split())), reverse=True)
	print(play_2048(s))


n = int(input())

def poss(numbers, target):
	numbers = sorted(numbers, reverse=True)
	while numbers[0] > target:
		numbers.pop(0)
		if len(numbers) == 0:
			return 'NO'
	if sum(numbers) >= target:
		return 'YES'
	else:
		return 'NO'
l = []
for k in range(n):
	p = int(input())
	r = [int(x) for x in input().split()]
	l.append(poss(r, 2048))
print('\n'.join((k for k in l)))


import sys
input = sys.stdin.readline

def log(x):
	ret = 0
	while x > 1:
		ret += 1
		x /= 2
	return ret
q = int(input())
for _ in range(q):
	n = int(input())
	a = [log(i) for i in map(int, input().split()) if i <= 2048]
	cnt = [0] * (log(2048) + 1)
	for x in a:
		cnt[x] += 1
	for i in range(len(cnt)):
		cnt[i] += cnt[i - 1] // 2
	if cnt[log(2048)] > 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	v = []
	for i in a:
		if i <= 2048:
			v.append(i)
		else:
			break
	if sum(v) >= 2048:
		print('YES')
	else:
		print('NO')


from collections import Counter as CO
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	i = 1
	d = dict()
	while i <= 5046:
		d[i] = 0
		i = i * 2
	freq = dict(CO(arr))
	for k in d:
		try:
			d[k] = freq[k]
		except:
			pass
	for k in sorted(d.keys()):
		try:
			d[k * 2] += d[k] // 2
		except:
			pass
	if d[2048] >= 1:
		print('YES')
	else:
		print('NO')


import math
for _ in range(int(input())):
	n = int(input())
	S = list(map(int, input().split()))
	a = 2048
	sum = 0
	for a in S:
		if a > 2048:
			continue
		else:
			sum = sum + a
	if sum >= 2048:
		print('YES')
	else:
		print('NO')


from math import *

def check(what, kol):
	global b
	if what == 0:
		if b[0] >= kol:
			return True
		else:
			return False
	if b[what] >= kol:
		return True
	else:
		return check(what - 1, (kol - b[what]) * 2)
t = int(input())
for q in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * 12
	for j in a:
		if j <= 2048:
			b[int(log2(j))] += 1
	i = 0
	if check(11, 1):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l1 = [int(__) for __ in input().split()]
	l1.sort(reverse=True)
	for i in range(n):
		if l1[i] <= 2048:
			if sum(l1[i:]) >= 2048:
				print('YES')
				break
	else:
		print('NO')


import math
t = []
for i in range(32):
	t.append(0)
a = int(input())
for i in range(a):
	n = input()
	x = list(map(int, input().split()))
	x = sorted(x)
	x = x[::-1]
	t = 2048
	if min(x) > 2048:
		print('NO')
	else:
		l = 0
		while l < len(x):
			if x[l] > 2048:
				l = l + 1
			else:
				t = t - x[l]
				if t == 0:
					print('YES')
					break
				else:
					l = l + 1
		if t != 0:
			print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	s = input().split()
	s_list = list(map(int, s))
	if 2048 in s_list:
		print('YES')
	else:
		s_newlist = [j for j in s_list if j < 2049]
		if sum(s_newlist) >= 2048:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	d = {2048: 0}
	flag = 'NO'
	n = int(input())
	l = map(int, input().split())
	for i in l:
		if i < 2049:
			try:
				d[i] += 1
			except:
				d[i] = 1
	while sum(d.values()) + 1 != len(d):
		try:
			if d[2048] == 0:
				raise
			if d[2048] > 0:
				flag = 'YES'
				break
		except:
			for i in d.keys():
				if d[i] > 1:
					try:
						d[2 * i] += 1
					except:
						d[2 * i] = 1
					if d[i] == 2:
						del d[i]
					else:
						d[i] -= 2
					break
	print(flag)


for _ in range(int(input())):
	n = int(input())
	l = [int(y) for y in input().split()]
	if 2048 in l:
		print('YES')
	else:
		k = []
		a = 1
		for i in range(12):
			k.append(l.count(a))
			a = a * 2
		for i in range(1, len(k)):
			x = k[i - 1] // 2
			k[i] = k[i] + x
		if k[-1] >= 1:
			print('YES')
		else:
			print('NO')


q = int(input())
ans = []
step = []
for i in range(12):
	step.append(2 ** i)
for i in range(q):
	kolvo = [0] * 12
	n = int(input())
	a = map(int, input().split())
	for elem in a:
		if elem in step:
			kolvo[step.index(elem)] += 1
	for i in range(11):
		kolvo[i + 1] += kolvo[i] // 2
	if kolvo[11]:
		ans.append('YES')
	else:
		ans.append('NO')
for elem in ans:
	print(elem)


a = int(input())
for i in range(a):
	b = int(input())
	l = list(map(int, input().split()))
	t = []
	for j in l:
		if j <= 2048:
			t.append(j)
	if sum(t) >= 2048:
		print('YES')
	else:
		print('NO')


from bisect import *
for i in range(int(input())):
	input()
	L = sorted(list(map(int, input().split())))
	L = L[:bisect_right(L, 2048)]
	if sum(L) >= 2048:
		print('YES')
	else:
		print('NO')


def game(s, n):
	a = s
	flag = 1
	while flag == 1:
		i = len(a) - 1
		flag = 0
		a.sort(reverse=True)
		while i > 0:
			if a[i] == 2048:
				return 'YES'
			elif a[i] == a[i - 1]:
				a[i - 1] = 2 * a[i]
				a.pop(i)
				flag = 1
			i = i - 1
		if a[0] == 2048:
			return 'YES'
	return 'NO'
q = int(input())
for i in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort(reverse=True)
	result = game(s, n)
	print(result)


q = int(input())

def ans():
	for k in range(0, 11):
		for i in range(A.count(2 ** k) // 2):
			A.append(2 ** (k + 1))
	if 2048 in A:
		print('Yes')
	else:
		print('No')
for i in range(q):
	n = int(input())
	A = [int(x) for x in input().split()]
	ans()


q = int(input())
answers = list()
l = 0
while l < q:
	n = int(input())
	numbers = input()
	numbers = numbers.split()
	i = 0
	while i < n:
		numbers[i] = int(numbers[i])
		i = i + 1
	numbers.sort(reverse=True)
	amount = 0
	i = 0
	while i < n:
		if amount + numbers[i] <= 2048:
			amount = amount + numbers[i]
		i = i + 1
	if amount == 2048:
		answers.append('YES')
	else:
		answers.append('NO')
	l = l + 1
l = 0
while l < q:
	print(answers[l])
	l = l + 1


q = int(input())
for i in range(0, q):
	n = input()
	a = [int(i) for i in input().split() if int(i) <= 2048]
	s = sum(a)
	print('YES' if s >= 2048 else 'NO')


q = int(input())
for i in range(q):
	n = int(input())
	_in = input().split(' ')
	numbers = {1: 0, 2: 0, 4: 0, 8: 0, 16: 0, 32: 0, 64: 0, 128: 0, 256: 0, 512: 0, 1024: 0, 2048: 0}
	for j in _in:
		if int(j) in numbers:
			numbers[int(j)] += 1
	for j in range(0, 11):
		numbers[2 ** (j + 1)] += numbers[2 ** j] // 2
	if numbers[2048] > 0:
		print('YES')
	else:
		print('NO')


I = input
for _ in [0] * int(I()):
	I()
	my_list = list(map(int, I().split()))
	if sum((x for x in my_list if x < 2049)) >= 2048:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	sum = 0
	a = list(map(int, input().split()))
	for v in a:
		if v <= 2048:
			sum += v
	if sum >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
for t in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	arr = [s.count(2 ** i) for i in range(12)]
	for i in range(1, 12):
		arr[i] += arr[i - 1] // 2
	if arr[11] > 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	a = [int(s) for s in input().split()]
	q1 = a.count(1)
	q2 = a.count(2) + q1 // 2
	q3 = a.count(4) + q2 // 2
	q4 = a.count(8) + q3 // 2
	q5 = a.count(16) + q4 // 2
	q6 = a.count(32) + q5 // 2
	q7 = a.count(64) + q6 // 2
	q8 = a.count(128) + q7 // 2
	q9 = a.count(256) + q8 // 2
	q10 = a.count(512) + q9 // 2
	q11 = a.count(1024) + q10 // 2
	q12 = a.count(2048) + q11 // 2
	if q12 >= 1:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for q in range(t):
	n = int(input())
	numbers = list(map(int, input().split()))
	dp = dict.fromkeys(range(30), 0)
	for v in numbers:
		p = int(math.log2(v))
		dp[p] += 1
	r = False
	for i in range(1, 30):
		c = dp[i - 1] // 2
		dp[i] += c
		dp[i - 1] -= c
		if dp[11] > 0:
			r = True
	if dp[11] > 0:
		r = True
	print('YES' if r else 'NO')


q = input()
for d in range(int(q)):
	n = input()
	arr = list(map(int, input().split()))
	if sum((x for x in arr if x <= 2048)) >= 2048:
		print('YES')
	else:
		print('NO')


from math import log
q = int(input())
for _ in range(q):
	n = int(input())
	arr = list(map(int, input().split()))
	cnt = [0 for i in range(12)]
	for i in arr:
		if log(i, 2) <= 11:
			cnt[int(log(i, 2))] += 1
	for i in range(11):
		cnt[i + 1] += cnt[i] // 2
	if cnt[11] >= 1:
		print('YES')
	else:
		print('NO')


query_number = int(input())
l = []
for i in range(query_number):
	integer_number = int(input())
	set_ = [int(j) for j in input().split()]
	l.append(set_)

def verify(x):
	x = [i for i in x[:] if i <= 2048]
	if sum(x) >= 2048:
		print('yes')
	else:
		print('no')
for i in l:
	verify(i)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(k1, k2) = (0, 0)
	for i in range(11):
		i = 2 ** i
		(k1, k2) = (a.count(i) // 2, (k2 + a.count(i)) // 2)
	if k2 > 0 or 2048 in a:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort(reverse=True)
	soma = 0
	for i in s:
		if i > 2048:
			continue
		if soma + i > 2048:
			continue
		else:
			soma += i
	if soma == 2048:
		print('YES')
	else:
		print('NO')


import sys
import math
from collections import defaultdict
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	a = [int(x) for x in input().split()]
	store = set()
	for ele in a:
		store.add(ele)
	if 2048 in store:
		print('YES')
	else:
		store = set()
		found = False
		for ele in a:
			if ele not in store:
				store.add(ele)
			else:
				new_ele = ele
				while new_ele in store:
					store.remove(new_ele)
					new_ele = new_ele * 2
				if new_ele == 2048:
					found = True
					break
				store.add(new_ele)
		if found:
			print('YES')
		else:
			print('NO')


q = int(input())
l = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]
for i in range(q):
	n = int(input())
	s = [int(x) for x in input().split()]
	for i in range(11):
		while s.count(l[i]) > 1:
			s.remove(l[i])
			s.remove(l[i])
			s.append(2 * l[i])
	if 2048 in s:
		print('YES')
	else:
		print('NO')


from math import log
I = lambda : map(int, input().split())
for _ in range(int(input())):
	I()
	C = [0] * 12
	for s in I():
		if s < 2049:
			C[int(log(s, 2))] += 1
	for i in range(11):
		C[i + 1] += C[i] // 2
	print('YES' if C[-1] else 'NO')


t = int(input())
for _ in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	nums.sort(reverse=True)
	need = 2048
	for num in nums:
		if num > need:
			continue
		need -= num
		if need == 0:
			break
	if not need:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	N = int(input())
	num = list(map(int, input().split()))
	num.sort(reverse=True)
	x = 0
	ans = 'NO'
	for k in num:
		if k > 2048:
			continue
		else:
			x += k
		if x == 2048:
			ans = 'YES'
	print(ans)


q = int(input())
for i in range(q):
	input()
	x = list(map(int, input().split(' ')))
	x = filter(lambda k: k <= 2048, x)
	print('YES' if sum(x) >= 2048 else 'NO')


q = int(input())
for i in range(q):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	while True:
		if 2048 in lst:
			break
		b = 0
		s = len(lst)
		for j in range(s):
			a = 0
			for p in range(j + 1, s):
				if lst[j] == lst[p]:
					lst.append(lst[j] + lst[p])
					lst.remove(lst[p])
					lst.remove(lst[j])
					lst.sort()
					a += 1
					break
			if a == 1:
				break
			else:
				b += 1
		if b == len(lst):
			break
	if 2048 in lst:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	memo = {}
	for i in range(n):
		if s[i] not in memo:
			memo[s[i]] = 1
		else:
			memo[s[i]] += 1
	for i in range(11):
		num = 2 ** i
		if num in memo:
			if num * 2 in memo:
				memo[num * 2] += memo[num] // 2
			else:
				memo[num * 2] = memo[num] // 2
	if 2048 in memo and memo[2048] > 0:
		print('YES')
	else:
		print('NO')


def two(sq):
	b = 1
	while 1:
		chk = -1
		for (e, i) in enumerate(sq):
			if i == 2048:
				return 1
			if i == b:
				if chk == -1:
					chk = e
				else:
					sq[e] = -1
					sq[chk] = -1
					sq.append(b * 2)
					chk = -1
		b *= 2
		if b == 4096:
			return 0
q = int(input())
for _ in range(q):
	n = int(input())
	seq = list(map(int, input().split()))
	if two(seq) == 0:
		print('NO')
	else:
		print('YES')


from collections import defaultdict as dd
from collections import Counter as ccd
from itertools import permutations as pp
from itertools import combinations as cc
from random import randint as rd
from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq as hq
from math import gcd
mod = pow(10, 9) + 7

def inp(flag=0):
	if flag == 0:
		return list(map(int, input().strip().split(' ')))
	else:
		return int(input())
for _ in range(int(input())):
	n = inp(1)
	l = ccd(inp())
	i = 1
	ans = 'NO'
	while i <= 1024:
		if l[i] > 1:
			l[i * 2] += l[i] // 2
			l[i] = l[i] % 2
		i *= 2
	if l[2048] != 0:
		ans = 'YES'
	print(ans)


from fractions import gcd
from datetime import date
from heapq import *
import math
from collections import defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
inf = float('inf')

def main():
	q = int(input())
	for i in range(q):
		n = int(input())
		s = list(map(int, input().split()))
		s = sorted(s, reverse=True)
		if sum(s) < 2048:
			print('NO')
			continue
		su = 0
		flg = False
		for j in range(n):
			if s[j] <= 2048:
				su += s[j]
			if su == 2048:
				flg = True
		if flg:
			print('YES')
		else:
			print('NO')
main()


n = int(input())
for i in range(n):
	useless = input()
	nums = [int(x) for x in input().split()]
	nums = sorted(nums, reverse=True)
	s = 2048
	for j in nums:
		if j <= s:
			s -= j
		if s == 0:
			print('Yes')
			break
		elif s < 0:
			print('No')
			break
	else:
		print('No')


from sys import stdin, stdout
from math import log2, pow, floor
n_queries = int(input())
for i in range(n_queries):
	n_ele = int(input())
	nums = list(map(int, input().split()))
	result = {}
	summ = 0
	for item in nums:
		if item == 2048:
			result[2048] = 1
			break
		elif item > 2048:
			pass
		else:
			summ += item
			if item in result:
				result[item] += 1
			else:
				result[item] = 1
	if 2048 in result:
		print('YES')
	elif summ < 2048:
		print('NO')
	else:
		start = 2
		while start <= 2048:
			if start in result:
				start_d = start * 2
				start_d_n = result[start] // 2
				if start_d in result:
					result[start_d] += start_d_n
				else:
					result[start_d] = start_d_n
			start = start * 2
		if 2048 in result:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	x = 2048
	while a:
		y = a.pop()
		if y <= x:
			x -= y
	print('NO' if x else 'YES')


t = int(input())
for j in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	c = 0
	q = 0
	i = 0
	while i < len(a) and a[i] <= 2048:
		c = c + a[i]
		if c >= 2048:
			print('YES')
			q = 1
			break
		i = i + 1
	if q == 0:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	j = []
	for i in range(n):
		if l[i] > 2048:
			continue
		else:
			j.append(l[i])
	if sum(j) >= 2048:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t = t - 1
	n = int(input())
	lst = [int(x) for x in input().split(' ')]
	lst1 = []
	d = {1: 0, 2: 0, 4: 0, 8: 0, 16: 0, 32: 0, 64: 0, 128: 0, 256: 0, 512: 0, 1024: 0, 2048: 0}
	for i in range(0, len(lst)):
		if d.get(lst[i]) != None:
			d[lst[i]] = d[lst[i]] + 1
	lst = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
	for i in range(len(lst) - 1):
		k = d[lst[i]]
		d[lst[i]] = 0
		d[lst[i + 1]] = k // 2 + d[lst[i + 1]]
	if d[2048] != 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = sorted([*map(int, input().split())])
	(res, f) = (0, False)
	for i in range(n):
		res += a[i]
		if res == 2048:
			f = True
	res = 0
	for i in range(n - 1, -1, -1):
		if a[i] > 2048:
			continue
		res += a[i]
		if res == 2048:
			f = True
	print('YES' if f else 'NO')


c = int(input())
y = 'YES'
n = 'NO'
for i in range(c):
	b = int(input())
	l = list(map(int, input().split()))
	cnt = 0
	for j in range(b):
		if l[j] <= 2048:
			cnt += l[j]
	if cnt >= 2048:
		print(y)
	else:
		print(n)


qtd = int(input())
for i in range(qtd):
	x = int(input())
	lista = list(map(int, input().split()))
	u = 0
	r = 'NO'
	while len(lista) != 0:
		lista.sort()
		if 2048 in lista:
			r = 'YES'
			break
		if u + 1 > len(lista) - 1:
			break
		if lista[u] == lista[u + 1]:
			lista[u] = lista[u] + lista[u + 1]
			lista.remove(lista[u + 1])
			u -= 1
		u += 1
	print(r)


def findMax(lists):
	up = lists[-1]
	lens = len(lists)
	fr = len(lists) - 1
	for i in range(lens - 1, -1, -1):
		if lists[i] < 2048:
			fr = i
			up = lists[i]
			break
	for i in range(fr - 1, -1, -1):
		if up == lists[i]:
			res = up * 2
			del lists[i]
			del lists[i]
			lists.append(res)
			return True
		else:
			up = lists[i]
	return False
T = int(input())
for i in range(T):
	strlen = int(input())
	list2048 = list(map(int, input().split()))
	while 2048 not in list2048:
		list2048.sort()
		if findMax(list2048) == False:
			print('NO')
			break
	if 2048 in list2048:
		print('YES')


from collections import Counter
for t in range(int(input())):
	n = int(input())
	l1 = []
	l2 = []
	d = {}
	f = 0
	s = 0
	l1 = list(map(int, input().split()))
	if 2048 in l1:
		print('YES')
		continue
	else:
		l1.sort()
		for i in range(0, len(l1)):
			s = 0
			for j in range(i, len(l1)):
				s += l1[j]
				if s > 2048:
					break
				if s == 2048:
					f = 1
					break
		if f == 1:
			print('YES')
		else:
			print('NO')


def solve():
	n = int(input())
	sum = 0
	ls = input().split()
	for i in ls:
		if int(i) > 2048:
			continue
		sum += int(i)
	if sum >= 2048:
		print('YES')
	else:
		print('NO')
	return
t = int(input())
for i in range(t):
	solve()


def doit(m, c):
	i = 0
	while i < len(c):
		p = c.pop(i)
		if p in c:
			i = 0
			j = c.index(p)
			c.append(2 * c[j])
			c.pop(j)
		else:
			c.insert(i, p)
			i += 1
		if 2048 in c:
			break
n = int(input())
for i in range(n):
	m = int(input())
	c = list(map(int, input().split()))
	if 2048 not in c:
		doit(m, c)
	if 2048 in c:
		print('YES')
	else:
		print('NO')


class Solution:

	@classmethod
	def check(cls):
		q = int(input())
		while q > 0:
			n = int(input())
			l = [int(x) for x in input().split()]
			ans = 'NO'
			flag = True
			while flag:
				flag = False
				l.sort()
				m = len(l)
				if 2048 in l:
					ans = 'YES'
					flag = False
					continue
				for i in range(m - 1, 0, -1):
					if l[i] == l[i - 1]:
						flag = True
						k = l[i]
						l.pop(i - 1)
						l.pop(i - 1)
						l.append(2 * k)
			q = q - 1
			print(ans)
Solution.check()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	s = 0
	f = 0
	for j in range(n - 1, -1, -1):
		s += a[j]
		if s == 2048:
			f = 1
			print('YES')
			break
		elif s > 2048:
			s -= a[j]
	if f == 0:
		print('NO')


for _ in range(int(input())):
	input()
	numbers = [int(num) for num in input().split(' ')]
	print('YES') if sum([num for num in numbers if num <= 2048]) >= 2048 else print('NO')


q = int(input())
while q:
	q -= 1
	n = int(input())
	flag = 0
	a = [int(i) for i in input().split()]
	a.sort()
	for i in range(n - 1):
		flag = 0
		if a[i] == 2048:
			print('YES')
			flag = 1
			break
		if a[i] == a[i + 1]:
			a[i] = 2 * a[i]
		a.sort()
	if a[n - 1] == 2048 and flag == 0:
		print('YES')
		continue
	if flag == 0:
		print('NO')


q = int(input())
while q > 0:
	n = int(input())
	l = list(map(int, input().split()))
	ans = 0
	for i in l:
		if i <= 2048:
			ans += i
	if ans >= 2048:
		print('YES')
	else:
		print('NO')
	q -= 1


from heapq import *

def work():
	n = int(input())
	a = list(map(int, input().split()))
	heapify(a)
	while a:
		x = heappop(a)
		if x == 2048:
			return 'YES'
		if a:
			y = heappop(a)
		else:
			break
		if x != y:
			heappush(a, y)
		else:
			heappush(a, 2 * x)
	return 'NO'
q = int(input())
for i in range(q):
	print(work())


q = int(input())
while q != 0:
	q = q - 1
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	f = 0
	f1 = 0
	while f != 1 and len(a) != 1 and (f1 != 1):
		if 2048 in a:
			f = 1
			break
		a.sort()
		i = 1
		while i < len(a):
			if a[i] == a[i - 1]:
				a[i - 1] = a[i - 1] + a[i]
				a.pop(i)
				i = i - 1
				f1 = 0
				break
			else:
				f1 = 1
			i = i + 1
	if 2048 in a:
		f = 1
	if f == 1:
		print('YES')
	else:
		print('NO')


import collections

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	d = collections.defaultdict(int)
	for i in a:
		d[i] += 1
	for i in range(11):
		d[2 ** (i + 1)] += d[2 ** i] // 2
	if d[2 ** 11]:
		print('YES')
	else:
		print('NO')
t = int(input())
for _ in range(t):
	solve()


n = int(input())
for i in range(n):
	le = int(input())
	li = list(map(int, input().split()))
	l2 = [0] * 12
	if 2048 in li:
		print('YES')
	else:
		for j in range(le):
			if li[j] == 2048:
				l2[11] += 1
			elif li[j] == 1024:
				l2[10] += 1
			elif li[j] == 512:
				l2[9] += 1
			elif li[j] == 256:
				l2[8] += 1
			elif li[j] == 128:
				l2[7] += 1
			elif li[j] == 64:
				l2[6] += 1
			elif li[j] == 32:
				l2[5] += 1
			elif li[j] == 16:
				l2[4] += 1
			elif li[j] == 8:
				l2[3] += 1
			elif li[j] == 4:
				l2[2] += 1
			elif li[j] == 2:
				l2[1] += 1
			elif li[j] == 1:
				l2[0] += 1
		for j in range(11):
			l2[j + 1] += l2[j] // 2
		if l2[11] >= 1:
			print('YES')
		else:
			print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	cou = []
	for j in range(12):
		cou.append(0)
	for j in range(n):
		if l[j] <= 2048:
			k = 0
			while l[j]:
				l[j] = l[j] // 2
				k += 1
			cou[k - 1] += 1
	for j in range(1, 12):
		cou[j] += cou[j - 1] // 2
	if cou[11] >= 1:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	f = 0
	while len(l) != len(set(l)):
		l = sorted(l)
		if 2048 in l:
			f = 1
			break
		for i in range(n - 1):
			if l[i] == l[i + 1]:
				tp = l.pop(i)
				l.pop(i)
				l.append(tp * 2)
				break
	if f == 1 or 2048 in l:
		print('YES')
	else:
		print('NO')


import math
from collections import deque, defaultdict
from sys import stdin, stdout
input = stdin.readline
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	a = listin()
	a.sort()
	i = 0
	while len(a) != len(set(a)) and 2048 not in a and (i < n - 1):
		a.sort()
		if a[i] == a[i + 1]:
			a[i] *= 2
			del a[i + 1]
		else:
			i += 1
	if 2048 in a:
		print('YES')
	else:
		print('NO')


def game(s):
	x = 2048
	jami = sum(s)
	if x in s:
		return 'YES'
	elif jami < x:
		return 'NO'
	else:
		for i in s:
			if i > x:
				jami -= i
		if jami < x:
			return 'NO'
		else:
			return 'YES'
q = input()
q = int(q)
while q:
	n = input()
	s = list(map(int, input().split()))
	print(game(s))
	q -= 1


t = int(input())
for case in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = False
	index = 0
	while a:
		if 2048 in a:
			ans = True
			break
		if len(a) == 1:
			break
		first = a.pop(0)
		if first == 2048:
			ans = True
		second = a.pop(0)
		if first == second:
			index2 = -1
			for i in range(len(a)):
				if first != a[i]:
					index2 = i
					break
			if index2 == -1:
				a.append(first + second)
			else:
				a.insert(index2, first + second)
		else:
			a.insert(0, second)
	if ans == True:
		print('YES')
	else:
		print('NO')


a = int(input())
szamok = []
ertek = []
mo = 0
mo2 = []
v = 0
for x in range(a):
	szamok.append(int(input()))
	ertek.append([int(x) for x in input().split()])
for x in range(len(ertek)):
	ertek[x] = sorted(ertek[x])
for x in range(len(ertek)):
	f = len(ertek[x]) - 1
	while v == 0 and f > -1:
		if ertek[x][f] < 2049:
			if mo < 2048:
				mo += ertek[x][f]
				if mo == 2048:
					v = 1
		f = f - 1
	mo2.append(mo)
	mo = 0
	v = 0
for x in range(len(mo2)):
	if mo2[x] == 2048:
		print('YES')
	else:
		print('NO')


from heapq import *
Q = int(input())
for _ in range(Q):
	N = int(input())
	h = [int(a) for a in input().split()]
	while 1:
		if h[0] == 2048:
			print('YES')
			break
		if len(h) <= 1:
			print('NO')
			break
		heapify(h)
		(a, b) = (heappop(h), heappop(h))
		if a == b:
			heappush(h, a + b)
		else:
			heappush(h, max(a, b))


for _ in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	a.sort(reverse=True)
	t = 2048
	for i in a:
		if t - i >= 0:
			t -= i
	print(['NO', 'YES'][t == 0])


q = int(input())
t = 1
while t <= q:
	t += 1
	n = int(input())
	if n > 0 and n <= 100:
		s = input().split(' ', int(n))
		l = list(map(int, s))
		sum = 0
		if 2048 in l:
			print('YES')
		else:
			for num in l:
				if int(num) < 2048:
					sum += int(num)
				else:
					sum += 0
			if sum >= 2048:
				print('YES')
			else:
				print('NO')


for i in range(int(input())):
	n = int(input())
	list_str = str(input())
	list_true = [int(x) for x in list_str.split()]
	m = 0
	for j in range(0, 12):
		for k in range(100):
			if 2 ** j in list_true:
				list_true.remove(2 ** j)
				m = m + 2 ** j
			else:
				pass
	if m >= 2048:
		print('YES')
	else:
		print('NO')


from collections import Counter, defaultdict
t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	cnt = defaultdict(lambda : 0)
	cnt.update(Counter(arr))
	arr = [2 ** i for i in range(12)]
	for i in arr:
		if cnt[2048]:
			print('YES')
			break
		cnt[2 * i] += cnt[i] // 2
	else:
		print('NO')


n = int(input())
a = []
for i in range(n):
	t = int(input())
	a.append([int(a) for a in input().split()])
for i in range(n):
	total = 2048
	fail = False
	while total != 0 and (not fail):
		if len(a[i]) == 0 or sum(a[i]) < total:
			fail = True
		elif total >= max(a[i]):
			total -= max(a[i])
			a[i].remove(max(a[i]))
		else:
			a[i].remove(max(a[i]))
	if total == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for tt in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in l:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	flag = False
	for i in l:
		if i == 2048:
			print('yes')
			flag = True
			break
		elif i in d and d[i] >= 2:
			d[i] -= 2
			toadd = i + i
			if toadd in d:
				d[toadd] += 1
			else:
				d[toadd] = 1
			l.append(toadd)
	if not flag:
		print('No')


for t in range(int(input())):
	n = input()
	values = list(map(int, input().split()))
	all = filter(lambda x: x <= 2048, values)
	print('YES' if sum(all) >= 2048 else 'NO')


q = int(input())
for i1 in range(q):
	n = int(input())
	c = [int(x) for x in input().split()]
	s = 0
	for i in range(n):
		if c[i] <= 2048:
			s += c[i]
	if s >= 2048:
		print('YES')
	else:
		print('NO')


import math
query = int(input())
for q in range(query):
	n = int(input())
	arr = list(map(int, input().split()))
	a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	for i in arr:
		if i <= 2048:
			k = int(math.log(i, 2))
			a[k] += 1
	for i in range(11):
		if a[i] >= 2:
			a[i + 1] += a[i] // 2
	if a[11] != 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	dic = {1: 0, 2: 0, 4: 0, 8: 0, 16: 0, 32: 0, 64: 0, 128: 0, 256: 0, 512: 0, 1024: 0, 2048: 0}
	num = int(input())
	tmp = [int(x) for x in input().split()]
	for x in tmp:
		if x <= 2048:
			dic[x] += 1
	dic[2] += dic[1] // 2
	dic[4] += dic[2] // 2
	dic[8] += dic[4] // 2
	dic[16] += dic[8] // 2
	dic[32] += dic[16] // 2
	dic[64] += dic[32] // 2
	dic[128] += dic[64] // 2
	dic[256] += dic[128] // 2
	dic[512] += dic[256] // 2
	dic[1024] += dic[512] // 2
	dic[2048] += dic[1024] // 2
	if dic[2048] > 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	x = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	f = 0
	if 2048 in l:
		print('YES')
	else:
		s = 0
		for i in l:
			if i <= 2048:
				s += i
			if s == 2048:
				f = 1
				print('Yes')
				break
			if s > 2048:
				f = 1
				print('No')
				break
		if f == 0:
			print('No')


tgt = 2048 .bit_length() - 1
for _ in range(int(input())):
	n = int(input())
	c = [0] * 31
	for x in input().split():
		c[int(x).bit_length() - 1] += 1
	for i in range(tgt):
		c[i + 1] += c[i] // 2
	print('YES' if c[tgt] else 'NO')


for i in range(int(input())):
	input()
	c = 0
	a = list(map(int, input().split()))
	for b in range(len(a)):
		if a[b - 1] <= 2048:
			c += a[b - 1]
			if c >= 2048:
				print('YES')
				break
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a1 = a.count(1)
	a2 = a.count(2) + a1 // 2
	a3 = a.count(4) + a2 // 2
	a4 = a.count(8) + a3 // 2
	a5 = a.count(16) + a4 // 2
	a6 = a.count(32) + a5 // 2
	a7 = a.count(64) + a6 // 2
	a8 = a.count(128) + a7 // 2
	a9 = a.count(256) + a8 // 2
	a10 = a.count(512) + a9 // 2
	a11 = a.count(1024) + a10 // 2
	a12 = a.count(2048) + a11 // 2
	if a12 >= 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	conj = [int(i) for i in input().split() if int(i) <= 2048]
	conj.sort(reverse=True)
	if 2048 in conj:
		print('YES')
		continue
	if sum(conj) >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	s = list(map(int, input().split(' ')))
	for j in range(len(s)):
		if s[j] > 2048:
			s[j] = 0
	s.sort(reverse=True)
	if s[0] == 2048:
		print('YES')
		continue
	sum = 0
	for j in range(len(s)):
		sum = sum + s[j]
		if sum == 2048:
			break
	if sum == 2048:
		print('YES')
	else:
		print('NO')


from collections import Counter

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	if 2048 in arr:
		return 'Yes'
	while 1:
		if arr.count(min(arr)) > 1:
			arr.append(2 * min(arr))
			arr.remove(min(arr))
			arr.remove(min(arr))
		elif arr.count(min(arr)) == 1:
			arr.remove(min(arr))
		if 2048 in arr:
			return 'Yes'
		if len(Counter(arr).keys()) == len(arr):
			break
	return 'No'
q = int(input())
for i in range(0, q):
	print(solve())


q = int(input())
for e in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	if 2048 in s:
		print('YES')
	else:
		ganhou = False
		rng = len(s) - 1
		i = 0
		while i < rng:
			e = s[i]
			e2 = s[i + 1]
			if e == e2:
				soma = e + e2
				if soma == 2048:
					ganhou = True
					break
				del s[i + 1]
				del s[i]
				s.append(soma)
				s.sort()
				rng = len(s) - 1
				i = -1
			i += 1
		if ganhou:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	n = int(input())
	S = [d for d in map(int, input().split()) if d <= 2048]
	if sum(S) >= 2048:
		print('YES')
	else:
		print('NO')


t = int(input())
import math
for j in range(t):
	n = int(input())
	s = list(map(int, input().split(' ')))
	f = [0] * 30
	if 2048 in s:
		print('Yes')
	else:
		for i in range(len(s)):
			f[int(math.log(s[i], 2))] += 1
		for i in range(1, 12):
			f[i] = f[i] + f[i - 1] // 2
			f[i - 1] = f[i - 1] - f[i - 1] // 2
		print('Yes' if f[11] >= 1 else 'No')


q = int(input())
result = []
for index in range(q):
	n = int(input())
	item_list = list(map(int, input().split()))
	item_list.sort()
	i = list(reversed(item_list))
	flag = False
	total = 0
	for num in i:
		if num == 2048:
			flag = True
			print('YES')
			break
		elif total == 2048:
			flag = True
			break
		elif num < 2048:
			total += num
	if total == 2048:
		print('YES')
		flag = True
	if not flag:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	a.reverse()
	if 2048 in a:
		print('YES')
	else:
		p = 0
		for i in range(n):
			if a[i] < 2048:
				p = i
				break
		a = a[p:]
		s = 0
		for i in range(len(a)):
			s += a[i]
			if s == 2048:
				print('YES')
				break
		else:
			print('NO')


def find(x, d, o):
	if x == 0:
		return 'NO'
	if d.get(x, 0) >= o:
		return 'YES'
	else:
		rem = o - d.get(x, 0)
		return find(x // 2, d, rem * 2)

def solve(n, s):
	d = {}
	for i in s:
		d[i] = d.get(i, 0) + 1
	if d.get(2048, 0) > 0:
		return 'YES'
	else:
		return find(2048 // 2, d, 2)
q = int(input())
for p in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	print(solve(n, s))


for u in range(int(input())):
	z = int(input())
	y = [int(f) for f in input().split()]
	y.sort()
	d = 0
	for i in y:
		d += i
	if d < 2048:
		print('No')
		continue
	if 2048 in y:
		print('yes')
		continue
	for x in range(z + 1):
		if 2048 in y:
			print('yes')
			break
		for i in range(len(y) - 1):
			if y[i] == y[i + 1]:
				y[i + 1] = y[i] * 2
				y.pop(i)
			if i > len(y) - 3:
				break
		y.sort()
	else:
		print('no')


n = int(input())
for i in range(n):
	k = int(input())
	a = [int(x) for x in input().split()]
	x = 0
	for j in range(12):
		x = x // 2 + a.count(2 ** j)
	if x == 0:
		print('NO')
	else:
		print('YES')


Q = int(input())
for q in range(Q):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	while len(arr) > 1 and arr[0] < 2048:
		m = min(arr)
		if arr[1] != arr[0]:
			arr = arr[1:]
		else:
			m = arr[0]
			arr = sorted(arr[2:] + [m * 2])
	if len(arr) != 0 and arr[0] == 2048:
		print('yes')
	else:
		print('no')


def game(n, s):
	if 2048 in s:
		return 'YES'
	elif len(set(s)) == len(s):
		return 'NO'
	else:
		s = [x for x in s if x < 2048]
		dic = {1: 0, 2: 0, 4: 0, 8: 0, 16: 0, 32: 0, 64: 0, 128: 0, 256: 0, 512: 0, 1024: 0, 2048: 0}
		main = 0
		for y in s:
			dic[y] += 1
		for q in dic.keys():
			if q == 2048:
				if dic[q] >= 1:
					return 'YES'
				else:
					return 'NO'
			else:
				tar = dic[q]
				dic[q * 2] += tar // 2
q = int(input())
query = []
for x in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	query.append(game(n, s))
for i in query:
	print(i)


def func(s):
	dic = {}
	for el in s:
		if el <= 2048:
			if el in dic.keys():
				dic[el] += 1
			else:
				dic[el] = 1
	for i in range(12):
		if 1 << i not in dic.keys():
			dic[1 << i] = 0
	if 2048 in dic.keys() and dic[2048] >= 1:
		return True
	else:
		for i in range(11):
			curr = dic[2 ** i]
			dic[2 ** i] = dic[2 ** i] % 2
			dic[2 ** (i + 1)] = dic[2 ** (i + 1)] + curr // 2
		if 2048 in dic.keys() and dic[2048] >= 1:
			return True
		else:
			return False
q = int(input())
for _ in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	ans = func(s)
	if ans == True:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	(n, arr) = (int(input()), list(map(int, input().split())))
	arr.sort()
	arr.reverse()
	k = 0
	while k < n and arr[k] > 2048:
		k += 1
	else:
		(j, Sum) = (k, 0)
		while j < n and Sum < 2048:
			Sum += arr[j]
			j += 1
		print('Yes' if Sum == 2048 else 'No')


n = int(input())
for i in range(n):
	s = 0
	m = int(input())
	l = list(map(int, input().split()))
	for j in l:
		if j <= 2048:
			s += j
	print('YES' if s >= 2048 else 'NO')


from math import *
t = int(input())
for y in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	a = [0 for i in range(12)]
	for i in l:
		u = int(log2(i))
		if u < 12:
			a[u] += 1
	for i in range(11):
		a[i + 1] += a[i] // 2
	if a[11] != 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	c = 0
	for x in a:
		if x <= 2048:
			c += x
	if c >= 2048:
		print('YES')
	else:
		print('NO')


t = int(input())
a = []
for i in range(t):
	n = input()
	b = list(map(int, input().split()))
	a.append(b)
for i in a:
	i.sort()
	sum = 0
	p = 0
	for j in i:
		if j < 2048:
			sum += j
		elif j == 2048:
			p = 1
			break
		else:
			break
	if p == 0:
		if sum >= 2048:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


def win_lose(s):
	total = 0
	if 2048 in s:
		return 'YES'
	for i in s:
		if total >= 2048:
			break
		if i < 2048:
			total += i
	if total >= 2048:
		return 'YES'
	else:
		return 'NO'
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	ans = win_lose(s)
	print(ans)


q = int(input())
while q:
	tem = [0] * 31
	q -= 1
	n = int(input())
	l = list(map(int, input().split()))
	for i in l:
		tem[len(bin(i)[2:]) - 1] += 1
	for i in range(0, 11):
		t = tem[i] // 2
		tem[i + 1] += t
	if tem[11] >= 1:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(0, n):
	c = 0
	t = int(input())
	list1 = [int(x) for x in input().split() if int(x) <= 2048]
	if 2048 in list1:
		print('YES')
	if 2048 not in list1 and sum(list1) == 2048:
		print('YES')
	if 2048 not in list1 and sum(list1) < 2048:
		print('NO')
	if 2048 not in list1 and sum(list1) > 2048:
		print('YES')


from collections import OrderedDict

def yesOrNo(numbers):
	dic = OrderedDict()
	for number in numbers:
		if number > 2048:
			continue
		while number in dic:
			if number == 2048:
				print('YES')
				return
			del dic[number]
			number *= 2
		dic[number] = 'hai yahi pe'
		if number == 2048:
			print('YES')
			return
	print('NO')
T = int(input())
for t in range(T):
	n = int(input())
	arr = map(int, input().split(' '))
	yesOrNo(arr)


import atexit
import io
import sys
_I_B = sys.stdin.read().splitlines()
input = iter(_I_B).__next__
_O_B = io.StringIO()
sys.stdout = _O_B

@atexit.register
def write():
	sys.__stdout__.write(_O_B.getvalue())

def pow(a, b):
	if b == 0:
		return 1
	t = pow(a, b // 2)
	if b & 1:
		return t * t * a
	else:
		return t * t

def main():
	idx = []
	for i in range(12):
		idx.append(pow(2, i))
	d = dict()
	for _ in range(int(input())):
		n = int(input())
		ms = list(map(int, input().split()))
		for i in idx:
			d[i] = 0
		for i in ms:
			if i <= 2048:
				d[i] += 1
		for i in range(11):
			d[idx[i + 1]] += d[idx[i]] // 2
		if d[2048] > 0:
			print('Yes')
		else:
			print('No')
main()


q = int(input())
for _ in range(q):
	N = int(input())
	(*A,) = map(int, input().split())
	S = [0] * 30
	for a in A:
		S[a.bit_length() - 1] += 1
	for i in range(11):
		while S[i] >= 2:
			S[i] -= 2
			S[i + 1] += 1
	if S[11] >= 1:
		print('YES')
	else:
		print('NO')


from math import log2
for _ in range(int(input())):
	n = int(input())
	data = list(map(int, input().split()))
	d = [0 for __ in range(100)]
	for e in data:
		d[int(log2(e))] += 1
	for i in range(11):
		d[i + 1] += d[i] // 2
	print('YES' if d[11] != 0 else 'NO')


n = int(input())
while n:
	q = int(input())
	sum = 0
	s = input()
	a = []
	a = s.split(' ')
	for x in range(q):
		if int(a[x]) <= 2048:
			sum = sum + int(a[x])
			if sum >= 20048:
				break
	if sum >= 2048:
		print('YES')
	else:
		print('NO')
	n = n - 1


import sys
from collections import defaultdict
from itertools import combinations
from itertools import permutations
input = lambda : sys.stdin.readline().rstrip()

def write(*args, sep=' '):
	for i in args:
		sys.stdout.write('{}'.format(i) + sep)
INF = float('inf')
MOD = int(1000000000.0 + 7)
for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	d = defaultdict(int)
	for i in arr:
		d[i] += 1
	for i in range(0, 11):
		x = d[1 << i] // 2
		d[1 << i + 1] += x
	if d[2048]:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	s_numbers = input().split()
	numbers = []
	sum = 0
	for j in range(n):
		numbers.append(int(s_numbers[j]))
		numbers.sort()
	for k in range(n - 1, -1, -1):
		if numbers[k] > 2048:
			sum += 0
		elif numbers[k] == 2048:
			print('YES')
			break
		elif numbers[k] < 2048:
			if sum < 2048:
				sum += numbers[k]
		if sum == 2048:
			print('YES')
			break
		if k == 0:
			print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	if 2048 in a:
		print('YES')
	else:
		b = [0] * 11
		for i in range(0, 11):
			b[i] += a.count(2 ** i)
			if b[i] > 1 and i < 10:
				if b[i] % 2 == 0:
					b[i + 1] += b[i] // 2
					b[i] = 0
				else:
					b[i + 1] += (b[i] - 1) // 2
					b[i] = 1
		temp = 2
		out = False
		for i in b[::-1]:
			if i >= temp:
				out = True
				break
			if i == 0 or i == 1:
				break
			temp *= 2
		print('YES' if out else 'NO')


q = int(input())
for i in range(q):
	temp = 0
	n = int(input())
	s = list(map(int, input().split()))
	for i in s:
		if i <= 2048:
			temp += i
	print('yes') if temp >= 2048 else print('no')


from sys import stdin
q = int(stdin.readline().strip())
for i in range(q):
	n = int(stdin.readline().strip())
	s = list(map(int, stdin.readline().strip().split()))
	flag = False
	for j in range(12):
		x = 2 ** j
		s1 = []
		cnt = 0
		for k in range(len(s)):
			if s[k] == x:
				cnt += 1
			else:
				s1.append(s[k])
			if s[k] == 2048:
				flag = True
		y = cnt // 2
		s1 = s1 + [x * 2] * y
		s = s1.copy()
	if flag:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
n_queries = int(stdin.readline())
for i in range(n_queries):
	length = int(stdin.readline())
	arr = [int(x) for x in stdin.readline().split()]
	summ = 0
	flag = 0
	for j in range(length):
		summ += arr[j]
		if summ & 2048 == 2048:
			flag = 1
			print('YES')
			break
	if flag == 0:
		print('NO')


for _ in range(int(input())):
	num = int(input())
	l = input().split()
	sum = 0
	if '2048' in l:
		print('YES')
	else:
		for i in l:
			if int(i) < 2048:
				sum += int(i)
			else:
				sum += 0
		if sum >= 2048:
			print('YES')
		else:
			print('NO')


n = int(input())
for i in range(n):
	n = int(input())
	li = list(map(int, input().split()))
	se = set(li)
	flag = 0
	while len(li) >= len(set(li)):
		if 2048 not in li and len(li) != len(set(li)):
			for i in range(len(li)):
				if li.count(li[i]) >= 2:
					j = li[i]
					li.remove(j)
					li.remove(j)
					li.append(2 * j)
					break
		else:
			break
	if 2048 in li:
		print('YES')
	else:
		print('NO')


from sys import stdin

def main():
	l = stdin.read().splitlines()[2::2]
	for (i, s) in enumerate(l):
		l[i] = ('NO', 'YES')[sum((e for e in map(int, s.split()) if e < 4096)) > 2047]
	print('\n'.join(l))
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if 2048 in a:
		print('YES')
	else:
		s = 0
		for i in a:
			if i <= 1024:
				s += i
		if s >= 2048:
			print('YES')
		else:
			print('NO')


t = int(input())
while t > 0:
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	l = 2048
	for i in s[-1::-1]:
		if l > 0 and i <= 2048:
			l = l - i
	if l == 0:
		print('Yes')
	else:
		print('No')
	t = t - 1


import sys
input = lambda : sys.stdin.readline().rstrip()
from math import log2
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	p = [0] * 12
	for i in a:
		if i > 2048:
			continue
		p[int(log2(i))] += 1
	for i in range(len(p) - 1):
		p[i + 1] += p[i] // 2
		p[i] = int(p[i]) % 2
	if p[11] > 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	c = []
	for i in range(n):
		if a[i] <= 2048:
			c.append(a[i])
	if sum(c) >= 2048:
		print('YES')
	else:
		print('NO')
	t -= 1


q = int(input())
for i in range(q):
	n = int(input())
	s = [int(x) for x in input().split()]
	t = []
	for j in range(n):
		if s[j] <= 2048:
			t = t + [s[j]]
	if sum(t) >= 2048:
		print('YES')
	else:
		print('NO')


import math

class Read:

	@staticmethod
	def string():
		return input()

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

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

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

def solve():
	n = Read.int()
	s = Read.list_int()
	res = 0
	for i in s:
		res += i if i <= 2048 else 0
	if res >= 2048:
		print('YES')
	else:
		print('NO')
query_count = Read.int()
for j in range(query_count):
	solve()


q = int(input())
for i in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	cur = 1
	while cur < 2048:
		while s.count(cur) > 1:
			del s[s.index(cur)]
			del s[s.index(cur)]
			s.append(cur * 2)
		cur *= 2
	if 2048 in s:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if 2048 in a:
		print('YES')
	elif sum(a) < 2048:
		print('NO')
	else:
		a.sort()
		while len(a) != len(set(a)):
			for i in range(n):
				try:
					if a[i] == a[i + 1]:
						a[i] += a[i]
						del a[i + 1]
				except:
					pass
			if 2048 in a:
				print('YES')
				break
			a.sort()
		else:
			print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	l = s.count(2048)
	if l > 0:
		print('YES')
	else:
		i = 0
		f = len(s)
		while f > 1 and i < f - 1:
			if s[i] == s[i + 1]:
				s.append(2 * s[i])
				s.remove(s[i])
				s.remove(s[i])
				f = len(s)
				if 2048 in s:
					print('YES')
					break
				else:
					s.sort()
			else:
				i += 1
		if s.count(2048) == 0:
			print('NO')


for _ in range(int(input())):
	q = int(input())
	arr = [int(x) for x in input().split()]
	s = 0
	for i in arr:
		if i <= 2048:
			s += i
	if s >= 2048:
		print('YES')
	else:
		print('NO')


import sys
input = lambda : sys.stdin.readline().strip()
q = int(input())
for i in range(q):
	n = int(input())
	tot = 2048
	ls = list(map(int, input().split()))
	ls.sort()
	ls.reverse()
	for i in ls:
		if i <= tot:
			tot -= i
		if tot == 0:
			print('YES')
			break
	else:
		print('NO')


q = int(input())
for ii in range(q):
	n = int(input())
	s = list(map(int, input().split(' ')))
	t = 0
	tt = False
	s.sort()
	s = reversed(s)
	for a in s:
		if a > 2048:
			pass
		else:
			t += a
			if t >= 2048:
				tt = True
				break
	print('YES' if tt else 'NO')


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

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

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

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

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

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

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

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

def S():
	return input()

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

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

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

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

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

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

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

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		b = [c for c in a if c <= 2048]
		rr.append(YES(sum(b) >= 2048))
	return JA(rr, '\n')
print(main())


n = int(input())
l = []
x = []
for i in range(n):
	l.append(int(input()))
	x.append(list(map(int, input().split())))
for i in range(n):
	y = []
	flag = 0
	y = sorted(x[i])
	s = 0
	j = -1
	while j >= -len(y):
		if y[j] > 2048:
			j -= 1
			continue
		s = s + y[j]
		if s == 2048:
			flag = 1
			break
		j -= 1
	if flag == 1:
		print('YES')
	if flag == 0:
		print('NO')


import math
q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a = list(sorted(a))
	cnt = [0 for i in range(12)]
	for i in a:
		if math.log(i, 2) < 12:
			cnt[int(math.log(i, 2))] += 1
	for i in range(11):
		if cnt[i] >= 2:
			cnt[i + 1] += cnt[i] // 2
			cnt[i] = cnt[i] % 2
	if cnt[11] > 0:
		print('YES')
	else:
		print('NO')


from itertools import combinations
t = int(input())
for never_used in range(t):
	n_q = int(input())
	li = list(map(int, input().split()))
	if sum(li) < 2048:
		print('NO')
		continue
	if min(li) > 2048:
		print('NO')
		continue
	res = 2048
	flag = 0
	if res in li:
		print('YES')
		continue
	li2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
	li3 = []
	for j in range(len(li2)):
		for k in range(li.count(li2[j])):
			li3.append(li2[j])
	h = 0
	while True:
		if li3.count(li2[h]) >= 2:
			li3.remove(li2[h])
			li3.remove(li2[h])
			li3.append(2 * li2[h])
			if res in li3:
				print('YES')
				flag = 1
				break
		if h == len(li2) - 1:
			break
		if li3.count(li2[h]) < 2:
			h = h + 1
		else:
			continue
	if flag == 0:
		print('NO')


from collections import defaultdict
q = int(input())
for _ in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	hash = defaultdict(int)
	for i in l:
		hash[i] += 1
	la = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2 - 48]
	for i in la:
		z = hash[i] // 2
		k = i * 2
		hash[k] += z
	if hash[2048] > 0:
		print('YES')
	else:
		print('NO')


q = int(input())
while q != 0:
	n = int(input())
	s = [int(i) for i in input().split(' ')]
	sum = 0
	for i in s:
		if i <= 2048:
			sum += i
	if sum >= 2048:
		print('Yes')
	else:
		print('No')
	q -= 1


c1 = int(input())
for n1 in range(0, c1):
	c2 = int(input())
	l = input().split()
	s = 0
	for n2 in range(0, c2):
		if int(l[n2]) == 2048:
			s = -10000000000000000000
			break
		elif int(l[n2]) < 2000:
			s = s + int(l[n2])
	if s >= 2048:
		print('YES')
	elif s < 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	l = [int(y) for y in input().split() if int(y) <= 2048]
	print('Yes' if sum(l) >= 2048 else 'No')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	dp = 1
	for i in range(n):
		if a[i] > 2048:
			continue
		dp |= dp << a[i]
	if dp & 1 << 2048:
		print('YES')
	else:
		print('NO')


def increase_count(s, j):
	c = s.get(j * 2, 0)
	s.update({j: 0})
	if c == 2:
		s = increase_count(s, j * 2)
	elif c == 1:
		s = increase_count(s, j * 2)
	else:
		s.update({j * 2: c + 1})
	return s

def start_program():
	for i in range(int(input())):
		solution = dict()
		n = int(input())
		set_data = list(map(int, input().split(' ')))
		for j in set_data:
			count = solution.get(j, 0)
			if count == 2:
				solution = increase_count(solution, j)
			elif count == 1:
				solution = increase_count(solution, j)
			else:
				solution.update({j: count + 1})
		if 2048 in solution:
			print('YES')
		else:
			print('NO')
start_program()


import math
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if 2048 in a:
		print('YES')
		continue
	f = {}
	for i in a:
		if i < 2048:
			if i in f:
				f[i] += 1
			else:
				f[i] = 1
	for i in range(12):
		if 2 ** i in f:
			if 2 * 2 ** i in f:
				f[2 * 2 ** i] += f[2 ** i] // 2
			else:
				f[2 * 2 ** i] = f[2 ** i] // 2
	if 2048 in f.keys():
		if f[2048] >= 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


num_queries = int(input())
for _ in range(num_queries):
	num_inputs = int(input())
	inputs = sorted(filter(lambda n: n <= 2048, map(int, input().split())))
	while 2048 not in inputs:
		try:
			if inputs[0] == inputs[1]:
				if inputs[0] == 2048:
					break
				inputs[1] *= 2
				inputs = sorted(inputs)
			inputs = inputs[1:]
		except IndexError:
			break
	if 2048 in inputs:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	found = False
	d = dict()
	n = int(input())
	arr = [i for i in map(int, input().split())]
	for i in arr:
		if i not in d.keys():
			d[i] = 1
		else:
			temp = i + i
			del d[i]
			while temp in d.keys():
				del d[temp]
				temp = temp + temp
			d[temp] = 1
		if 2048 in d:
			found = True
			break
	if found:
		print('YES')
	else:
		print('NO')


import math
import os

def solve(n, arr):
	count_dict = {}
	start = 1
	for i in range(0, 12, 1):
		count_dict[start] = 0
		start *= 2
	for i in range(n):
		if arr[i] <= 2048:
			count_dict[arr[i]] += 1
	count_dict_keys = list(count_dict.keys())
	for i in range(1, 12, 1):
		count_dict[count_dict_keys[i]] += int(math.floor(count_dict[count_dict_keys[i - 1]] / 2))
	if count_dict[2048] > 0:
		return 'Yes'
	else:
		return 'No'
q = int(input())
for q_itr in range(0, q, 1):
	n = int(input())
	arr = input()
	arr = arr.split()
	arr = list(map(int, arr))
	answer = solve(n, arr)
	print(answer)


def which(n):
	x = -1
	while n > 0:
		n = n // 2
		x += 1
	return x
q = int(input())
for you in range(q):
	n = int(input())
	arr = [0 for i in range(30)]
	poss = 0
	l = input().split()
	li = [int(i) for i in l]
	for i in li:
		arr[which(i)] += 1
	for i in range(29):
		if i == 11 and arr[i] > 0:
			poss = 1
			break
		arr[i + 1] += arr[i] // 2
		arr[i] %= 2
	if poss:
		print('yes')
	else:
		print('no')


t = input()
t = int(t)
while t:
	n = input()
	n = int(n)
	l = list(map(int, input().split()))
	d = {}
	c = 0
	for i in range(n):
		d[l[i]] = d.get(l[i], 0) + 1
	k = 0
	while k <= n:
		for i in d:
			if i == 2048:
				k = n
				c = 1
		for i in d:
			if d[i] >= 2 and d[i] < 2048:
				d[i * 2] = d.get(i * 2, 0) + 1
				d[i] = d[i] - 2
				break
		k += 1
	if c == 1:
		print('YES')
	else:
		print('NO')
	t -= 1


import math
nCases = int(input())
for _ in range(nCases):
	nVals = int(input())
	vals = sorted([int(x) for x in input().split()])
	reg = [0 for _ in range(12)]
	for val in vals:
		if val > 2048:
			break
		reg[int(math.log2(val))] += 1
	gotIt = False
	for (i, valu) in enumerate(reg):
		if reg[11] > 0:
			gotIt = True
			break
		if i == 11:
			break
		num = int(valu / 2)
		reg[i + 1] += num
	if gotIt:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	beki = [0] * 50
	for i in range(n):
		beki[s[i].bit_length() - 1] += 1
	for i in range(29):
		beki[i + 1] += beki[i] // 2
	if beki[11] > 0:
		print('YES')
	else:
		print('NO')


n_query = int(input())
for i in range(n_query):
	n_elements = int(input())
	query = [int(m) for m in input().split(' ')]
	test = True
	while test:
		combined = False
		query.sort(reverse=True)
		for j in range(len(query)):
			if query[j] == 2048:
				print('YES')
				combined = True
				test = False
				break
			if j < len(query) - 1 and query[j] == query[j + 1]:
				query.insert(j, 2 * query[j])
				del query[j + 1:j + 3]
				combined = True
				break
		if not combined:
			print('NO')
			test = False


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().strip().split()))
	if 2048 in l:
		print('YES')
	else:
		for i in range(n):
			if l[i] > 2048:
				l[i] = 0
		if sum(l) >= 2048:
			print('YES')
		else:
			print('NO')


t = int(input().strip())
for i in range(t):
	n = int(input())
	l = filter(lambda x: x < 2049, map(int, input().strip().split()))
	if sum(l) >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	a = [int(item) for item in input().split()]
	val = 0
	for item in a:
		if item <= 2048:
			val += item
	if val >= 2048:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	k = 0
	s = 0
	while s < 2048 and k < n:
		if a[k] <= 2048:
			s += a[k]
		k += 1
	if s == 2048:
		print('yes')
	else:
		print('no')


Q = int(input())
for q in range(Q):
	n = int(input())
	L = list(map(int, input().split()))
	pow2 = [0] * 12
	for l in L:
		for i in range(0, 12):
			if 2 ** i == l:
				pow2[i] += 1
	flag = True
	while flag:
		flag = False
		for i in range(11):
			pow2[i + 1] += pow2[i] // 2
			pow2[i] = pow2[i] % 2
			if pow2[i + 1] > 1 and i + 1 != 11:
				flag = True
	if pow2[-1] > 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	for p in l:
		if p <= 2048:
			l1.append(p)
	if sum(l1) >= 2048:
		print('YES')
	else:
		print('NO')


def solution():
	k = int(input())
	a = [int(x) for x in input().split()]
	n2048 = a.count(2048)
	if n2048 > 0:
		return 'Yes'
	n1024 = a.count(1024)
	if n1024 >= 2:
		return 'Yes'
	n512 = a.count(512)
	n256 = a.count(256)
	n128 = a.count(128)
	n64 = a.count(64)
	n32 = a.count(32)
	n16 = a.count(16)
	n8 = a.count(8)
	n4 = a.count(4)
	n2 = a.count(2)
	n1 = a.count(1)
	n2 += n1 // 2
	n4 += n2 // 2
	n8 += n4 // 2
	n16 += n8 // 2
	n32 += n16 // 2
	n64 += n32 // 2
	n128 += n64 // 2
	n256 += n128 // 2
	n512 += n256 // 2
	n1024 += n512 // 2
	n2048 += n1024 // 2
	if n2048 > 0:
		return 'Yes'
	return 'No'
n = int(input())
for i in range(n):
	print(solution())


n = int(input())
for i in range(0, n):
	m = int(input())
	s = 0
	num0 = str(input())
	num = [int(n) for n in num0.split()]
	for j in range(0, m):
		if num[j] <= 2048:
			s += num[j]
	if s >= 2048:
		print('YES')
	else:
		print('NO')


def twopow(n):
	c = 0
	while n > 1:
		c += 1
		n = n // 2
	return c
t = int(input())
for i in range(t):
	freq = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0}
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	for i in arr:
		if twopow(i) not in freq:
			freq[twopow(i)] = 1
		else:
			freq[twopow(i)] += 1
	key = [*freq]
	if 11 in key:
		print('YES')
	else:
		for i in range(0, 10):
			if freq[i] > 0:
				freq[i + 1] += freq[i] // 2
		if freq[10] // 2 >= 1:
			print('YES')
		else:
			print('NO')


n = int(input())
for i in range(0, n):
	num = int(input())
	list = [int(l) for l in input().split()]
	list.sort(reverse=True)
	if 2048 in list:
		print('YES')
	else:
		while num > 1 and 2048 not in list:
			if list[num - 1] == list[num - 2]:
				list[num - 2] = 2 * list[num - 1]
				list.sort(reverse=True)
				list.pop(num - 1)
				num = num - 1
			else:
				list.pop(num - 1)
				num = num - 1
		else:
			if 2048 in list:
				print('YES')
			else:
				print('NO')


for _ in range(int(input())):
	i = input()
	numbers = list(map(int, input().split()))
	while 2048 not in numbers and len(set(numbers)) < len(numbers):
		for number in numbers:
			if numbers.count(number) > 1:
				numbers.append(number * 2)
				numbers.remove(number)
				numbers.remove(number)
	if 2048 in numbers:
		print('yes')
	else:
		print('no')


q = int(input())
for i in range(q):
	n = int(input())
	s = [int(i) for i in input().split()]
	if 2048 in s:
		print('YES')
	elif sum(s) < 2048:
		print('NO')
	else:
		while len(set(s)) != len(s) and 2048 not in s:
			for j in range(len(s)):
				br = False
				for k in range(j + 1, len(s)):
					if s[j] == s[k]:
						s.append(s[j] + s[k])
						del s[j]
						del s[k - 1]
						br = True
						break
				if br:
					break
		if 2048 in s:
			print('YES')
		else:
			print('NO')


q = int(input())
answer = []
for i in range(q):
	n = int(input())
	multiset = [int(i) for i in input().split()]
	multiset.sort(reverse=True)
	somme = 0
	for nb in multiset:
		if nb <= 2048:
			somme += nb
		if somme >= 2048:
			break
	if somme == 2048:
		answer.append(True)
	else:
		answer.append(False)
for line in answer:
	if line:
		print('YES')
	else:
		print('NO')


from collections import Counter
for TT in range(1, int(input()) + 1):
	n = int(input())
	cnt = Counter(map(int, input().split()))

	def f(x=2048):
		if x == 0:
			return False
		if cnt.get(x, 0) > 0:
			cnt[x] -= 1
			return True
		return f(x // 2) and f(x // 2)
	print('Yes' if f() else 'No')


for q in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	d1 = {}
	for item in l1:
		if item not in d1:
			d1[item] = 1
		else:
			d1[item] += 1
	i = 1
	while i < 2048:
		if i not in d1:
			i *= 2
			continue
		if d1[i] == 1:
			i *= 2
			continue
		if 2 * i not in d1:
			d1[2 * i] = d1[i] // 2
		else:
			d1[2 * i] += d1[i] // 2
		i *= 2
	if 2048 in d1:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	n = int(input())
	a = [int(i) for i in input().split()]
	a = sorted(a, reverse=True)
	summ = 0
	flag = 0
	for i in range(n):
		if a[i] > 2048:
			continue
		elif a[i] == 2048:
			flag = 1
			break
		else:
			summ += a[i]
			if summ == 2048:
				flag = 1
				break
	if flag == 1:
		print('yes')
	else:
		print('no')
	t -= 1


def is_possible(a):
	return 'YES' if sum(filter(lambda x: x < 4096, a)) >= 2048 else 'NO'
for i in range(int(input())):
	input()
	print(is_possible(map(int, input().split())))


from queue import PriorityQueue as PQ

def func():
	n = int(input())
	que = PQ()
	num = [int(x) for x in input().split()]
	for i in num:
		que.put(i)
	pre = 0
	fin = 'NO'
	while que.empty() == False:
		cnt = que.get()
		if cnt == 2048:
			fin = 'YES'
			break
		if cnt == pre:
			que.put(cnt * 2)
			pre = que.get()
		else:
			pre = cnt
		if pre == 2048:
			fin = 'YES'
			break
	print(fin)
q = int(input())
for i in range(0, q):
	func()


from collections import defaultdict as dd
for i in range(int(input())):
	n = int(input())
	a = dd(int)
	for i in map(int, input().split()):
		a[i] += 1
	i = 1
	while i < 2048:
		a[i * 2] += a[i] // 2
		i *= 2
		if a[2048] > 0:
			break
	print(('NO', 'YES')[a[2048] > 0])


count = []
from math import log
from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ok = False
	for i in l:
		if i == 2048:
			ok = True
			break
	if not ok:
		sum_ = 0
		for i in range(n):
			if l[i] < 2048:
				sum_ += l[i]
			if sum_ >= 2048:
				ok = True
	if ok:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	for i in a:
		if i == 2048:
			n = 0
			print('YES')
			break
		elif i > 2048:
			a.remove(i)
	a.sort()
	cnt = 0
	if n != 0:
		for i in a[::-1]:
			if cnt + i <= 2048:
				cnt += i
			if cnt == 2048:
				n = 0
				print('YES')
				break
	if n != 0:
		print('NO')


def ain():
	return map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	count = [0] * 12
	for x in a:
		if x == 1:
			count[0] += 1
		if x == 2:
			count[1] += 1
		if x == 4:
			count[2] += 1
		if x == 8:
			count[3] += 1
		if x == 16:
			count[4] += 1
		if x == 32:
			count[5] += 1
		if x == 64:
			count[6] += 1
		if x == 128:
			count[7] += 1
		if x == 256:
			count[8] += 1
		if x == 512:
			count[9] += 1
		if x == 1024:
			count[10] += 1
		if x == 2048:
			count[11] += 1
	for i in range(1, 12):
		count[i] += count[i - 1] // 2
	if count[11] > 0:
		print('YES')
	else:
		print('NO')


queries = int(input())
for x in range(queries):
	n = int(input())
	nums = [int(x) for x in input().split()]
	nums.sort()
	if 2048 in nums:
		print('YES')
		continue
	frequency = {1: 0, 2: 0, 4: 0, 8: 0, 16: 0, 32: 0, 64: 0, 128: 0, 256: 0, 512: 0, 1024: 0}
	for x in nums:
		if x in frequency:
			frequency[x] += 1
		else:
			frequency[x] = 1
	frequency[2] += frequency[1] // 2
	frequency[4] += frequency[2] // 2
	frequency[8] += frequency[4] // 2
	frequency[16] += frequency[8] // 2
	frequency[32] += frequency[16] // 2
	frequency[64] += frequency[32] // 2
	frequency[128] += frequency[64] // 2
	frequency[256] += frequency[128] // 2
	frequency[512] += frequency[256] // 2
	frequency[1024] += frequency[512] // 2
	if frequency[1024] >= 2:
		print('YES')
	else:
		print('NO')


dic = {1024: 10, 512: 9, 256: 8, 128: 7, 64: 6, 32: 5, 16: 4, 8: 3, 4: 2, 2: 1, 1: 0}
for _ in range(int(input())):
	n = int(input())
	p = [0 for i in range(12)]
	l = []
	flag = False
	for i in input().split():
		i = int(i)
		if i > 2048:
			continue
		if i == 2048:
			flag = True
			break
		else:
			for d in dic:
				if i & d:
					while d < 2048 and p[dic[d]]:
						p[dic[d]] = 0
						d *= 2
					if d == 2048:
						flag = True
						break
					p[dic[d]] = 1
			if flag:
				break
	if flag:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = []
	for i in a:
		if i <= 2048:
			b.append(i)
	if sum(b) >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	t = False
	a = list(map(int, input().split()))
	a.sort()
	if 2048 in a:
		t = True
	elif n == 1:
		t = False
	else:
		while not 2048 in a:
			a.sort()
			if min(a) > 2048:
				break
			if a[0] == a[1] and n > 1:
				a[1] = 2 * a[1]
				a[0] = 2049
			elif n > 1:
				a[0] = 2049
				a.sort()
			if 2048 in a:
				t = True
				break
	if t:
		print('YES')
	else:
		print('NO')


x = int(input())
for i in range(x):
	s = int(input())
	d = [int(x) for x in input().split()]
	final = 0
	for j in range(s):
		if d[j] <= 2048:
			final += d[j]
	if final >= 2048:
		print('YES')
	else:
		print('NO')


import math
import collections

def check(a):
	cnt = collections.Counter(a)
	new_cnt = collections.defaultdict(int)
	for k in cnt:
		new_cnt[k] = cnt[k]
	keys = list(new_cnt.keys())
	max_key = max(keys)
	for k in range(max_key + 10):
		new_cnt[k + 1] += new_cnt[k] // 2
		if k == 11 and new_cnt[k] >= 1:
			print('YES')
			return
	if new_cnt[11] >= 1:
		print('YES')
		return
	print('NO')
q = int(input())
for i in range(q):
	n = int(input())
	a = [len(bin(int(s))) - 3 for s in input().split(' ')]
	check(a)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = 0
	for t in l:
		if t <= 2048:
			ans += t
	if ans >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort(reverse=True)
	r = 2048
	c = 0
	for i in s:
		if i <= r:
			r -= i
			if r == 0:
				c = 1
				break
	if c == 1:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline

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

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

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

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

def addDictList(d, key, val):
	if key not in d:
		d[key] = []
	d[key].append(val)

def addDictInt(d, key, val):
	if key not in d:
		d[key] = 0
	d[key] = val

def addDictCount(d, key):
	if key not in d:
		d[key] = 0
	d[key] += 1

def addDictSum(d, key, val):
	if key not in d:
		d[key] = 0
	d[key] += val
t = getInt()
for _ in range(t):
	n = getInt()
	a = getList()
	s = 0
	for i in range(n):
		if a[i] < 2049:
			s += a[i]
	if s < 2048:
		print('NO')
	else:
		print('YES')


from collections import Counter, defaultdict
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(I()):
	n = I()
	a = LI()
	d = defaultdict(int)
	d = Counter(a)
	flag = 0
	for i in range(29):
		if 2 ** i > 2048:
			break
		a = d[2 ** i]
		d[2 ** i * 2] += a // 2
		if d[2048] >= 1:
			flag = 1
			break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
output = []
for _ in range(t):
	n = int(input())
	list_numbers = list(map(int, input().split()))
	final_list = sorted((i for i in list_numbers if i <= 2048), reverse=True)
	sum_val = 0
	flag = 0
	for val in final_list:
		sum_val += val
		if sum_val == 2048:
			flag = 1
			break
		else:
			continue
	if flag == 0:
		output.append('NO')
	else:
		output.append('YES')
for x in output:
	print(x)


import math
q = int(input())
for _ in range(q):
	n = int(input())
	s = [int(x) for x in input().split()]
	arr = s
	flag = 0
	kk = dict()
	while flag == 0:
		flag = 1
		h = []
		for i in range(0, len(arr)):
			kk[arr[i]] = 1
		d = dict()
		for i in range(0, len(arr)):
			if d.get(arr[i]) == None:
				d[arr[i]] = 1
				h.append(arr[i])
			else:
				d[arr[i]] += 1
				flag = 0
		g = []
		for i in range(0, len(h)):
			temp = d[h[i]]
			for j in range(temp // 2):
				g.append(h[i] * 2)
			if temp % 2 != 0:
				g.append(h[i])
		arr = g
	if kk.get(2048) == None:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	_ = input()
	l = [int(c) for c in input().split() if int(c) <= 2048]
	print('YNEOS'[sum(l) < 2048::2])


for i in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	su = 0
	for i in range(n):
		if arr[i] <= 2048:
			su += arr[i]
		if su >= 2048:
			break
	print('yes' if su >= 2048 else 'no')


q = int(input())
for i in range(q):
	n = int(input())
	s1 = list(map(int, input().split()))
	s1.sort()
	num = 0
	for i in s1:
		if i > 2048:
			break
		num += i
	if num >= 2048:
		print('YES')
	else:
		print('NO')


N = 29
M = 11
D = {2 ** i: i for i in range(M + 1)}
q = int(input())
for _ in range(q):
	n = int(input())
	A = [0] * (M + 1)
	for x in [int(x) for x in input().split()]:
		if x <= 2 ** M:
			A[D[x]] += 1
	for i in range(M):
		A[i + 1] += A[i] // 2
	print(['NO', 'YES'][A[M] != 0])


for _ in range(int(input())):
	n = int(input())
	l = filter(lambda x: x <= 2048, map(int, input().split()))
	print('Yes' if sum(l) >= 2048 else 'No')


for _ in range(int(input())):
	n = int(input())
	s = [int(i) for i in input().split()]
	arr = []
	for i in range(n):
		if s[i] <= 2048:
			arr.append(s[i])
	arr.sort(reverse=True)
	num = 2048
	flag = 0
	for i in range(len(arr)):
		num -= arr[i]
		if num == 0:
			flag = 1
			break
	if flag:
		print('YES')
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase

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

def prime(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 divisors(n):
	i = 1
	div = []
	while i <= math.sqrt(n):
		if n % i == 0:
			if n / i == i:
				div.append(i)
			else:
				div.append(i)
				div.append(n // i)
		i = i + 1
	return div

def solve():
	n = int(input())
	ls = list(map(int, input().split()))
	s = 0
	for i in ls:
		if i <= 2048:
			s = s + i
	if s >= 2048:
		return 'YES'
	else:
		return 'NO'

def main():
	for _ in range(int(input())):
		print(solve())
	pass
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')
main()


def Solve():
	for _ in range(int(input())):
		n = input()
		fuad = [int(x) for x in input().split() if int(x) <= 2048]
		print('YES' if sum(fuad) >= 2048 else 'NO')
Solve()


import math
Q = int(input())
for q in range(Q):
	n = int(input())
	m = [0] * 12
	num = [int(x) for x in input().split()]
	for i in range(n):
		if num[i] <= 2048:
			m[int(math.log(num[i], 2))] += 1
	success = False
	while True:
		operation = 0
		if m[11] >= 1:
			success = True
			break
		for i in range(10, -1, -1):
			if m[i] >= 2:
				m[i] -= 2
				m[i + 1] += 1
				operation += 1
		if operation == 0:
			break
	if success == True:
		print('YES')
	else:
		print('NO')


import sys
import itertools
import math
import collections
from collections import Counter

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

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

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

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

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

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

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

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

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)
t = ii()
for i in range(t):
	n = ii()
	d = li()
	t = {2 ** i: 0 for i in range(0, 12)}
	for i in d:
		if i <= 2048:
			t[i] += 1
	while True:
		f = False
		if t[2048] > 0:
			print('YES')
			break
		for j in t:
			if t[j] > 1:
				f = True
				if j != 2048:
					t[j * 2] += t[j] // 2
					t[j] -= t[j] // 2 * 2
		if not f:
			print('NO')
			break


a = int(input())
for i in range(a):
	b = int(input())
	c = list(map(int, input().split()))
	d = False
	sum = 0
	for j in c:
		sum += j
		sumstr = '0000000000' + bin(sum)
		if sumstr[-12] == '1':
			d = True
			break
	if d:
		print('YES')
	else:
		print('NO')


import collections as cl
for _ in range(int(input())):
	n = int(input())
	a = dict(cl.Counter(map(int, input().split())))
	k = 1
	if k not in a:
		a[k] = 0
	while k < 2048:
		if k * 2 not in a:
			a[k * 2] = 0
		a[k * 2] += a[k] // 2
		k *= 2
	print(('NO', 'YES')[a[2048] > 0])


q = int(input())
for _ in range(q):
	n = int(input())
	ar = list(map(int, input().split()))
	lk = {}
	for elm in ar:
		if elm not in lk:
			lk[elm] = 1
		else:
			lk[elm] += 1
	if 2048 in lk:
		print('YES')
		continue
	for i in range(11):
		curr = 1 << i
		if curr not in lk:
			continue
		if lk[curr] > 1:
			if 2 * curr not in lk:
				lk[2 * curr] = lk[curr] // 2
			else:
				lk[2 * curr] += lk[curr] // 2
	if 2048 in lk:
		print('YES')
	else:
		print('NO')


from sys import *
from typing import *
from collections import *
from string import *
from itertools import *
from math import *
import json
from fractions import *
from typing import *
from collections import *
from bisect import *
from random import *
cin_buffer = []
cin_buffer_ptr = 0

def next() -> str:
	global cin_buffer
	global cin_buffer_ptr
	if cin_buffer_ptr >= len(cin_buffer):
		cin_buffer = input().split()
		cin_buffer_ptr = 0
		return next()
	else:
		res = cin_buffer[cin_buffer_ptr]
		cin_buffer_ptr += 1
		return res

def next_int() -> int:
	return int(next())
for _ in range(next_int()):
	n = next_int()
	cnt = Counter((next_int() for _ in range(n)))
	i = 1
	while i < 2048:
		cnt[i * 2] += cnt[i] // 2
		i *= 2
	print('YES' if cnt[2048] else 'NO')


q = int(input())
for cases in range(q):
	n = int(input())
	nums = list(map(int, input().split()))
	if 2048 in nums:
		print('YES')
		continue
	else:
		nums = sorted(nums)
		mark = 0
		for i in range(n):
			for j in range(i + 1, n + 1):
				ans = sum(nums[i:j])
				if ans == 2048:
					mark = 1
					print('YES')
					break
			if mark == 1:
				break
		if mark == 0:
			print('NO')


q = int(input())
for i in range(q):
	a = int(input())
	ll = sorted([int(k) for k in input().split() if int(k) <= 2048], reverse=True)
	ans = 0
	for k in ll:
		if ans + k <= 2048:
			ans += k
		else:
			continue
	print('YES' if ans == 2048 else 'NO')


import sys
import bisect as b
import math
from collections import defaultdict as dd
input = sys.stdin.readline
mo = 10 ** 9 + 7

def cin():
	return map(int, sin().split())

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

def sin():
	return input()

def inin():
	return int(input())
for i in range(inin()):
	n = inin()
	l = ain()
	s = 0
	for i in l:
		if i <= 2048:
			s += i
	if s >= 2048:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	input()
	c = list(map(int, input().split()))
	d = False
	sum = 0
	for j in c:
		sum += j
		if sum & 2048:
			d = True
			break
	print('YES' if d else 'NO')


for _ in range(int(input())):
	lens = int(input())
	vals = [int(x) for x in input().split()]
	vals = [x for x in vals if x <= 2048]
	if sum(vals) < 2048:
		print('NO')
	else:
		print('YES')


import math as m
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	arr = [0] * 12
	for i in l:
		if i <= 2048:
			arr[int(m.log(i, 2))] += 1
	for i in range(11):
		arr[i + 1] += arr[i] // 2
	if arr[11] >= 1:
		print('YES')
	else:
		print('NO')


n = int(input())
results = []
for i in range(n):
	m = int(input())
	num_arr = map(int, input().split())
	num_arr = filter(lambda i: i <= 2048, num_arr)
	results.append(sum(num_arr))
results = ['YES' if x >= 2048 else 'NO' for x in results]
print('\n'.join(results))


q = int(input())
for i in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	res = []
	for _ in s:
		if _ <= 2048:
			res.append(_)
	if sum(res) >= 2048:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	j = 0
	a = int(input())
	num = [int(x) for x in input().split()]
	if 2048 in num:
		print('YES')
		continue
	for a in range(a):
		if num[j] > 2048:
			del num[j]
		else:
			j += 1
	if sum(num) >= 2048:
		print('YES')
		continue
	elif sum(num) < 2048:
		print('NO')
		continue


import math

def loga2(x):
	k = int(math.floor(math.log(x) / math.log(2)))
	return k

def process():
	id = 0
	n = int(input())
	s = input()
	a = []
	b = s.split(' ')
	for x in b:
		k = int(x)
		if k == 2048:
			id = 1
			break
		elif k < 2048:
			a.append(k)
	if id == 1:
		print('YES')
	else:
		t = 2048
		a.sort(reverse=True)
		for x in a:
			if t >= x:
				t = t - x
				if t == 0:
					id = 1
					break
		if id == 0:
			print('NO')
		else:
			print('YES')
q = int(input())
for i in range(0, q):
	process()


from math import *
from sys import *
from collections import defaultdict
import os, sys
from io import IOBase, BytesIO
M = 10 ** 9 + 7

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

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

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

def alldivisors(n):
	list = []
	arr = []
	for i in range(1, int(sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				arr += [i]
			else:
				arr += [i]
				list.append(n // i)
	arr += list[::-1]
	return arr

def primefactorisation(n):
	potentional_p = 3
	itog_list = defaultdict(int)
	if n % 2 == 0:
		itog_list[2] = 0
	while n % 2 == 0:
		n = n // 2
		itog_list[2] += 1
	while n - 1:
		if potentional_p > n ** 0.5:
			itog_list[n] += 1
			return itog_list
		while n % potentional_p == 0:
			n = n // potentional_p
			itog_list[potentional_p] += 1
		potentional_p += 2
	return itog_list

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		dict = defaultdict(int)
		for x in a:
			dict[x] += 1
		dict[2] += dict[1] // 2
		dict[4] += dict[2] // 2
		dict[8] += dict[4] // 2
		dict[16] += dict[8] // 2
		dict[32] += dict[16] // 2
		dict[64] += dict[32] // 2
		dict[128] += dict[64] // 2
		dict[256] += dict[128] // 2
		dict[512] += dict[256] // 2
		dict[1024] += dict[512] // 2
		dict[2048] += dict[1024] // 2
		if dict[2048] > 0:
			print('YES')
		else:
			print('NO')
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

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

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

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

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

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		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')
main()


q = int(input())
for i in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	if 2048 in s:
		print('yes')
	else:
		for a in range(11):
			b = 2 ** a
			while s.count(b) >= 2:
				c = b * 2
				s.remove(b)
				s.remove(b)
				s.append(c)
		if 2048 in s:
			print('yes')
		else:
			print('no')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in range(12):
		d[2 ** i] = 0
	for i in l:
		if i <= 2048:
			d[i] += 1
	for i in range(11):
		d[2 ** (i + 1)] += d[2 ** i] // 2
	if d[2048] > 0:
		print('YES')
	else:
		print('NO')


q = int(input())
J = [2 ** i for i in range(12)]
for _ in range(q):
	n = int(input())
	cunt = [0] * 12
	In = list(map(int, input().split(' ')))
	In.sort()
	for i in range(n):
		for j in range(12):
			if In[i] == J[j]:
				cunt[j] += 1
				break
	for i in range(11):
		cunt[i + 1] += cunt[i] // 2
	if cunt[11] >= 1:
		print('YES')
	else:
		print('NO')


from math import log2
q = int(input())
i = 0
f = 0
a = [0 for _ in range(30)]
for _ in range(q):
	n = int(input())
	a1 = [int(i) for i in input().split()]
	for i in range(len(a1)):
		a[int(log2(a1[i]))] += 1
	for i in range(12):
		if a[i] > 1:
			a[i + 1] += a[i] // 2
	if a[11]:
		print('Yes')
	else:
		print('No')
	a = [0 for _ in range(30)]


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

def IN(f=0):
	if f == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
tc = IN(1)
for _ in range(tc):
	n = IN(1)
	a = IN()
	d = {}
	for i in range(0, 12):
		d[2 ** i] = 0
	for i in a:
		if i in d:
			d[i] += 1
	for i in range(1, 12):
		r = 2 ** i
		p = 2 ** (i - 1)
		d[r] += d[p] // 2
	if d[2048] > 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	m = int(input())
	l = input().split()
	p = 0
	for i in range(m):
		x = int(l[i])
		if x <= 2048:
			p += x
	if p >= 2048:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	c = int(input())
	a = [int(x) for x in input().split()]
	for k in range(11):
		b = a.count(2 ** k)
		a = a + [2 ** (k + 1)] * (b // 2)
	if 2048 in a:
		print('YES')
	else:
		print('NO')


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import *
(t,) = I()
while t:
	t -= 1
	(n,) = I()
	l = I()
	a = [0] * 100
	for i in l:
		c = 0
		while i % 2 == 0:
			c += 1
			i //= 2
		a[c] += 1
	for i in range(1, 13):
		a[i] += a[i - 1] // 2
	if a[11]:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	num = int(input())
	total = 0
	s = [int(x) for x in input().split()]
	for j in range(num):
		if s[j] > 2048:
			total += 0
		else:
			s[j] <= 2048
			total += s[j]
	if total >= 2048:
		print('YES')
	else:
		print('NO')


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

	def cal(n, s):
		for i in range(n):
			for j in range(i, n):
				if sum(s[i:j + 1]) == 2048:
					return 'YES'
		return 'NO'
	print(cal(n, s))


n = int(input())
for i in range(n):
	m = int(input())
	a = [int(i) for i in input().split()]
	sum = 0
	for j in range(0, len(a)):
		if a[j] <= 2048:
			sum = sum + a[j]
	if sum >= 2048:
		print('YES')
	else:
		print('NO')


test = int(input())
for t in range(test):
	n = int(input())
	arr = list(map(int, input().split()))
	new_arr = [el for el in arr if el <= 2048]
	print('YES' if sum(new_arr) >= 2048 else 'NO')


def rec(s, n):
	if n in s:
		s[s.index(n)] = -1
		return True
	if n < 1:
		return False
	n1 = int(n / 2)
	return rec(s, n1) and rec(s, n1)
q = int(input())
for _ in range(q):
	input()
	s = list(map(int, input().split()))
	if rec(s, 2048):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	if 2048 in s:
		print('YES')
	else:
		s.sort()
		k = sum(s)
		if k < 2048:
			print('NO')
		elif k == 2048:
			print('YES')
		else:
			k = sum([i for i in s if i < 2048])
			if k > 2048:
				print('YES')
			else:
				print('NO')


for t in range(int(input())):
	n = input()
	a = [int(i) for i in input().split() if int(i) <= 2048]
	print('YES' if sum(a) >= 2048 else 'NO')


import math
q = int(input())
for t in range(q):
	n = int(input())
	c = []
	for i in range(30):
		c += [0]
	s = [int(i) for i in input().split()]
	for i in s:
		c[int(math.log(i, 2))] += 1
	for i in range(12):
		c[i + 1] += c[i] // 2
	if c[11]:
		print('YES')
	else:
		print('NO')


import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(100000)
input = sys.stdin.readline

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

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

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

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

def read_str_n():
	return list(map(str, input().split()))

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

@mt
def slv(N, S):
	if 2048 in S:
		return 'YES'
	heapq.heapify(S)
	while len(S) >= 2:
		a = heapq.heappop(S)
		b = heapq.heappop(S)
		if a == b:
			if a + b == 2048:
				return 'YES'
			heapq.heappush(S, a + b)
		else:
			heapq.heappush(S, b)
	return 'NO'

def main():
	Q = read_int()
	for _ in range(Q):
		N = read_int()
		S = read_int_n()
		print(slv(N, S))
main()


for _ in range(int(input())):
	n = input()
	l = [int(x) for x in input().split() if int(x) <= 2048]
	print('YES' if sum(l) >= 2048 else 'NO')


q = int(input())
for query in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	sum = 0
	for elem in a:
		if elem <= 2048:
			sum += elem
	if sum >= 2048:
		print('YES')
	else:
		print('NO')


def solution():
	input()
	m = {}
	for n in input().split():
		n = int(n)
		if n == 2048:
			return 'YES'
		elif n > 2048:
			continue
		else:
			m[n] = m.get(n, 0) + 1
	return check(m)

def check(m):
	i = 1
	while i <= 2048:
		iCount = m.get(i, 0)
		m[i * 2] = m.get(i * 2, 0) + iCount // 2
		i = i * 2
	return m.get(2048, 0) > 0
total = int(input())
for i in range(total):
	print('YES' if solution() else 'NO')


q = int(input())
p = 1
dp = [0 for i in range(40)]
for _ in range(q):
	n = int(input())
	it = list(map(int, input().split()))
	it = [i for i in it if i <= 2048]
	if sum(it) >= 2048:
		print('YES')
	else:
		print('NO')


def solve(n, a):
	a.sort()
	i = 0
	while i + 1 < len(a):
		if a[i] == a[i + 1]:
			a.append(a[i] * 2)
			del a[i]
			del a[i]
		else:
			i += 1
		if 2048 in a:
			return 'YES'
		a.sort()
	return 'NO'

def main():
	q = int(input())
	for i in range(q):
		n = int(input())
		a = list(map(int, input().split()))
		if 2048 in a:
			print('YES')
			continue
		print(solve(n, a))
main()


def query(arr):
	validElems = list()
	for x in arr:
		if x <= 2048:
			validElems.append(x)
	if sum(validElems) >= 2048:
		return 'YES'
	return 'NO'
t = int(input())
while t:
	n = int(input())
	nums = [int(x) for x in input().split(' ')]
	print(query(nums))
	t -= 1


q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	t = 2048
	c = 0
	s = 2048
	sl = 1
	while c == 0:
		dem = a.count(t)
		if dem >= sl:
			c = 1
		else:
			s = s - dem * t
			if s <= 0:
				c = 1
		if c == 1:
			break
		t = t // 2
		if t == 0:
			break
		sl = s // t
	if c == 0:
		print('NO')
	else:
		print('YES')


q = int(input())
MAX = 13
while q:
	n = int(input())
	arr = input().split(' ')
	mp = {}
	for i in range(n):
		k = int(arr[i])
		if k in mp:
			mp[k] += 1
		else:
			mp[k] = 1
	freq = [0] * (MAX + 1)
	for i in range(MAX):
		cur = 2 ** i
		if not cur in mp:
			mp[cur] = 0
		freq[i] += mp[cur]
		freq[i + 1] += freq[i] // 2
	if freq[11]:
		print('YES')
	else:
		print('NO')
	q -= 1


import math
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	count = [0] * 31
	for i in l:
		y = int(math.log(i, 2))
		count[y] += 1
	for i in range(len(count)):
		if i == 0:
			pass
		count[i] += count[i - 1] // 2
	if count[10] > 1 or count[11] > 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(0, q):
	n = int(input())
	s = input()
	suma = 0
	s = s.split()
	for e in range(len(s)):
		s[e] = int(s[e])
	for j in range(n):
		if s[j] <= 2048:
			suma += s[j]
		else:
			next
	if suma >= 2048:
		print('yes')
	else:
		print('no')


n = int(input())
j = 1
while j < n + 1:
	n1 = int(input())
	x = [int(i) for i in input().split()]
	j = j + 1
	s1 = x.count(2048) * 2048
	s2 = x.count(1024) * 1024
	s3 = x.count(512) * 512
	s4 = x.count(256) * 256
	s5 = x.count(128) * 128
	s6 = x.count(64) * 64
	s7 = x.count(32) * 32
	s8 = x.count(16) * 16
	s9 = x.count(8) * 8
	s10 = x.count(4) * 4
	s11 = x.count(2) * 2
	s12 = x.count(1) * 1
	if s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10 + s11 + s12 >= 2048:
		print('YES')
	else:
		print('NO')


def game(nums):
	nums.sort()
	i = 0
	while i < len(nums) - 1:
		if nums[i + 1] == nums[i]:
			if nums[i] == 1024:
				return True
			if nums[i] < 2048:
				newN = nums[i] * 2
				del nums[i:i + 2]
				newInd = len(nums) + 1
				for j in range(len(nums)):
					if nums[j] > newN:
						newInd = j
						break
				nums.insert(newInd, newN)
				return game(nums)
		i += 1
	return False
n = int(input())
for i in range(n):
	input()
	numStrs = input().split(' ')
	nums = [int(n) for n in numStrs]
	if any([n == 2048 for n in nums]) or game(nums):
		print('YES')
	else:
		print('NO')


def main():
	n = int(input())
	for i in range(n):
		q = int(input())
		num = list(map(int, input().strip().split()))[:q]
		num = list(filter(lambda x: x <= 2048, num))
		if sum(num) >= 2048:
			print('Yes')
		else:
			print('No')
main()


def equal(list_1, n):
	list_1.sort(reverse=True, key=lambda x: int(x))
	for i in range(n - 1):
		if 2048 in list_1:
			return 'YES'
		elif i == n - 2:
			if list_1[i] == list_1[i + 1] and list_1[i] != 0:
				a = int(list_1[i]) + int(list_1[i + 1])
				list_1[i] = 0
				list_1[i + 1] = a
				return list_1
			else:
				return list_1
		elif list_1[i] == list_1[i + 1]:
			a = int(list_1[i]) + int(list_1[i + 1])
			list_1[i] = a
			list_1[i + 1] = 0
			continue
		else:
			continue
num = int(input())
for i in range(num):
	n = int(input())
	str_1 = input()
	if n == 1 and str_1 != '2048':
		print('NO')
	elif '2048' in str_1:
		print('YES')
	else:
		str_1 = list(str_1.split())
		str_1 = [int(x) for x in str_1]
		for i in range(n):
			if str_1[i] > 2048:
				str_1[i] = 0
		str_2 = equal(str_1, n)
		while True:
			if '2048' in str_2 or 'YES' in str_2 or 2048 in str_2:
				print('YES')
				break
			else:
				m = str_2[:]
				k = equal(str_2, n)
				if k == m:
					print('NO')
					break


from __future__ import division, print_function
from sys import stdin, stdout
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
import heapq
from fractions import Fraction
import math

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

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

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

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

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

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

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

def fli():
	return list(fmi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

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

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

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

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

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

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

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

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

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

def gr2(n):
	d = defaultdict(list)
	for i in range(n):
		(x, y) = mi()
		d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

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

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

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)

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

def SieveOfEratosthene(n, isPrime):
	isPrime[0] = isPrime[1] = 1
	for i in range(2, n + 1):
		isPrime[i] = 0
	p = 2
	while p * p <= n:
		if isPrime[p] != 0:
			i = p * p
			print(isPrime)
			while i <= n:
				isPrime[i] = p
				i += p
		p += 1
	return isPrime
t = ii()
for a0 in range(t):
	n = ii()
	l = li()
	x = 0
	for i in l:
		if i <= 2048:
			x += i
	if x >= 2048:
		print('YES')
	else:
		print('NO')


T = int(input())
for i in range(T):
	n = int(input())
	l = list(map(int, input().split()))
	if 2048 in l:
		print('YES')
	else:
		t = 0
		if 1 in l:
			k = l.count(1)
		else:
			k = 0
		for i in range(1, 11):
			if 2 ** i in l:
				k = l.count(2 ** i) + k // 2
			elif t >= 0:
				k = k // 2
			if k <= 1:
				t = 0
			t = t + k
		if t >= 2:
			print('YES')
		else:
			print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = [0] * 2049
	for x in a:
		if x <= 2048:
			cnt[x] += 1
	for i in range(0, 11):
		cnt[2 ** (i + 1)] += cnt[2 ** i] // 2
	if cnt[2 ** 11] >= 1:
		print('YES')
	else:
		print('NO')


q = int(input())
while q:
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	i = 0
	d = False
	while i < len(a) - 1:
		if 2048 in a:
			d = True
			break
		if a[i] == a[i + 1]:
			a.append(a[i] + a[i + 1])
			a.sort()
			i += 2
		else:
			i += 1
	if 2048 in a:
		d = True
	if d:
		print('YES')
	else:
		print('NO')
	q -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	for i in range(n):
		num = 0
		f = 0
		if a[i] > 2048:
			continue
		else:
			for j in range(i, n):
				if num + a[j] == 2048:
					f = 1
					print('YES')
					break
				else:
					num += a[j]
		if f == 1:
			break
	if f == 0:
		print('NO')


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

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections, itertools, statistics, math
from collections import *
from itertools import *
from statistics import *
from math import *
mod = int(1000000000.0 + 7)
imin = -2147483648
imax = 2147483647
true = True
false = False
none = None
inp = lambda : input()
I = lambda : int(inp())
M = lambda : map(int, inp().split())
L = lambda : list(M())
Yes = lambda : print('Yes')
No = lambda : print('No')
YES = lambda : print('YES')
NO = lambda : print('NO')

def IO():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def true_yes(statement):
	return YES() if statement else NO()

def prec(a):
	return '{0:.13f}'.format(a)

def kabraji_ka_totka():
	for i in range(I()):
		n = I()
		arr = filter(lambda x: x <= 2048, L())
		true_yes(sum(arr) >= 2048)
kabraji_ka_totka()


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


import math

def game(a, n):
	l = list(set(a))
	l.sort(reverse=True)
	c = [a.count(i) for i in l]
	for i in range(len(l)):
		if l[i] > 2048:
			continue
		elif l[i] == 2048:
			return 'YES'
			break
		else:
			req = 2 ** (11 - math.log(l[i], 2)) - c[i]
			if req <= 0:
				return 'YES'
				break
			else:
				s = 0
				for j in range(i + 1, len(l)):
					s += c[j] * l[j]
				if s >= req * l[i]:
					return 'YES'
					break
				else:
					return 'NO'
					break
	return 'NO'
for t in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	print(game(l1, n))


t = int(input())
for i in range(t):
	n = int(input())
	ara = list(map(int, input().strip().split()))
	ara.sort()
	ara.reverse()
	flag = 0
	ans = 0
	for j in ara:
		if j == 2048:
			flag = 1
			break
		elif j < 2048:
			ans += j
		if ans == 2048:
			flag = 1
			break
		else:
			flag = 0
	if flag == 1:
		print('YES')
	else:
		print('NO')


q = input()
for a in range(int(q)):
	n = input()
	v = [int(x) for x in input().split()]
	sum = 0
	for b in range(int(n)):
		if v[b] < 2049:
			sum += v[b]
		if sum >= 2048:
			print('YES')
			break
	else:
		print('NO')


m = int(input())
for i in range(m):
	g = int(input())
	lst = list(map(int, input().split()))
	n = 2048
	while True:
		if n in lst:
			print('YES')
			break
		val = 0
		sec = set(lst)
		arr = []
		for char in sec:
			temp = lst.count(char)
			if temp > 1:
				arr.append(char)
				val += 1
		if val == 0:
			print('NO')
			break
		for char in arr:
			lst.remove(char)
			lst.remove(char)
			lst.append(char * 2)


count = 0

def func(x):
	global d, count
	if x == 0:
		return
	if count == 2048:
		return
	if x in d:
		if x == 2048:
			count += x
			return
		elif d[x] == 1:
			count += x
			del d[x]
			func(int(x / 2))
		elif d[x] == 2:
			count += 2 * x
			del d[x]
		else:
			count += 2 * x
			d[x] -= 2
	else:
		func(int(x / 2))
		func(int(x / 2))
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in l:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	func(2048)
	if count == 2048:
		print('YES')
		count = 0
	else:
		count = 0
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	su = 0
	for i in range(n):
		if l[i] <= 2048:
			su += l[i]
		if su >= 2048:
			print('yes')
			break
	else:
		print('no')


for i in range(int(input())):
	(a, arr) = (int(input()), list(map(int, input().split(' '))))
	barrel = [0] * 30
	for j in range(0, 30):
		barrel[j] = arr.count(2 ** j)
	for j in range(1, 12):
		barrel[j] += barrel[j - 1] // 2
	print('YES' if barrel[11] else 'NO')


for i in range(int(input())):
	x = input()
	list = input().split()
	s = 0
	for j in list:
		if int(j) <= 2048:
			s += int(j)
	if s >= 2048:
		print('YES')
	else:
		print('No')


t = int(input())
for _ in range(t):
	n = int(input())
	s = [int(x) for x in input().split()]
	f = sum((x if x <= 2048 else 0 for x in s))
	print('YES' if f >= 2048 else 'NO')


import math
import os
import sys
DEBUG = 'DEBUG' in os.environ

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

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)

def solve(N, S):
	c = {}
	a = 1
	while a <= 2 ** 29:
		c[a] = 0
		a *= 2
	for s in S:
		c[s] += 1
	a = 1
	while a < 2048:
		c[a * 2] += c[a] // 2
		a *= 2
	return c[2048] > 0

def main():
	Q = int(inp())
	for _ in range(Q):
		N = int(inp())
		S = [int(e) for e in inp().split()]
		print('YES' if solve(N, S) else 'NO')
main()


def check(arr, n):
	if 2048 in arr:
		return True
	arr.sort()
	while n > 1:
		if arr[n - 1] == arr[n - 2]:
			(k, l) = (arr[n - 1], arr[n - 2])
			arr.remove(arr[n - 1])
			arr.remove(arr[n - 2])
			arr.append(k + l)
			n = len(arr)
			if 2048 in arr:
				return True
			arr.sort()
		else:
			n -= 1
	return False
t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().strip().split()))[:n]
	k = check(arr, n)
	if k:
		print('YES')
	else:
		print('No')
	t -= 1


def check(s):
	if 2048 in s:
		return True
	return False
q = int(input())
for i in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	if check(s):
		print('YES')
	else:
		z = list(filter(lambda a: a < 2048, s))
		if sum(z) >= 2048:
			print('YES')
		else:
			print('NO')


d = dict()
d[1024] = 10
d[512] = 9
d[256] = 8
d[128] = 7
d[64] = 6
d[32] = 5
d[16] = 4
d[8] = 3
d[4] = 2
d[2] = 1
d[1] = 0
n = int(input())
for i in range(n):
	q = int(input())
	l = [int(j) for j in input().split()]
	flag = 0
	while l:
		g = 0
		t = len(l)
		j = 0
		while j < t and (not flag):
			if l[j] <= 1024:
				z = j + 1
				while z < t:
					if l[j] == l[z]:
						l.pop(z)
						g = 1
						l[j] = l[j] * 2
						t -= 1
						if l[j] == 2048:
							flag = 1
							break
					z += 1
			if l[j] == 2048:
				flag = 1
				break
			j += 1
		if g == 0:
			break
	if flag:
		print('YES')
	else:
		print('NO')


for _ in ' ' * int(input()):
	input()
	d = {2048: 0}
	n = 0
	for i in map(int, input().split()):
		if i == 2048:
			n = 1
			break
		else:
			d[i] = d.get(i, 0) + 1
			k = i
			while d[k] > 1:
				d[k + k] = d.get(k + k, 0) + 1
				d[k] -= 2
				k = k + k
				if d[2048] == 1:
					n = 1
					break
	print('YES' if n else 'NO')


import collections
t = int(input())
for q in range(0, t):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	i = n - 1
	while i >= 0:
		if a[i] > 2048:
			a = a[:i]
		i -= 1
	s = sum(a)
	if s >= 2048:
		print('YES')
	else:
		print('NO')


def f(i):
	(n, s) = i
	su = 0
	for j in s:
		if j == 2048:
			return 'YES'
		elif j < 2048:
			su += j
	if su >= 2048:
		return 'YES'
	else:
		return 'NO'
t = int(input())
l = []
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	l.append((n, s))
ans = [f(i) for i in l]
for i in ans:
	print(i)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	l = filter(lambda x: x <= 2048, s)
	print('YES') if sum(l) >= 2048 else print('NO')


import math
for _ in range(int(input())):
	s = int(input())
	arr = list(map(int, input().split()))
	m = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	for i in arr:
		if i <= 2048:
			m[int(math.log(i, 2))] += 1
	x = 2048
	flag = 0
	for i in range(11):
		q = m[i] // 2
		m[i + 1] += q
	if m[11] > 0:
		print('YES')
	else:
		print('NO')


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	cc = Counter(l)
	for i in range(11):
		cc[2 ** (i + 1)] += cc[2 ** i] // 2
	if cc[2 ** 11] >= 1:
		print('YES')
	else:
		print('NO')


import sys
for i in range(int(input())):
	a = int(input())
	li = list(map(int, input().split()))
	l1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
	b = []
	ans = 0
	for i in l1:
		zz = li.count(i)
		ans += zz * i
	if ans >= 2048:
		print('YES')
	else:
		print('NO')


def operate(s, n):
	current_set = []
	new_set = s
	while True:
		if 2048 in new_set:
			return 1
		current_set = new_set
		new_set = []
		l = len(current_set)
		op_ind = False
		i = 0
		while i < l - 1:
			if current_set[i] == current_set[i + 1]:
				new_set.append(current_set[i] + current_set[i + 1])
				i = i + 1
				op_ind = True
			else:
				new_set.append(current_set[i])
			i = i + 1
		if op_ind == False:
			return 0

def main():
	q = int(input())
	s = []
	n = []
	for i in range(q):
		n.append(int(input()))
		temp = [int(x) for x in input().split()]
		s.append(temp)
	for i in range(q):
		if 2048 in s[i]:
			print('YES')
		else:
			s[i].sort(reverse=True)
			verdict = operate(s[i], n[i])
			if verdict == 1:
				print('YES')
			elif verdict == 0:
				print('NO')
main()


q = int(input())
for _ in range(q):
	input()
	n = [int(x) for x in input().split() if int(x) <= 2048]
	if 2048 in n:
		print('yes')
		continue
	if sum(n) >= 2048:
		print('yes')
		continue
	print('no')


import os
from sys import stdin, stdout

def gn():
	return list(map(float, stdin.readline().rstrip().split()))

def mi(i):
	return list(map(int, i))
n = int(gn()[0])
querys = []
for ind in range(n):
	gn()
	cur = gn()
	cur = mi(cur)
	cur = list(filter(lambda x: x <= 2048, cur))
	cur.sort(reverse=True)
	ans = False
	op = True
	while op:
		if len(cur) > 0 and cur[0] == 2048:
			ans = True
			op = False
		else:
			i = 0
			op = False
			next = []
			while i < len(cur):
				if i + 1 < len(cur) and cur[i] == cur[i + 1]:
					next.append(cur[i] * 2)
					i += 2
					op = True
				else:
					next.append(cur[i])
					i += 1
			cur = next
	if ans:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	if 2048 in a:
		print('YES')
		continue
	a = sorted(a, reverse=True)
	summ = 0
	for i in a:
		if i > 2048:
			continue
		summ += i
		if summ == 2048:
			break
	if summ == 2048:
		print('YES')
	else:
		print('NO')


def calc(arr: list):
	total: int = 0
	for i in arr:
		if i == 2048:
			return 'YES'
		elif i < 2048:
			total += i
		elif total >= 2048:
			return 'YES'
	if total >= 2048:
		return 'YES'
	else:
		return 'NO'

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


t = int(input())
for i in range(t):
	input()
	l = list(map(int, input().split()))
	l = list(filter(lambda a: a <= 2048, l))
	if sum(l) >= 2048:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	n = int(input())
	l = list(map(int, input().split()))
	p = []
	for i in range(len(l)):
		if l[i] > 2048:
			continue
		else:
			p.append(l[i])
	if sum(p) >= 2048:
		print('YES')
	else:
		print('NO')


test = int(input())
for i in range(test):
	n = int(input())
	arr = list(map(int, input().split()))
	freq = [0] * 12
	for i in range(n):
		if arr[i] <= 2048:
			count = 0
			while arr[i] != 1:
				count += 1
				arr[i] = arr[i] // 2
			freq[count] = freq[count] + 1
	for i in range(11):
		while freq[i] >= 2:
			freq[i] = freq[i] - 2
			freq[i + 1] = freq[i + 1] + 1
	if freq[11] >= 1:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	lst = [0] * 30
	for i in arr:
		lst[int(math.log2(i))] += 1
	if lst[11]:
		print('YES')
		continue
	for i in range(29):
		if lst[11]:
			break
		lst[i + 1] += lst[i] // 2
		lst[i] %= 2
		if lst[11]:
			break
	if lst[11]:
		print('YES')
	else:
		print('NO')


from math import log
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr2 = [0] * 12
	for i in arr:
		if i <= 2048:
			x = int(log(i, 2))
			arr2[x] += 1
		else:
			continue
	for i in range(11):
		arr2[i + 1] += arr2[i] // 2
	if arr2[11] >= 1:
		print('YES')
	else:
		print('NO')


def main():
	a = int(input())
	for i in range(a):
		temp = int(input())
		values = list(filter(lambda x: x <= 2048, map(int, input().split())))
		if len(values) is 0:
			print('NO')
			continue
		values = sorted(values, reverse=True)
		decide = True
		while True:
			if values[0] == 2048:
				print('YES')
				break
			elif decide == False:
				print('NO')
				break
			decide = False
			i = 0
			while i < len(values) - 1:
				if values[i] == values[i + 1]:
					decide = True
					values[i] = values[i] + values[i + 1]
					del values[i + 1]
				i += 1
main()


t = int(input())
for i in range(1, t + 1):
	counts = dict()
	n = int(input())
	line = input()
	numbers = line.split(' ')
	for num in numbers:
		if counts.get(int(num)):
			counts[int(num)] += 1
		else:
			counts[int(num)] = 1
	k = 1
	while k <= 2048:
		if counts.get(2048) is not None and counts.get(2048) > 0:
			print('YES')
			break
		if counts.get(k) is None:
			k = k * 2
			continue
		if counts.get(k * 2) is not None:
			counts[k * 2] += counts.get(k) // 2
		else:
			counts[k * 2] = counts.get(k) // 2
		k = k * 2
	if k > 2048:
		print('NO')


q = int(input())
l = {1: 0, 2: 0, 4: 0, 8: 0, 16: 0, 32: 0, 64: 0, 128: 0, 256: 0, 512: 0, 1024: 0, 2048: 0}
for _ in range(q):
	n = int(input())
	arr = list(map(int, input().split()))
	s = 0
	for i in arr:
		if i <= 2048:
			s += i
	if s >= 2048:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(filter(lambda x: x <= 2048, map(int, input().split())))
	if sum(l) >= 2048:
		print('yes')
	else:
		print('no')


t = int(input())
while t > 0:
	n = int(input())
	l = [int(i) for i in input().split()]
	f = 0
	l.sort()
	q = 1
	while q:
		q = 0
		if 2048 in l:
			f = 1
			break
		else:
			for i in range(0, len(l) - 1):
				if l[i] == l[i + 1]:
					x = l.pop(i)
					y = l.pop(i)
					l.append(x + y)
					q = 1
					l.sort()
					break
	if f == 1:
		print('YES')
	else:
		print('NO')
	t = t - 1


import collections
tasks = int(input())
for i in range(tasks):
	input()
	a = input().split()
	b = []
	for j in a:
		b.append(int(j))
	while True:
		if 2048 in b:
			print('YES')
			break
		found = False
		y = collections.Counter(b)
		for k in range(30):
			if y[2 ** k] > 1:
				found = True
				c = y[2 ** k] // 2
				for p in range(c * 2):
					del b[b.index(2 ** k)]
				for c in range(c):
					b.append(2 ** (k + 1))
		if not found:
			print('NO')
			break


q = int(input())
for i in range(q):
	n = int(input())
	lst = list(map(int, input().strip().split()))[:n]
	temp = 0
	for i in lst:
		if i <= 2048:
			temp = temp + i
	if temp >= 2048:
		print('YES')
	else:
		print('NO')


N = int(input())
for _ in range(N):
	K = int(input())
	arr = map(int, input().split())
	res = []
	for i in arr:
		r = 0
		while i != 1:
			i /= 2
			r += 1
		res.append(r)
	while True:
		flag = 1
		if 11 in res:
			print('YES')
			break
		for i in res:
			if res.count(i) > 1:
				res.remove(i)
				res.remove(i)
				res.append(i + 1)
		if 11 in res:
			print('YES')
			break
		for i in res:
			if res.count(i) > 1:
				flag = 0
				break
		if flag:
			print('NO')
			break


from sys import stdin, stdout
import math
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	p = []
	for i in range(0, 12):
		p.append(2 ** i)
	temp = []
	for i in arr:
		if i in p:
			temp.append(i)
	temp = sorted(temp)[::-1]
	ans = 0
	for i in temp:
		ans += i
		if ans == 2048:
			print('yes')
			break
	else:
		print('no')


def solution(l):
	m = {}
	for n in l:
		n = int(n)
		if n == 2048:
			return 'YES'
		elif n > 2048:
			continue
		else:
			m[n] = m.get(n, 0) + 1
	return check(m)

def check(m):
	next = 1024
	need = 2
	while next >= 1:
		if need <= m.get(next, 0):
			return True
		need = (need - m.get(next, 0)) * 2
		next = next / 2
	return False
total = int(input())
for i in range(total):
	input()
	l = input().split()
	print('YES' if solution(l) else 'NO')


q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	d = dict()
	f = 0
	for j in range(n):
		if a[j] < 2048:
			d[a[j]] = d.get(a[j], 0) + 1
		elif a[j] == 2048:
			f = 1
			break
	c = 1
	while c != 0 and f == 0:
		c = 0
		for k in range(11):
			if d.get(2 ** 11, 0) > 0:
				f = 1
				break
			v = d.get(2 ** (10 - k), 0) // 2
			if v != 0:
				c = c + 1
				d[2 ** (10 - k + 1)] = v + d.get(2 ** (10 - k + 1), 0)
				d[2 ** (10 - k)] = d.get(2 ** (10 - k), 0) % 2
	if f == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
i = 0
trash = list()
num = list()
while i < 2 * n:
	if i % 2 == 1:
		num.append(input().split())
	else:
		trash.append(input())
	i += 1
for i in range(len(num)):
	for j in range(len(num[i])):
		num[i][j] = int(num[i][j])
for i in num:
	sum = 0
	check = False
	i.sort()
	for j in range(len(i) - 1, -1, -1):
		if i[j] <= 2048:
			sum += i[j]
			if sum == 2048:
				print('YES')
				check = True
				break
	if check == False:
		print('NO')


Q = int(input())
while Q > 0:
	Q -= 1
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	a.reverse()
	fla = False
	while len(a) > 0:
		if a[-1] == 2048:
			print('YES')
			fla = True
			break
		if len(a) > 1:
			if a[-1] == a[-2]:
				x = 2 * a[-1]
				del a[-1]
				del a[-1]
				a.append(x)
				a.sort()
				a.reverse()
			else:
				del a[-1]
		else:
			del a[-1]
	if fla == False:
		print('NO')


n = int(input())
s = int(0)
for i in range(n):
	k = int(input())
	arr = list(map(int, input().split()))
	if len(arr) == k:
		for j in arr:
			if j <= 2048:
				s += j
		if s >= 2048:
			print('YES')
		else:
			print('NO')
	s = 0


q = int(input())
while q:
	n = int(input())
	s = input().split()
	for i in range(n):
		s[i] = int(s[i])
	s.sort()
	a = [0 for i in range(2049)]
	for i in range(n):
		if 1 <= s[i] <= 2048:
			a[s[i]] += 1
	for i in range(1025):
		a[2 * i] += a[i] // 2
	if a[2048] == 0:
		print('NO')
	else:
		print('YES')
	q -= 1


numberOfLines = int(input())

def canMakes2048(numbers):
	if 2048 in numbers:
		return True
	for i in range(len(numbers)):
		for j in range(i + 1, len(numbers)):
			if numbers[i] == numbers[j]:
				numbers.append(numbers[i] + numbers[j])
				numbers.remove(numbers[i])
				j -= 1
				numbers.remove(numbers[j])
				return canMakes2048(numbers)
	return False
for i in range(numberOfLines):
	numberOfDigits = int(input())
	numbers = input().split()
	for j in range(0, len(numbers)):
		numbers[j] = int(numbers[j])
	numbers.sort()
	if canMakes2048(numbers):
		print('YES')
	else:
		print('NO')


string = int(input())
for i in range(string):
	num = int(input())
	listi = list(map(int, input().split()))
	for p in [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]:
		a = listi.count(p)
		listi.extend([p * 2] * (a // 2))
	if 2048 in listi:
		print('YES')
	else:
		print('NO')


from math import *
q = int(input())
for i in range(q):
	n = int(input())
	s = [0] * 2049
	a = list(map(int, input().split()))
	for j in range(n):
		if a[j] <= 2048:
			s[a[j]] += 1
	for j in range(1025):
		if s[j] != 0:
			if j != 2048:
				s[j * 2] += s[j] // 2
	if s[2048] == 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	found = 0
	sum1 = 0
	a = list(map(int, input().split()))
	for i in a:
		if i == 2048:
			print('Yes')
			found = 1
			break
		if i < 2048:
			sum1 += i
	if sum1 >= 2048 and found == 0:
		print('Yes')
	elif found == 0:
		print('No')


def calculate(listOfNumbers):
	myDick = {}
	for i in listOfNumbers:
		if i == 2048:
			return True
		if i > 2048:
			continue
		if i in myDick:
			myDick[i] += 1
		else:
			myDick[i] = 1
	someList = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]
	for i in someList:
		if not i in myDick:
			continue
		if myDick[i] >= 2:
			if i * 2 in myDick:
				myDick[i * 2] += myDick[i] // 2
			else:
				myDick[i * 2] = myDick[i] // 2
	return 2048 in myDick
n = int(input())
myList = []
for i in range(n):
	input()
	myList.append(input())
for index in range(len(myList)):
	myList[index] = myList[index].split(' ')
	for innerIndex in range(len(myList[index])):
		myList[index][innerIndex] = int(myList[index][innerIndex])
for i in myList:
	if calculate(i):
		print('Yes')
	else:
		print('No')


n = int(input())
for i in range(0, n):
	m = int(input())
	a = list(map(int, input().split(' ')))
	s = 0
	if '2048' in a:
		print('YES')
	else:
		for j in range(0, m):
			if a[j] > 2048:
				continue
			else:
				s += a[j] / 2048
		if s >= 1:
			print('YES')
		else:
			print('NO')


q = int(input())

def func(n, c):
	if n == 0:
		if l.count(2 ** n) >= c:
			return 1
		return 0
	elif l.count(2 ** n) >= c:
		return 1
	else:
		return func(n - 1, (c - l.count(2 ** n)) * 2)
for i in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	a = func(11, 1)
	if a:
		print('YES')
	else:
		print('NO')


q = int(input())
ans = []
for x in range(q):
	sum = 0
	n = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	v = 0
	for ele in l:
		if ele <= 2048:
			sum += ele
			if sum == 2048:
				v = 1
				ans.append('Yes')
				break
	if v != 1:
		ans.append('No')
for val in ans:
	print(val)


import math
alph = 'abcdefghijklmnopqrstuvwxyz'
q = int(input())
for _ in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	E = 0
	for i in range(n):
		if s[i] <= 2048:
			E += s[i]
	if E >= 2048:
		print('YES')
	else:
		print('NO')


def check2048(lst):
	if 2048 in lst:
		return True
	summa = 0
	for elem in lst:
		if elem <= 2048:
			summa += elem
	if summa >= 2048:
		return True
	return False
n = int(input())
for i in range(n):
	m = int(input())
	a = [int(j) for j in input().split()]
	if check2048(a) is True:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	sum = 0
	ok = 0
	ok2 = 0
	a = int(input())
	l = list(map(int, input().split()))
	for i in range(0, len(l), 1):
		if l[i] <= 2048:
			sum += l[i]
	if sum >= 2048:
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
for _ in range(t):
	input()
	s = [int(x) for x in input().split()]
	mysum = sum([x for x in s if x <= 2048])
	print('YES' if mysum >= 2048 else 'NO')


try:
	from string_source import string_source
	source = string_source('6\n4\n1024 512 64 512\n1\n2048\n3\n64 512 2\n2\n4096 4\n7\n2048 2 2048 2048 2048 2048 2048\n2\n2048 4096')
except ImportError:
	source = input
from collections import Counter

def possible(items):
	if any((i == 2048 for i in items)):
		return 'YES'
	counts = Counter((i for i in items if i < 2048))
	for i in range(0, 11):
		c = counts.get(2 ** i, 0)
		counts[2 ** (i + 1)] += c // 2
	if counts[1024] >= 2:
		return 'YES'
	else:
		return 'NO'
n_queries = int(source())
for q in range(n_queries):
	source()
	items = list(map(int, source().split()))
	print(possible(items))


t = int(input(''))
q = []
while t > 0:
	n = int(input(''))
	x = list(map(int, input('').split()))
	l = []
	if len(x) == n:
		l = x
	l.sort()
	s = 0
	count = 0
	for i in range(count, len(l)):
		if l[i] == 2048:
			q.append('YES')
			break
		elif i == len(l) - s - 1:
			q.append('NO')
			break
		elif l[i] == l[i + 1] and l[i] != 0 and (i + 1 < len(l)):
			r = l[i] + l[i + 1]
			if r == 2048:
				q.append('YES')
				break
			l.remove(l[i])
			l.append(r)
			l.sort()
	t = t - 1
for i in q:
	print(i)


def game_solver(numbers):
	return True if sum([num for num in numbers if num <= 2048]) >= 2048 else False
for _ in range(int(input())):
	input()
	numbers = [int(num) for num in input().split(' ')]
	print('YES') if game_solver(numbers) else print('NO')


z = int(input())
res = []
for i in range(z):
	n = int(input())
	s = input().split()
	(flag, k) = (True, 0)
	while flag:
		for num in s:
			if '2048' in s:
				flag = False
				break
			if s.count(num) != 1:
				s.append(str(int(s.pop(s.index(num))) + int(s.pop(s.index(num)))))
				k += 1
		if k == 0:
			flag = False
		else:
			k = 0
	if '2048' in s:
		res.append('YES')
	else:
		res.append('NO')
for result in res:
	print(result)


q = int(input())
for i in range(q):
	flag = False
	n = int(input())
	s = [int(el) for el in input().split()]
	s.sort()
	s2 = list(filter(lambda x: x <= 2048, s))
	s2.reverse()
	while len(s2) > 1:
		if s2[-1] == 2048 or s2[-2] == 2048:
			flag = True
			break
		if s2[-1] != s2[-2]:
			s2.pop()
			continue
		a = s2.pop()
		b = s2.pop()
		s2.append(a + b)
		s2.sort()
		s2.reverse()
	if flag or (len(s2) >= 1 and s2[0] == 2048):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	sum = 0
	flag = 0
	for i in l:
		if i <= 2048:
			sum += i
		if sum == 2048:
			flag = 1
			break
	if flag == 1:
		print('yes')
	else:
		print('NO')


x = int(input())
lis = []
su = 0
for i in range(x):
	y = int(input())
	f = input()
	lis = [int(k) for k in str(f).split()]
	for j in range(y):
		if lis[j] == 2048:
			su = 2048
			break
		if lis[j] > 2048:
			continue
		else:
			su = su + lis[j]
	if su >= 2048:
		print('YES')
	else:
		print('NO')
	su = 0


q = int(input())
for i in range(q):
	n = int(input())
	lst2 = []
	lst1 = list(map(int, input().split()))
	for i in range(len(lst1)):
		if lst1[i] <= 2048:
			lst2.append(lst1[i])
	sum1 = sum(lst2)
	if sum1 >= 2048:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(0, n):
	o = int(input())
	p = input().rstrip().split(' ')
	if '2048' in p:
		print('YES')
	else:
		w = [0] * 20000
		for j in range(0, len(p)):
			if int(p[j]) < 2048:
				w[int(p[j])] += 1
				if w[int(p[j])] == 2:
					w[int(p[j])] = 0
					w[2 * int(p[j])] += 1
		if w[2048] > 0:
			print('YES')
		else:
			for j in range(0, 2048):
				if w[j] >= 2:
					A = w[j] // 2
					w[j] = 0
					w[2 * j] += A
			if w[2048] > 0:
				print('YES')
			else:
				print('NO')


from collections import defaultdict
n = int(input())
for i in range(n):
	num = int(input())
	vec = [int(x) for x in input().split()]
	vec.sort()
	dic = defaultdict(lambda : 0)
	ret = 'NO'
	for a in vec:
		t = a
		dic[t] += 1
		if dic[2048] >= 1:
			ret = 'YES'
			break
		flag = dic[t] >= 2
		while flag:
			dic[2 * t] += 1
			dic[t] -= 2
			flag = dic[2 * t] >= 2
			t = 2 * t
			if dic[2048] >= 1:
				ret = 'YES'
				break
		if ret == 'YES':
			break
	print(ret)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	if 2048 in a:
		print('Yes')
		continue
	for i in a:
		if i <= 2048:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	k = 0
	m = 0
	p = 0
	req = {1024: 2, 512: 4, 256: 8, 128: 16, 64: 32, 32: 64, 16: 128, 8: 256, 4: 512, 2: 1024}
	r = [2 ** i for i in range(12)]
	for i in range(12):
		if 2 ** (11 - i) in d:
			r[i] -= d[2 ** (11 - i)]
			m = d[2 ** (11 - i)]
			if i != 11:
				for j in range(i + 1, len(r)):
					p = 2 * m
					r[j] -= p
					m = p
			for j in r:
				if j <= 0:
					print('Yes')
					k = 1
					break
			if k == 1:
				break
	if k == 0:
		print('No')


def magic(n, l1):
	l1.sort()
	l2 = []
	for i in l1:
		if i <= 2048:
			l2.append(i)
	sum = 0
	for i in range(len(l2) - 1, -1, -1):
		sum += l2[i]
		if sum == 2048:
			ans = 'YES'
			break
	else:
		ans = 'NO'
	return ans
t = int(input(''))
for u in range(1, t + 1):
	N = int(input(''))
	String = input('')
	l1 = [int(x) for x in String.split()]
	print(magic(N, l1))


def proA(arr):
	n = len(arr)
	arr.sort()
	ind = -1
	for i in range(len(arr)):
		if arr[n - 1 - i] > 2048:
			continue
		ind = n - 1 - i
		break
	if ind == -1:
		print('NO')
		return
	if sum(arr[:ind + 1]) >= 2048:
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	proA(arr)


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort(reverse=True)
	sum = 0
	flag = 0
	for i in l:
		if i > 2048:
			continue
		elif i == 2048:
			flag = 1
			break
		else:
			sum += i
			if sum == 2048:
				flag = 1
				break
	if flag == 1:
		print('YES')
	else:
		print('NO')


import math
q = int(input())

def count(n, num):
	powertwo = [0] * 30
	for i in range(n):
		powertwo[int(math.log(num[i], 2))] += 1
	for i in range(11):
		powertwo[i + 1] += powertwo[i] // 2
	if powertwo[11] > 0:
		return 'YES'
	else:
		return 'NO'
res = ''
for i in range(q):
	n = int(input())
	num = list(map(int, input().split()))
	res += count(n, num) + '\n'
print(res.strip())


import heapq
TARGET = 2048

def game2048(n, nums):
	nums = [num for num in nums if num <= TARGET]
	n = len(nums)
	if TARGET in nums:
		return 'YES'
	heapq.heapify(nums)
	while nums:
		val = heapq.heappop(nums)
		if val == TARGET:
			return 'YES'
		elif nums and nums[0] == val:
			heapq.heappop(nums)
			heapq.heappush(nums, val * 2)
	return 'NO'
Q = int(input())
for q in range(Q):
	n = int(input())
	nums = [int(num) for num in input().strip().split()]
	ans = game2048(n, nums)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	s = 0
	for i in arr:
		if i > 2048:
			continue
		elif s >= 2048:
			break
		else:
			s += i
	if s >= 2048:
		print('YES')
	else:
		print('NO')


from math import log2
from math import floor

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = list(map(int, input().strip().split()))
		arr.sort()
		ma = {i: 0 for i in range(12)}
		for i in range(n):
			num = arr[i]
			if num > 2048:
				break
			else:
				p = int(log2(num))
				ma[p] += 1
		for i in range(11):
			ma[i + 1] += ma[i] // 2
		if ma[11]:
			print('YES')
		else:
			print('NO')
main()


from collections import *

def pow1(x, base):
	sq = 1
	while base > 0:
		if base % 2:
			base -= 1
			sq = sq * x
		base //= 2
		x = x * x
	return sq
arr = [pow1(2, j) for j in range(12)]
for i in range(int(input())):
	(n, a) = (int(input()), list(map(int, input().split())))
	(mem, ans, l) = (Counter(a), 'NO', 0)
	while l < 12:
		l = 0
		for j in arr:
			if mem[2048]:
				ans = 'YES'
				break
			if mem[j] > 1:
				mem[2 * j] += mem[j] // 2
				mem[j] %= 2
			else:
				l += 1
		if ans == 'YES':
			break
	print(ans)


a = int(input())
for i in range(a):
	b = int(input())
	c = [int(x) for x in input().split()]
	c.sort()
	count = 0
	for j in range(b):
		if c[j] <= 2048:
			count += c[j]
	if count >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
for tt in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	tofind = 2048
	ans = 0
	while len(s) > 0:
		flag = 0
		s.sort()
		if tofind in s:
			ans = 1
			break
		for i in range(len(s) - 1):
			if s[i] == s[i + 1]:
				flag = 1
				x = s[i]
				break
		if flag == 0:
			break
		else:
			s.remove(x)
			s.remove(x)
			s.append(x + x)
	if ans == 1:
		print('YES')
	else:
		print('NO')


g = int(input())
for i in range(g):
	p = 0
	t = int(input())
	m = [int(x) for x in input().split()]
	m.sort(reverse=True)
	k = 0
	for j in range(t):
		if m[j] > 2048:
			continue
		k = k + m[j]
		if k == 2048:
			p = 2
			break
	if p == 2:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	j = 0
	ff = 0
	dd = 0
	l = len(a)
	while j < l - 1:
		a.sort()
		if a[j] == 2048:
			dd = 1
			break
		elif a[j] == a[j + 1]:
			h = j
			p = a.pop(j)
			r = a.pop(j)
			a.insert(h, p + r)
		else:
			j = j + 1
		l = len(a)
	if dd == 1:
		print('YES')
	else:
		for j in range(len(a)):
			if a[j] == 2048:
				ff = 1
				print('YES')
				break
		if ff != 1:
			print('NO')


q = int(input())
from collections import Counter
for _ in range(q):
	n = int(input())
	S_ = list(map(int, input().split()))
	S = []
	for s in S_:
		if s <= 2048:
			S.append(s)
	if sum(S) >= 2048:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	z = [int(x) for x in input().split(' ')]
	if z.count(2048) != 0:
		print('yes')
		continue
	f = 0
	while 1:
		s = 0
		for x in z:
			if z.count(x) > 1:
				z.append(2 * x)
				z.pop(z.index(x))
				z.pop(z.index(x))
				s = 1
				break
		if z.count(2048) != 0:
			print('yes')
			f = 1
			break
		if s == 0:
			print('no')
			break


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if 2048 in l:
		print('YES')
	else:
		l.sort()
		p = 0
		for i in range(n):
			if l[i] > 1024:
				p = i
				break
		if p > 0:
			l = l[:p]
		if len(l) == 0:
			print('NO')
		else:
			s = 0
			p = 0
			for j in range(len(l) - 1):
				if p == 1:
					break
				s = l[j]
				for k in range(j + 1, len(l)):
					s = s + l[k]
					if s == 2048:
						print('YES')
						p = 1
						break
					elif s > 2048:
						break
			if p == 0:
				print('NO')


for __ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	ar1 = []
	for elem in ar:
		if elem <= 2 ** 11:
			ar1.append(elem)
	ar1.sort(reverse=True)
	num = 0
	ans = 'NO'
	for elem in ar1:
		if num + elem <= 2048:
			num += elem
		if num == 2048:
			ans = 'YES'
	print(ans)


q = int(input())
while q > 0:
	n = int(input())
	num = [int(x) for x in input().split()]
	num.sort(reverse=True)
	s = 0
	p = 0
	for i in num:
		if i <= 2048:
			s += i
			if s == 2048:
				p = 7
				break
	if p == 7:
		print('YES')
	else:
		print('NO')
	q -= 1


import os
import sys
from io import BytesIO, IOBase

def solution(n, arr):
	arr.sort()
	while arr and arr[-1] > 2048:
		arr.pop()
	write('YES' if arr and sum(arr) >= 2048 else 'NO')

def main():
	for _ in range(r_int()):
		n = r_int()
		arr = r_array()
		solution(n, arr)
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))

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

def write(*args, end='\n'):
	for x in args:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(end)

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

def r_int():
	return int(input())
main()


x = int(input())
for __ in range(x):
	a = int(input())
	b = list(map(int, input().split()))
	i = 1
	tt = 0
	while i <= 2048:
		tt = b.count(i) + tt // 2
		i *= 2
	if tt > 0:
		print('YES')
	else:
		print('NO')


I = input
for _ in [0] * int(I()):
	I()
	print('YNEOS'[sum((x for x in map(int, I().split()) if x < 2049)) < 2048::2])


y = 0
n = int(input())
while y < n:
	m = int(input())
	num = sorted(list(map(int, input().split())))
	x = 0
	while x < len(num):
		if 2048 in num:
			print('YES')
			break
		elif num.count(num[x]) > 1:
			z = num[x]
			num[x] = 2 * z
			num.remove(z)
			num = sorted(num)
			x -= 1
		x += 1
	if 2048 not in num:
		print('NO')
	y += 1


t = int(input())
for x in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if 2048 in arr:
		print('YES')
		continue
	i = 0
	while i < len(arr):
		if arr[i] > 2048:
			arr.pop(i)
			continue
		i = i + 1
	while True:
		flag2 = 0
		if len(set(arr)) == len(arr):
			break
		for i in range(len(arr)):
			flag = 0
			for j in range(i + 1, len(arr)):
				if arr[i] == arr[j]:
					val = arr[i]
					arr.remove(val)
					arr.remove(val)
					arr.append(2 * val)
					flag = 1
					if 2 * val == 2048:
						print('YES')
						flag2 = 1
				if flag == 1:
					break
			if flag == 1:
				break
		if flag2 == 1:
			break
	if flag2 == 1:
		continue
	print('NO')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	m = {}
	for i in range(0, 12):
		m[2 ** i] = 0
	if 2048 in arr:
		print('YES')
		continue
	for i in arr:
		try:
			m[i] += 1
		except Exception:
			pass
	for i in range(0, 11):
		curr_number = 2 ** i
		next_number = 2 ** (i + 1)
		freq_curr = m[curr_number]
		m[next_number] += freq_curr // 2
	if m[2048] > 0:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	s = list(filter(lambda x: x < 2049, map(int, input().split())))
	if sum(s) >= 2048:
		print('Yes')
	else:
		print('NO')


def move(l):
	l.sort(reverse=True)
	a = 0
	lk = []
	for i in range(len(l) - 1):
		if l[i] == l[i + 1]:
			a = l[i]
			l.remove(a)
			lk = l
			lk[i] = 2 * int(a)
			lk.sort(reverse=True)
			return lk
	if a == 0:
		return l
num = int(input())
for i in range(num):
	n = input()
	l = input().split(' ')
	l1 = []
	for i in l:
		l1.append(int(i))
	while True:
		if 2048 in l1:
			print('YES')
			break
		else:
			l2 = l1[:]
			l3 = move(l1)
			if l3 == l2:
				print('NO')
				break


q = eval(input())
for i in range(q):
	n = input()
	l1 = list(map(eval, input().split()))
	for i in range(len(l1)):
		if l1[i] > 2048:
			l1[i] = 0
	if sum(l1) >= 2048:
		print('YES')
	else:
		print('NO')


b = int(input())
for i in range(b):
	p = int(input())
	a = list((int(x) for x in input().split()))
	sum = 0
	for i in a:
		if i <= 2048:
			sum += i
	if sum >= 2048:
		print('YES')
	else:
		print('NO')


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = defaultdict(lambda : 0)
	for i in range(13):
		d[1 << i] += l.count(1 << i)
		x = d[1 << i] // 2
		d[1 << i + 1] += x
	print('YES' if d[1 << 11] > 0 else 'NO')


for tc in range(int(input())):
	input()
	tracker = {2 ** x: 0 for x in range(0, 12)}
	for val in [int(n) for n in input().split()]:
		tracker.setdefault(val, 0)
		tracker[val] += 1
	for i in range(11):
		tracker[2 ** (i + 1)] += tracker[2 ** i] // 2
	if tracker[2048] == 0:
		print('NO')
	else:
		print('YES')


import sys
from collections import defaultdict as dd
from itertools import permutations as pp
from itertools import combinations as cc
from collections import Counter as ccd
from random import randint as rd
from bisect import bisect_left as bl
from heapq import heappush as hpush
from heapq import heappop as hpop
mod = 10 ** 9 + 7

def ri(flag=0):
	if flag == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
for _ in range(ri(1)):
	n = ri(1)
	a = ri()
	c = dd(int)
	for i in a:
		c[i] += 1
	status = 0
	while 1:
		chnaged = 0
		for i in list(c.keys()):
			if c[2048] > 0:
				status = 1
			if c[i] >= 2:
				c[i] -= 2
				c[i + i] += 1
				chnaged = 1
		if chnaged == 0:
			break
	if status:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in range(13):
		a = pow(2, i)
		d[a] = l.count(a)
	for i in range(12):
		a = pow(2, i + 1)
		b = pow(2, i)
		d[a] += d[b] // 2
	if d[2048] > 0:
		print('YES')
	else:
		print('NO')


queries_amount = int(input())
queries = []

def lists_are_equal(list1, list2):
	if len(list1) != len(list2):
		return False
	length = len(list1)
	list1 = sorted(list1)
	list2 = sorted(list2)
	for index in range(length):
		if not list1[index] == list2[index]:
			return False
	else:
		return True

def transform_array_for_2048(array):
	while not lists_are_equal(array, list(set(array))) and (not 2048 in array):
		for value in array:
			values_to_delete = array.count(value)
			if values_to_delete == 1:
				continue
			elif values_to_delete % 2 != 0:
				values_to_delete -= 1
			values_to_append = values_to_delete // 2
			value_to_append = value * 2
			array += [value_to_append] * values_to_append
			for _ in range(values_to_delete):
				array.remove(value)
	return array
for _ in range(queries_amount):
	numbers_amount = int(input())
	numbers = [int(i) for i in input().split()]
	queries.append((numbers_amount, numbers))
all_possible_numbers = [2 ** i for i in range(12)]
for (_, numbers) in queries:
	if 2048 in numbers or 2048 in transform_array_for_2048(numbers):
		print('YES')
	else:
		print('NO')


import math
setti = [0] * 40

def log2(a):
	value = int(math.log2(int(a)))
	setti[value] += 1
	return value
for i in range(int(input())):
	n = int(input())
	setti = [0] * 40
	a = list(map(log2, input().split()))
	a.sort(reverse=False)
	for i in range(11):
		setti[i + 1] += setti[i] // 2
	if setti[11] > 0:
		print('YES')
	else:
		print('NO')


import copy

def count(lst):
	dic = {}
	for i in lst:
		dic[i] = dic.get(i, 0) + 1
	return dic
t = int(input())
while t:
	t -= 1
	n = int(input())
	lst = list(map(int, input().split()))
	flg = False
	run = True
	while run:
		temp = []
		dic = count(lst)
		run = False
		for key in dic:
			if key == 2048:
				flg = True
				run = False
				break
			if dic[key] != 1:
				run = True
				temp.append(key * 2)
				dic[key] -= 2
				temp.extend([key] * dic[key])
			else:
				temp.append(key)
		lst = copy.deepcopy(temp)
	if not flg:
		for i in temp:
			if i == 2048:
				flg = True
				break
	if flg:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	a = []
	for i in l:
		if i <= 2048:
			a.append(i)
	if sum(a) >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
kq = []
for i in range(0, q):
	s = 0
	n = int(input())
	ss = input()
	ss = ss.split()
	for j in range(0, n):
		ss[j] = eval(ss[j])
	ss.sort()
	x = 0
	while s < 2048 and x < n and (ss[x] <= 2048):
		s = s + ss[x]
		x = x + 1
	if s >= 2048:
		kq.append('YES')
	else:
		kq.append('NO')
for i in range(0, q):
	print(kq[i])


import sys
import heapq

def solve(a):
	heapq.heapify(a)
	if 2048 in a:
		return True
	lst = heapq.heappop(a)
	if lst > 2048:
		return False
	while len(a) >= 1:
		slst = heapq.heappop(a)
		if lst == slst:
			total = lst + slst
			if total == 2048:
				return True
			else:
				heapq.heappush(a, total)
			lst = heapq.heappop(a)
		else:
			lst = slst
	return 2048 in a
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	print('YES' if solve(a) else 'NO')


for _ in range(int(input())):
	j = int(input())
	a = [int(i) for i in input().split()]
	while len(set(a)) < len(a) and 2048 not in a:
		for i in a:
			if a.count(i) >= 2:
				a.remove(i)
				a.remove(i)
				a.append(i * 2)
	if 2048 in a:
		print('YES')
	else:
		print('NO')


import math

def f(n, m):
	global q
	if q[n] >= m:
		return True
	elif n > 0:
		return f(n - 1, 2 * max([0, m - q[n]]))
	else:
		return False
for j in range(int(input())):
	n = int(input())
	d = [int(math.log2(i)) for i in list(map(int, input().split()))]
	q = [0] * 30
	for i in d:
		q[i] += 1
	if q[11] >= 1 or f(10, max([0, 2 - q[11]])):
		print('YES')
	else:
		print('no')


for _ in range(int(input())):
	N = int(input())
	Sum = 0
	L = list(map(int, input().split()))
	for i in L:
		if i <= 2048:
			Sum = Sum + i
	if Sum >= 2048:
		print('Yes')
	else:
		print('No')


t = int(input())
while t:
	n = int(input())
	arr = [int(x) for x in input().split() if int(x) <= 2048]
	print('YES' if sum(arr) >= 2048 else 'NO')
	t -= 1


for i in range(int(input())):
	input()
	print(('NO', 'YES')[sum(filter(lambda x: x < 2049, map(int, input().split()))) >= 2048])


q = int(input())
while q > 0:
	q = q - 1
	n = int(input())
	s = input().split()
	a = []
	for i in s:
		a.append(int(i))
	k = 0
	d = {1: 0, 2: 0, 4: 0, 8: 0, 16: 0, 32: 0, 64: 0, 128: 0, 256: 0, 512: 0, 1024: 0, 2048: 0}
	for i in a:
		if i in d:
			d[i] = d[i] + 1
	temp = 1
	while temp > 0:
		temp -= 1
		for (key, val) in d.items():
			if d[2048] > 0:
				k = 1
				break
			if val >= 2:
				d[key] = d[key] - 2
				newkey = key * 2
				if newkey in d:
					d[newkey] += 1
				else:
					d[newkey] = 1
				temp += 1
	if k == 1:
		print('YES')
	else:
		print('NO')


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

def fun(arr, n, sum):
	subset = [[False for j in range(sum + 1)] for i in range(3)]
	for i in range(n + 1):
		for j in range(sum + 1):
			if j == 0:
				subset[i % 2][j] = True
			elif i == 0:
				subset[i % 2][j] = False
			elif arr[i - 1] <= j:
				subset[i % 2][j] = subset[(i + 1) % 2][j - arr[i - 1]] or subset[(i + 1) % 2][j]
			else:
				subset[i % 2][j] = subset[(i + 1) % 2][j]
	return subset[n % 2][sum]
from math import log2
for _ in range(int(input())):
	n = int(input())
	a = list(mi())
	if fun(a, n, 2048):
		print('YES')
	else:
		print('NO')


n = int(input())

def cal(digs):
	if 2048 in digs:
		return True
	digs.sort()
	temp = {}
	for i in digs:
		if i not in temp:
			temp[i] = 1
		else:
			temp[i] += 1
	kk = list(temp.keys())
	kk.sort()
	ori = kk[0]
	while ori < 2048:
		if ori in temp and temp[ori] > 1:
			if 2 * ori in temp:
				temp[2 * ori] += temp[ori] // 2
			else:
				temp[2 * ori] = temp[ori] // 2
		ori = 2 * ori
	if 2048 in temp:
		return True
	else:
		return False
for i in range(n):
	len = int(input())
	digs = [int(x) for x in input().split()]
	if cal(digs):
		print('YES')
	else:
		print('NO')


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	a = Counter(list(map(int, input().split())))
	for i in range(11):
		a[1 << i + 1] += a[1 << i] // 2
	if a[2048] > 0:
		print('YES')
	else:
		print('NO')


for u in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	f = 0
	c = 0
	for i in l:
		if i == 2048:
			f = 1
			break
		elif i < 2048:
			c = c + i
		if c >= 2048:
			f = 1
			break
	if f == 0:
		print('NO')
	else:
		print('YES')


for x in range(int(input())):
	a = int(input())
	l = list(filter(lambda x: x <= 2048, map(int, input().split())))
	print(['NO', 'YES'][sum(l) >= 2048])


Q = int(input())

def solve():
	N = int(input())
	S = list(map(int, input().split()))
	S = sorted(S)
	while len(S) > 1:
		if S[0] == 2048:
			return True
		if S[0] == S[1]:
			S = [2 * S[0]] + S[2:]
		else:
			S = S[1:]
		S = sorted(S)
	return 2048 in S
for _ in range(Q):
	if solve():
		print('YES')
	else:
		print('NO')


def win():
	a = list(map(int, input().split()))
	k = 1
	while 2048 not in a and k < 2048:
		while a.count(k) > 1:
			a.remove(k)
			a.remove(k)
			a.append(k * 2)
		k *= 2
	if 2048 in a:
		return 'YES'
	else:
		return 'NO'
q = int(input())
for i in range(q):
	n = int(input())
	print(win())


def subarray(a):
	n = len(a)
	if 2048 in a:
		return 'yes'
	s = []
	for i in range(n - 1):
		for j in range(i + 1, n + 1):
			s.append(sum(a[i:j + 1]))
	if 2048 in s:
		return 'yes'
	else:
		return 'no'
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort(reverse=True)
	print(subarray(a))


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	data = defaultdict(int)
	for x in arr:
		data[x] += 1
	x = 1
	while x < 2048:
		data[x * 2] += data[x] // 2
		x = x * 2
	if data[x] > 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for o in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	c = [0] * 3000
	for x in a:
		if x < 3000:
			c[x] += 1
	ans = 0
	i = 1
	while i < 1049:
		ans = ans // 2 + c[i]
		i *= 2
	if ans > 1 or c[2048] > 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = sorted([int(x) for x in input().split()])
	vals = []
	for i in range(29):
		vals.append(l.count(2 ** i))
	for i in range(11):
		vals[i + 1] += vals[i] // 2
	if vals[11] >= 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	arr = {1: 0, 2: 0, 4: 0, 8: 0, 16: 0, 32: 0, 64: 0, 128: 0, 256: 0, 512: 0, 1024: 0, 2048: 0}
	flag = 0
	for i in a:
		if i in arr:
			arr[i] = arr[i] + 1
	temp = 1
	while temp > 0:
		temp -= 1
		for (key, val) in arr.items():
			if arr[2048] > 0:
				flag = 1
				break
			if val >= 2:
				arr[key] = arr[key] - 2
				temp = key * 2
				if temp in arr:
					arr[temp] += 1
				else:
					arr[temp] = 1
				temp += 1
	if flag:
		print('YES')
	else:
		print('NO')


from sys import stdin
import math
t = int(stdin.readline())
while t:
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	ans = 'no'
	if 2048 in arr:
		ans = 'yes'
	else:
		s = 0
		for e in arr:
			if e <= 2048:
				s += e
		if s >= 2048:
			ans = 'yes'
	print(ans)
	t -= 1


q = int(input())
for i in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	ans = ''
	s = 0
	for i in range(len(l)):
		z1 = 0
		z2 = 0
		z4 = 0
		z8 = 0
		z16 = 0
		z32 = 0
		z64 = 0
		z128 = 0
		z256 = 0
		z512 = 0
		z1024 = 0
		for j in range(len(l)):
			if l[j] == 2048:
				ans = 'YES'
				break
			elif l[j] == 1:
				z1 = z1 + 1
			elif l[j] == 2:
				z2 = z2 + 1
			elif l[j] == 4:
				z4 = z4 + 1
			elif l[j] == 8:
				z8 = z8 + 1
			elif l[j] == 16:
				z16 = z16 + 1
			elif l[j] == 32:
				z32 = z32 + 1
			elif l[j] == 64:
				z64 = z64 + 1
			elif l[j] == 128:
				z128 = z128 + 1
			elif l[j] == 1:
				z128 = z128 + 1
			elif l[j] == 256:
				z256 = z256 + 1
			elif l[j] == 512:
				z512 = z512 + 1
			elif l[j] == 1024:
				z1024 = z1024 + 1
			if z1 == 2 or z2 == 2 or z4 == 2 or (z8 == 2) or (z16 == 2) or (z32 == 2) or (z64 == 2) or (z128 == 2) or (z256 == 2) or (z512 == 2) or (z1024 == 2):
				break
		if z1 == 2:
			l.remove(1)
			l.remove(1)
			l.append(2)
			s = 1 * 2
		if z2 == 2:
			l.remove(2)
			l.remove(2)
			l.append(4)
			s = 2 * 2
		if z4 == 2:
			l.remove(4)
			l.remove(4)
			l.append(8)
			s = 4 * 2
		if z8 == 2:
			l.remove(8)
			l.remove(8)
			l.append(16)
			s = 8 * 2
		if z16 == 2:
			l.remove(16)
			l.remove(16)
			l.append(32)
			s = 16 * 2
		if z32 == 2:
			l.remove(32)
			l.remove(32)
			l.append(64)
			s = 32 * 2
		if z64 == 2:
			l.remove(64)
			l.remove(64)
			l.append(128)
			s = 64 * 2
		if z128 == 2:
			l.remove(128)
			l.remove(128)
			l.append(256)
			s = 128 * 2
		if z256 == 2:
			l.remove(256)
			l.remove(256)
			l.append(512)
			s = 256 * 2
		if z512 == 2:
			l.remove(512)
			l.remove(512)
			l.append(1024)
			s = 512 * 2
		if z1024 == 2:
			l.remove(1024)
			l.remove(1024)
			l.append(2048)
			s = 1024 * 2
		if s == 2048:
			ans = 'YES'
			break
	if ans != 'YES':
		ans = 'NO'
	print(ans)


n = int(input())
import math
for i in range(n):
	lt = [0] * 12
	m = int(input())
	ls = [int(x) for x in input().split()]
	for j in range(m):
		if ls[j] > 2048:
			continue
		lt[int(math.log2(ls[j]))] += 1
	for j in range(11):
		lt[j + 1] += lt[j] // 2
	if lt[11] > 0:
		print('YES')
	else:
		print('NO')


from math import log
num_queries = int(input())
for _ in range(num_queries):
	length = int(input())
	numbers = list(map(int, input().split(' ')))
	if sum(numbers) >= 2048:
		if 2048 in numbers:
			print('YES')
		else:
			powers = [0] * 12
			for num in numbers:
				if num < 2048:
					power = log(num, 2)
					if power.is_integer() and power < 12:
						powers[int(power)] += 1
			for i in range(len(powers) - 1):
				powers[i + 1] += powers[i] // 2
			if powers[11]:
				print('YES')
			else:
				print('NO')
	else:
		print('NO')


def game():
	num_queries = int(input())
	for i in range(num_queries):
		num = int(input())
		temp = list(map(int, input().split()))
		temp.sort(reverse=True)
		sum = 0
		for j in temp:
			if j > 2048:
				continue
			sum += j
			if sum == 2048:
				print('YES')
				break
		if sum != 2048:
			print('NO')
game()


from collections import Counter
queries = int(input())
for _ in range(queries):
	n = int(input())
	numbers = Counter([int(x) for x in input().split()])
	(t, quantity) = (2048, 1)
	while t > 0:
		if numbers[t] >= quantity:
			print('YES')
			break
		elif numbers[t] > 0:
			quantity -= numbers[t]
		(t, quantity) = (t // 2, quantity * 2)
	if t == 0:
		print('NO')


for i in range(int(input())):
	a = int(input())
	arr = list(map(int, input().split()))
	sumi = 0
	for k in arr:
		if k <= 2048:
			sumi += k
			if sumi >= 2048:
				print('YES')
				break
	else:
		print('NO')


q = int(input())
for _ in range(q):
	d = dict()
	for i in range(0, 13):
		d[pow(2, i)] = 0
	n = int(input())
	s = [int(i) for i in input().split()]
	for i in s:
		if i <= 2048:
			d[i] += 1
	for i in d.keys():
		if i < 2048:
			d[i * 2] += d[i] // 2
	if d[2048] != 0:
		print('YES')
	else:
		print('NO')


ans = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	temp = []
	for i in arr:
		if i <= 2048:
			temp.append(i)
	c = []
	for i in ans:
		x = temp.count(i)
		c.append(x)
	for i in range(len(ans) - 1):
		c[i + 1] += c[i] // 2
	if c[-1] >= 1:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(0, q):
	n = int(input())
	l = list(map(int, input().split(' ')))
	l.sort(reverse=True)
	sum = 0
	ans = 'NO'
	for i in l:
		if i <= 2048:
			sum = sum + i
			if sum == 2048:
				ans = 'YES'
				break
	sum = 0
	print(ans)


q = int(input())

def change(n):
	global s
	if s.count(n) >= 2:
		s.remove(n)
		s.remove(n)
		s.append(n * 2)
		return True
	return False
for _ in range(q):
	l = int(input())
	s = [int(i) for i in input().split()]
	for i in range(0, 12):
		i = 2 ** i
		while True:
			if not change(i):
				break
		if 2048 in s:
			print('yes')
			break
		if i == 1024:
			print('no')
			break


n = int(input())
result = list()
for i in range(n):
	x = input()
	res = list(map(int, input().split(' ')))
	for j in range(len(res)):
		if res[j] > 2048:
			res[j] = 0
	if sum(res) >= 2048:
		result.append('YES')
	else:
		result.append('NO')
for i in range(len(result)):
	print(result[i])


q = int(input())
for i in range(q):
	n = int(input())
	arr = [int(x) for x in input().split() if int(x) <= 2048]
	print('YES' if sum(arr) >= 2048 else 'NO')


from itertools import combinations
for _ in range(int(input())):
	rs = 0
	data = []
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	for i in arr:
		if i <= 2048:
			data.append(i)
	rs = sum(data)
	if rs >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
import math
for qtimes in range(q):
	num = int(input())
	nli = [0 for i in range(13)]
	li = [int(i) for i in input().split(' ')]
	for i in li:
		exp = int(math.log2(i))
		if exp > 11:
			continue
		else:
			nli[exp] += 1
	for i in range(len(nli)):
		if i == 11:
			if nli[11] > 0:
				print('YES')
			else:
				print('NO')
			break
		if nli[i] >= 2:
			nli[i + 1] += nli[i] >> 1
			nli[i] = nli[i] & 1


T = int(input())
while T > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	s = 0
	for ele in arr:
		if ele <= 2048:
			s += ele
	if s >= 2048:
		print('YES')
	else:
		print('NO')
	T -= 1


q = int(input())
for i in range(0, q):
	n = int(input())
	s = list(map(int, input().split()))
	su = 0
	for j in range(0, n):
		if s[j] <= 2048:
			su = su + s[j]
	if su >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	lista = list(map(int, input().split(' ')))
	suma = 0
	for i in lista:
		if i <= 2048:
			suma += i
	if suma >= 2048:
		print('YES')
	else:
		print('NO')


n = int(input())
for h in range(n):
	m = int(input())
	a = [int(x) for x in input().split()]
	b = []
	c = []
	for l in range(m):
		if a[l] < 4096:
			b.append(a[l])
	while len(set(b)) != len(b) and 2048 not in b:
		for x in range(len(b)):
			if b[x] not in c:
				c.append(b[x])
			else:
				c.remove(b[x])
				c.append(b[x] * 2)
		b.clear()
		b.extend(c)
		c = []
	if 2048 in b:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	b = int(input())
	c = map(int, input().split())
	summ = 0
	for j in c:
		if j <= 2048:
			summ += j
	if summ >= 2048:
		print('Yes')
	else:
		print('No')


t = int(input())
while t is not 0:
	n = int(input())
	s = list(map(int, input().split()))
	s = [i for i in s if i <= 2048]
	print('YES' if sum(s) >= 2048 else 'NO')
	t = t - 1


import math
n = int(input())
for i in range(n):
	temp = [0 for i in range(12)]
	no = int(input())
	arr = list(map(int, input().strip().split()))
	for i in range(no):
		if arr[i] <= 2048:
			temp[int(math.log(arr[i], 2))] += 1
	for i in range(1, 12):
		temp[i] += temp[i - 1] // 2
	if temp[11] >= 1:
		print('YES')
	else:
		print('NO')


n = int(input())
for _ in range(n):
	a = int(input())
	b = list(map(int, input().split()))
	sum = 0
	flag = 0
	k = 2
	if 2048 not in b:
		while k > 1:
			for i in b:
				if b.count(i) > 1:
					sum = i + i
					b.append(sum)
					b.remove(i)
					b.remove(i)
					if sum == 2048:
						flag = 1
			l = list()
			for i in b:
				l = l + [b.count(i)]
			if max(l) == 1:
				k = 0
		if flag == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	summ = 0
	li = map(int, input().split())
	for i in li:
		if i < 2048:
			summ += i
		if i == 2048:
			summ += 2048
	if summ >= 2048:
		print('YES')
	else:
		print('NO')


a = int(input())
fin = []
for j in range(a):
	b = int(input())
	ls = [int(i) for i in input().strip().split()]
	ls.sort(reverse=True)
	ans = 0
	flag = 0
	for i in ls:
		if i == 2048 or ans == 2048:
			temp = 'YES'
			flag = 1
			break
		elif i < 2048:
			ans += i
	if ans == 2048 and flag != 1:
		temp = 'YES'
	elif flag == 0:
		temp = 'NO'
	fin.append(temp)
for i in fin:
	print(i)


import sys, os, re, datetime, copy
from collections import *
from bisect import *
from math import *

def mat(v, *dims):

	def dim(i):
		return [copy.copy(v) for _ in range(dims[-1])] if i == len(dims) - 1 else [dim(i + 1) for _ in range(dims[i])]
	return dim(0)
__cin__ = None

def cin():
	global __cin__
	if __cin__ is None:
		__cin__ = iter(input().split(' '))
	try:
		return next(__cin__)
	except StopIteration:
		__cin__ = iter(input().split(' '))
		return next(__cin__)

def iarr(T, n):
	return [T(cin()) for _ in range(n)]

def carr(n):
	return input()

def imat(T, n, m):
	return [iarr(T, m) for _ in range(n)]

def cmat(n, m):
	return [input() for _ in range(n)]
q = int(cin())
for i in range(q):
	n = int(cin())
	a = iarr(int, n)
	a.sort(key=lambda x: x)
	l = list(filter(lambda x: x <= 2048, a))
	f = mat(0, 4097)
	for v in l:
		f[v] += 1
	for j in range(2049):
		f[2 * j] += f[j] // 2
	if f[2048] > 0:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = [0] * 12
	for i in a:
		t = int(math.log2(i))
		if t > 11:
			pass
		else:
			d[t] += 1
	for i in range(len(d) - 1):
		d[i + 1] += d[i] // 2
	if d[11] >= 1:
		print('YES')
	else:
		print('NO')


def main():
	import sys
	from collections import Counter
	input = sys.stdin.readline
	q = int(input())
	for _ in range(q):
		N = int(input())
		A = list(map(int, input().split()))
		C = Counter(A)
		for i in range(11):
			C[2 ** (i + 1)] += C[2 ** i] // 2
		if C[2048]:
			print('YES')
		else:
			print('NO')
main()


import heapq
q = int(input())
for i in range(q):
	n = int(input())
	A = list(map(int, input().split()))
	l = []
	for i in range(len(A)):
		heapq.heappush(l, A[i])
	flag = True
	while len(l) > 1:
		a = heapq.heappop(l)
		b = heapq.heappop(l)
		if a == 2048 or b == 2048:
			flag = False
			print('Yes')
			break
		if a == b:
			heapq.heappush(l, 2 * a)
		else:
			heapq.heappush(l, b)
	if len(l) != 0 and flag:
		if l[0] == 2048 and flag:
			print('Yes')
		else:
			print('No')
	elif flag:
		print('No')


n = int(input())
for i in range(n):
	m = int(input())
	a = list(map(int, input().split()))
	x = sum((i for i in a if i <= 2048))
	if x >= 2048:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
import heapq
q = int(input())
for testcases in range(q):
	n = int(input())
	S = list(map(int, input().split()))
	heapq.heapify(S)
	while S:
		x = heapq.heappop(S)
		if x == 2048:
			print('YES')
			break
		if len(S) == 0:
			print('NO')
			break
		y = heapq.heappop(S)
		if x == y:
			heapq.heappush(S, x + y)
		else:
			heapq.heappush(S, y)


for _ in range(int(input())):
	from collections import Counter
	import bisect
	n = int(input())
	ls = list(map(int, input().split()))
	if 2048 in ls:
		print('Yes')
	else:
		ls.sort()
		var = bisect.bisect_left(ls, 2048)
		if sum(ls[:var]) >= 2048:
			print('Yes')
		else:
			print('No')


from sys import stdin
from math import ceil, log
q = int(stdin.readline().strip())
for _ in range(q):
	n = int(stdin.readline().strip())
	arr = list(map(int, stdin.readline().split()))
	while True:
		arr.sort()
		if 2048 in arr:
			print('YES')
			break
		temp = []
		for i in arr:
			if i > 2048:
				pass
			else:
				temp.append(i)
		arr = temp
		temp = []
		for i in range(1, len(arr)):
			if arr[i] == arr[i - 1]:
				temp.append(arr[i] * 2)
				for j in range(i + 1, len(arr)):
					temp.append(arr[j])
				break
		else:
			print('NO')
			break
		arr = temp


q = int(input())
for qq in range(q):
	n = int(input())
	ar = list(map(int, input().split()))
	arr = []
	ans = False
	for i in range(n):
		if ar[i] == 2048:
			ans = True
		elif ar[i] < 2048:
			arr.append(ar[i])
	arr.sort()
	arr = arr[::-1]
	temp = 0
	for i in range(len(arr)):
		xx = temp + arr[i]
		if xx > 2048:
			continue
		elif xx == 2048:
			ans = True
			break
		else:
			temp = xx
	if ans:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	if 2048 in a:
		print('YES')
	else:
		count = 0
		out = False
		for i in a:
			if i < 2048:
				count += i
			if count >= 2048:
				out = True
				break
		print('YES' if out else 'NO')


Q = int(input())
d = {}
for q in range(Q):
	sm = 0
	n = int(input())
	s = list(map(int, input().split()))
	for ss in s:
		d[ss] = d.get(ss, 0) + 1
		if ss <= 2048:
			sm += ss
		if sm >= 2048:
			print('YES')
			break
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = int(input())
	s = [int(x) for x in input().split()]
	if 2048 in s:
		print('YES')
	else:
		p = 0
		for j in range(a):
			if s[j] < 2048:
				p += s[j] / 2048
		if p >= 1:
			print('YES')
		else:
			print('NO')


n = int(input())
count = 0
for _ in range(n):
	k = int(input())
	a = list(map(int, input().split()))
	b = []
	for ele in a:
		if ele <= 2048:
			b.append(ele)
	if sum(b) >= 2048:
		print('YES')
	else:
		print('NO')


n = input()
for i in range(int(n)):
	k1 = input()
	k2 = input()
	lis0 = k2.split(' ')
	lis1 = []
	sum = 0
	found = False
	for i in lis0:
		lis1.append(int(i))
	lis1.sort()
	lis1.reverse()
	if min(lis1) > 2048:
		print('NO')
	else:
		while max(lis1) > 2048:
			lis1.pop(0)
		for i in range(len(lis1)):
			sum += lis1[i]
			if sum == 2048:
				print('YES')
				found = True
				break
		if not found:
			print('NO')


from collections import Counter, defaultdict

def solve():
	n = int(input())
	arr = map(int, input().split())
	dd = defaultdict(int)
	pows = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
	for i in pows:
		dd[i] = 0
	for i in arr:
		if i <= 2048:
			dd[i] += 1
	for i in pows:
		dd[i * 2] += dd[i] // 2
	if dd[2048]:
		print('YES')
	else:
		print('NO')
for i in range(int(input())):
	solve()


q = int(input())
re = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
while q:
	n = int(input())
	l = list(map(int, input().split()))
	ll = [0] * 2049
	for i in l:
		if i <= 2048:
			ll[i] += 1
	lol = 1
	cou = 1
	while lol and cou:
		cou = 0
		for i in re:
			if ll[2048] != 0:
				lol = 0
				break
			a = ll[i]
			if a > 1:
				cou = 1
			if a % 2 == 0:
				ll[i] = 0
				if 2 * i <= 2048:
					ll[2 * i] += a // 2
			else:
				ll[i] = 1
				a -= 1
				if 2 * i <= 2048:
					ll[2 * i] += a // 2
	if ll[2048]:
		print('YES')
	else:
		print('NO')
	q -= 1


c = int(input())
qq = []
for i in range(0, c):
	qq.append(' ')
for i in range(0, c):
	input()
	s = input().split(' ')
	for j in range(0, len(s)):
		s[j] = int(s[j])
	if 2048 in s:
		qq[i] = 'YES'
	else:
		s.sort(reverse=True)
		j = 0
		while j < len(s) and s[j] > 2048:
			s.remove(s[j])
			j = j + 1
		j = 0
		tf = False
		while j < len(s) - 1:
			if s[j] == s[j + 1]:
				s[j + 1] = s[j] + s[j + 1]
				s.remove(s[j])
				if 2048 in s:
					qq[i] = 'YES'
					tf = True
					break
				j = 0
			else:
				j = j + 1
		if tf == False:
			qq[i] = 'NO'
for i in qq:
	print(i)


list = []

def gg():
	for i in range(len(list)):
		for j in range(i + 1, len(list)):
			if list[i] == list[j]:
				return [i, j]
	return False

def cal():
	global list
	input()
	list = [int(x) for x in input().split()]
	if 2048 in list:
		return 'YES'
	indicator = gg()
	while indicator:
		if 2048 in list:
			return 'YES'
		list.append(list.pop(indicator[0]) + list.pop(indicator[1] - 1))
		indicator = gg()
	if 2048 in list:
		return 'YES'
	return 'NO'
for i in range(int(input())):
	print(cal())


def f(l, n):
	l.sort(reverse=True)
	i = 0
	while i < n and l[i] > 2048:
		i += 1
	r = 2048
	while i < n and r > 0:
		r -= l[i]
		i += 1
	return r == 0
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	print('YES' if f(l, n) else 'NO')


t = int(input())
for kk in range(t):
	n = int(input())
	l = filter(lambda x: x <= 2048, map(int, input().split()))
	print('yes' if sum(l) >= 2048 else 'no')


for q in range(int(input())):
	n = int(input())
	a = map(int, input().split())
	d = {}
	for i in a:
		try:
			d[i] += 1
		except KeyError:
			d[i] = 1
	x = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
	res = [0] * len(x)
	if 1 in d:
		res[0] = d[1]
	for i in range(1, len(x)):
		res[i] = res[i - 1] // 2
		if x[i] in d:
			res[i] += d[x[i]]
	if res[-1] == 0:
		print('NO')
	else:
		print('YES')


def main():
	a = int(input())
	for i in range(a):
		temp = int(input())
		values = list(filter(lambda x: x <= 2048, map(int, input().split())))
		if len(values) is 0:
			print('no')
			continue
		total = sum(values)
		if total >= 2048:
			print('yes')
		else:
			print('no')
main()


q = int(input())
for _ in range(q):
	n = int(input())
	s = [0] * 15
	for ss in map(int, input().split()):
		if ss > 2048:
			continue
		s[ss.bit_length()] += 1
	for i in range(0, 11 + 1):
		s[i + 1] += s[i] // 2
	print('YES' if s[12] != 0 else 'NO')


q = int(input())
while q:
	n = int(input())
	s = [int(x) for x in input().split()]
	s.sort(reverse=True)
	f = 0
	while n:
		i = 0
		j = len(s) - 1
		if 2048 in s:
			f = 1
			break
		while j:
			if s[i] == s[i + 1]:
				s[i] = s[i] + s[i + 1]
				s.pop(i + 1)
				j -= 1
				break
			i += 1
			j -= 1
		n -= 1
	if f == 1 or s[0] == 2048:
		print('YES')
	else:
		print('NO')
	q -= 1


import math
q = int(input())
inputlist = []
for i in range(q):
	n = int(input())
	ls = list(map(int, input().split()))
	inputlist.append(ls)
outputlist = []

def possibility(somelist, outlist):
	checklist = []
	for i in range(12):
		checklist.append(0)
	for j in somelist:
		m = int(math.log(j, 2))
		if m <= 11:
			checklist[m] += 1
		else:
			continue
	for i in range(len(checklist) - 1):
		checklist[i + 1] += math.floor(checklist[i] / 2)
	if checklist[-1] > 0:
		outlist.append('YES')
	else:
		outlist.append('NO')
for somelist in inputlist:
	possibility(somelist, outputlist)
for j in outputlist:
	print(j)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	i = 0
	a.sort()
	f = 0
	while i < len(a) - 1:
		if 2048 in a:
			f = 1
			break
		elif a[i] == a[i + 1]:
			a.append(2 * a[i])
			i += 2
			a.sort()
		else:
			i += 1
	if 2048 in a:
		print('YES')
	else:
		print('NO')


def solve():
	nb = int(input())
	arr = list(map(lambda u: int(u), input().split(' ')))
	s = 0
	for n in arr:
		if n < 2048:
			s += n
		elif n == 2048:
			return 'YES'
	return 'YES' if s >= 2048 else 'NO'
ts = int(input())
for _ in range(ts):
	print(solve())


q = int(input())
for i in range(q):
	sub = int(input())
	main = list(map(int, input().split()))
	main.sort(reverse=True)
	temp = 0
	for j in range(sub):
		if main[j] <= 2048:
			if temp < 2048:
				temp += main[j]
	if temp == 2048:
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	k = int(input())
	s = input().split()
	l = [int(i) for i in s if int(i) <= 2048]
	print('Yes' if sum(l) >= 2048 else 'No')


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	ar = sorted(ar, reverse=True)
	count = 0
	s = 0
	for i in ar:
		if i <= 2048:
			count += i
			if count == 2048:
				s = 1
				print('YES')
				break
	if s == 0:
		print('NO')


testcases = int(input())
while testcases > 0:
	testcases = testcases - 1
	length = int(input())
	arr = list(map(int, input().split()))
	s = 0
	ans = False
	for x in arr:
		if x == 2048:
			ans = True
			break
		elif x < 2048:
			s = s + x
			if s >= 2048:
				ans = True
				break
			else:
				continue
	if ans:
		print('Yes')
	else:
		print('No')


from collections import defaultdict as dd
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = 0
	flag = 0
	for i in a:
		if i <= 2048:
			s += i
		if s >= 2048:
			flag = 1
			print('YES')
			break
	if not flag:
		print('NO')


import bisect
q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().rstrip().split()))
	d = dict()
	flag = 0
	for i in a:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	a.sort()
	while len(a) > 1:
		if 2048 in a:
			flag = 1
			break
		if a[0] == a[1]:
			sum1 = 2 * a[0]
			a.pop(0)
			a.pop(0)
			bisect.insort(a, sum1)
		else:
			a.pop(0)
	if 2048 in a:
		flag = 1
	if flag == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for test_case in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	flag = False
	for j in range(n):
		a.sort()
		lent = len(a)
		i = 0
		while i < lent - 1:
			if 2048 in a:
				flag = True
			if a[i] == a[i + 1]:
				a[i] += a[i + 1]
				a.pop(i + 1)
				lent -= 1
			else:
				i += 1
		if 2048 in a:
			flag = True
	if flag:
		print('YES')
	else:
		print('NO')


n = int(input())
a = []
for i in range(n):
	k = int(input())
	s = [int(i) for i in input().split()]
	s.sort()
	isTrue = False
	for j in range(len(s)):
		counter = 0
		for i in range(j, len(s)):
			counter += s[i]
			if counter == 2048:
				a.append(1)
				isTrue = True
				break
			elif counter > 2048:
				break
		if isTrue:
			break
	if isTrue == False:
		a.append(0)
for i in a:
	if i == 1:
		print('YES')
	else:
		print('NO')


q = int(input())
n = []
nums = []
sub = 0
for x in range(q):
	n.append(int(input()))
	nums.append(input().split())
for i in range(q):
	for j in range(n[i]):
		nums[i][j] = int(nums[i][j])
for l in range(q):
	tempset = []
	permset = []
	tempset = nums[l]
	for k in range(len(tempset)):
		if tempset[k] <= 2048:
			permset.append(tempset[k])
	if sum(permset) >= 2048:
		print('YES')
	else:
		print('NO')


def checker(nums):
	ax = [m for m in nums if m < 2050]
	if sum(ax) >= 2048:
		return 'YES'
	else:
		return 'NO'
q = int(input())
for i in range(q):
	n = int(input())
	x = input()
	xn = [int(z) for z in x.split()]
	print(checker(xn))


q = int(input())
ans = []
for i in range(q):
	n = int(input())
	multiset = list(map(int, input().split()))
	multiset = list(filter(lambda x: x <= 2048, multiset))
	if sum(multiset) >= 2048:
		ans.append('YES')
	else:
		ans.append('NO')
print('\n'.join(ans))


from collections import Counter
t = int(input())
for i in range(t):
	n = int(input())
	inp = list(map(int, input().split()))
	inp = [i for i in inp if i <= 2048]
	c = Counter(inp)
	if c[2048] == 1:
		print('YES')
	else:
		k = 1
		while k < 2048:
			c[2 * k] += c[k] // 2
			k = 2 * k
		if c[2048] >= 1:
			print('Yes')
		else:
			print('No')


def digit(n):
	res = 0
	while n > 1:
		res += 1
		n = n // 2
	return res

def solution(data):
	res = [0 for i in range(12)]
	for i in range(len(data)):
		if digit(data[i]) > 11:
			continue
		res[digit(data[i])] += 1
	if res[-1] > 0:
		return True
	for i in range(len(res) - 1):
		if res[i] > 1:
			res[i + 1] += res[i] // 2
	return res[-1] > 0
N = int(input().strip())
data = []
for i in range(N):
	x = input()
	tmp = list(map(int, input().strip().split(' ')))
	data.append(tmp)
for i in range(N):
	if solution(data[i]):
		print('YES')
	else:
		print('NO')


from collections import Counter
n = int(input())
for _ in range(n):
	a = input()
	li = list(map(int, input().split()))
	co = Counter(li)
	check = 1
	result = 0
	if 2048 in li:
		print('YES')
		continue
	while check:
		check = 0
		for i in co.copy():
			if co[i] >= 2:
				check = 1
				result = 2 * i
				co[result] = co[result] + 1
				co[i] = co[i] - 2
			if result == 2048:
				check = 0
				break
	if result == 2048:
		print('YES')
	else:
		print('NO')


tests = int(input())
for i in range(tests):
	count = {}
	_ = input()
	numbers = list(map(int, input().split(' ')))
	for number in numbers:
		if number in count:
			count[number] = count[number] + 1
		else:
			count[number] = 1

	def solve(number):
		if number in count and count[number] > 0:
			count[number] = count[number] - 1
			return True
		if number == 1:
			return False
		return solve(number // 2) and solve(number // 2)
	if solve(2048) == True:
		print('YES')
	else:
		print('NO')


import math
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	flag = 0
	if 2048 in a:
		print('YES')
	else:
		for i in range(n):
			b.append(int(math.log(a[i], 2)))
		for i in range(len(b) - 1):
			b.sort()
			if b[i] == b[i + 1]:
				b[i] = b[i] + 1
				b[i + 1] = 0
			if b[i] == 11:
				flag = 1
				break
		if flag == 1:
			print('YES')
		else:
			print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	a = sorted(map(int, input().split()))
	s = 0
	for j in range(n - 1, -1, -1):
		if s + a[j] <= 2048:
			s += a[j]
	if s == 2048:
		print('YES')
	else:
		print('NO')


def game(d):
	num = 0
	for i in d.keys():
		d[i] += num
		num = d[i] // 2
result_num = 2048
result_pow = 12
num = int(input())
result_list = []
for i in range(num):
	num_of_numbers = int(input())
	input_lst = input().split()
	input_lst = [int(num) for num in input_lst]
	d = dict.fromkeys([2 ** i for i in range(result_pow + 1)], 0)
	for num in input_lst:
		if num <= result_num:
			d[num] += 1
	game(d)
	if d[result_num] != 0:
		result_list.append('Yes')
	else:
		result_list.append('No')
for answer in result_list:
	print(answer)


from sys import stdin
from collections import defaultdict
for i in range(int(input())):
	n = int(input())
	l = sorted(map(int, stdin.readline().split()))
	dic = defaultdict(int)
	for j in l:
		dic[j] += 1
	for j in range(1, 12):
		dic[2 ** j] += dic[2 ** (j - 1)] // 2
	if dic[2048] > 0:
		print('Yes')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	flag = 0
	if 2048 in arr:
		print('yes')
	else:
		while 2048 not in arr:
			flag = 0
			for i in range(len(arr) - 1):
				if arr[i] == arr[i + 1]:
					x = arr[i]
					arr.pop(i)
					arr.pop(i)
					arr.append(2 * x)
					flag = 1
					break
			arr = sorted(arr)
			if 2048 in arr:
				break
			elif len(arr) == 1:
				break
			if flag == 0:
				break
		if 2048 in arr:
			print('Yes')
		else:
			print('No')


t = int(input())
for i in range(0, t):
	n = int(input())
	ls = [int(j) for j in input().split(' ')]
	sm = 0
	for j in ls:
		if j > 2048:
			continue
		sm += j
	if sm >= 2048:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = [int(x) for x in input().split()]
	s.sort()
	if 2048 in s:
		print('YES')
	else:
		t = 0
		if s[0] > 2048:
			print('NO')
		else:
			for i in s:
				if i < 2048:
					t = t + i
				else:
					break
			if t >= 2048:
				print('YES')
			else:
				print('NO')


elem = int(input())
for x in range(elem):
	elem2 = int(input())
	ar = []
	for t in input().split(' '):
		if int(t) >= 4096:
			continue
		ar.append(int(t))
	ar = sorted(ar)
	if sum(ar) < 2048:
		print('NO')
		continue
	if 2048 in ar:
		print('YES')
		continue
	temp = ar.copy()
	while True:
		check = 0
		for i in range(len(temp)):
			if i != len(temp) - 1:
				if temp[i] == temp[i + 1]:
					qwe = temp[i] + temp[i + 1]
					temp.append(qwe)
					temp.pop(i + 1)
					temp.pop(i)
					temp = sorted(temp)
					check = 1
					break
		if 2048 in temp:
			print('YES')
			break
		if check == 0:
			print('NO')
			break


from math import log
t = int(input())
for z in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if 2048 in arr:
		print('YES')
		continue
	d = [0 for q in range(40)]
	s = []
	for c in arr:
		if c < 2048:
			s.append(c)
	if sum(s) >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
d = {1: 0}
a = 1
for i in range(1, 30):
	a *= 2
	d[a] = i
for i in range(q):
	n = int(input())
	m = [0] * 100
	inp = list(map(int, input().split()))
	for j in range(n):
		m[d[inp[j]]] += 1
	for j in range(12):
		m[j + 1] += m[j] // 2
	if m[11]:
		print('yes')
	else:
		print('no')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	j = 0
	leng = n
	for i in range(10000):
		if j >= len(a) - 1:
			break
		if a[j] == a[j + 1]:
			a.append(a[j] + a[j])
			j = j + 2
			a.sort()
		else:
			j += 1
	if 2048 in a:
		print('YES')
	else:
		print('NO')


q = int(input())
for t in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	tot = 0
	for i in range(n):
		if l[i] <= 2048:
			tot += l[i]
	if tot >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	y = list(map(int, input().split()))
	y = sorted(y)
	d = {}
	arr = []
	for i in y:
		if i <= 2048:
			arr.append(i)
	i = 0
	while i < 12:
		d[2 ** i] = 0
		i += 1
	for i in arr:
		d[i] += 1
	i = 1
	while d[2048] == 0 and i < 12:
		x = d[2 ** (i - 1)] // 2
		d[2 ** (i - 1)] = d[2 ** (i - 1)] // 2
		d[2 ** i] += x
		i += 1
	if d[2048] > 0:
		print('YES')
	else:
		print('NO')


a = int(input())
while a > 0:
	a -= 1
	tot = 0
	x = int(input())
	lis = []
	lis = list(map(int, input().split()))
	lis = [i for i in lis if i <= 2048]
	tot = sum(lis)
	if tot >= 2048:
		print('Yes')
	else:
		print('No')


def arr():
	return list(map(int, input().split()))
for _ in range(int(input())):
	n = int(input())
	s = arr()
	x = 2048
	y = 1
	while y > 0 and x >= 1:
		if x in s:
			y -= 1
			s.remove(x)
			if y == 0:
				print('YES')
				break
		else:
			x //= 2
			y = y * 2
	else:
		print('NO')


from bisect import bisect_right
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	s = 0
	for i in range(bisect_right(arr, 2048) - 1, -1, -1):
		s += arr[i]
		if s == 2048:
			print('YES')
			break
	else:
		print('NO')


Q = int(input())
for q in range(Q):
	N = int(input())
	arr = list(map(int, input().split()))
	hap = 0
	for i in range(len(arr)):
		if arr[i] > 2048:
			continue
		hap += arr[i]
	if hap >= 2048:
		print('YES')
	else:
		print('No')


a = int(input())
b = []
ans = 0
for i in range(a):
	n = int(input())
	b = list(map(int, input().split()))
	b = sorted(b)[::-1]
	while True:
		if b[-1] == 2048:
			ans = 1
		if len(b) == 1:
			break
		if b[-1] > 2048:
			break
		if b[-1] != b[-1 - 1]:
			b.pop()
		elif b[-1] == b[-1 - 1]:
			b.pop()
			b[-1] = 2 * b[-1]
		b = sorted(b)[::-1]
	if ans == 1:
		print('YES')
	else:
		print('NO')
	ans = 0


q = int(input())
for j in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	while len(s) > 0 and s[0] < 2048:
		if len(s) >= 2:
			if s[0] == s[1]:
				s.append(s[0] * 2)
				s.pop(0)
				s.pop(0)
			else:
				s.pop(0)
		else:
			s.pop(0)
		s.sort()
	if 2048 in s:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	list_str = str(input())
	list_true = [int(x) for x in list_str.split()]
	m = 0
	for k in range(0, n):
		if list_true[k] <= 2048:
			m = m + list_true[k]
		else:
			pass
	if m >= 2048:
		print('YES')
	else:
		print('NO')


import collections as cl
q = int(input())
for _ in range(q):
	n = int(input())
	s = cl.Counter(map(int, input().split()))
	for i in range(12):
		a = 2 ** i
		s[a * 2] += s[a] // 2
	if s[2048]:
		print('YES')
	else:
		print('NO')


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
q = int(input())
for _ in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	curr = 0
	for val in a:
		if val > 2048:
			break
		curr += val
	if curr >= 2048:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	num = int(input())
	seq = list(map(int, input().split()))
	if min(seq) > 2048:
		print('NO')
		continue
	sq = [i for i in seq if i <= 2048]
	sq = sorted(sq, reverse=True)
	flag = 1
	while True:
		i = 1
		st = [sq[0]]
		while i < len(sq):
			if st[-1] == sq[i]:
				st[-1] += sq[i]
			else:
				st.append(sq[i])
			i += 1
		if st[0] >= 2048:
			flag = 0
			print('YES')
			break
		if len(sq) == len(st):
			break
		sq = list(st)
	if flag:
		print('NO')


n = int(input())
for i in range(n):
	input()
	a = list(map(int, input().split()))
	pos = [0] * 2500
	for i in range(len(a)):
		if a[i] <= 2048:
			pos[a[i]] += 1
	for i in range(2000):
		if pos[i] >= 2:
			pos[i * 2] += pos[i] // 2
	if pos[2048] != 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	input()
	nums = list(map(int, input().strip().split()))
	nums.sort()
	i = 0
	while 2048 not in nums:
		if len(nums[i:]) >= 2 and nums[i] == nums[i + 1]:
			nums[i] += nums.pop(i + 1)
			nums.sort()
			i = 0
		elif len(nums[i:]) >= 2:
			i += 1
		else:
			break
		if 2048 in nums:
			break
	if 2048 in nums:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = sorted(l)
	a = []
	for i in range(n):
		if s[i] <= 2048:
			a.append(s[i])
	if sum(a) >= 2048:
		print('YES')
	else:
		print('NO')


__author__ = 'Esfandiar'
from collections import defaultdict
for i in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())), reverse=True)
	num = 2048
	j = 0
	while j < n and num > 0:
		if a[j] <= 2048:
			num -= a[j]
		j += 1
	print('YES' if num == 0 else 'NO')


import math
for i1 in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = dict()
	for i in range(n):
		e = int(math.log(l[i], 2))
		if e not in d:
			d.update({e: 1})
		else:
			d[e] += 1
	ans = 0
	for i in range(11, -1, -1):
		if i in d:
			ans += d[i] / 2 ** (11 - i)
	if ans >= 1:
		print('YES')
	else:
		print('NO')


n = int(input())
for nn in range(n):
	m = int(input())
	arr = [int(x) for x in input().split(' ')]
	d = {}
	index = 0
	while 2 ** index <= 2048:
		d[2 ** index] = 0
		index += 1
	for i in range(m):
		if arr[i] in d:
			d[arr[i]] += 1
		else:
			d[arr[i]] = 1
	index = 0
	while 2 ** index < 2048:
		key = 2 ** index
		index += 1
		d[2 ** index] += d[key] // 2
	if d[2048] > 0:
		print('YES')
	else:
		print('NO')


query = int(input())
for _ in range(query):
	n = int(input())
	s = list(map(int, input().split()))
	r = [element for element in s if element <= 2048]
	if sum(r) >= 2048:
		print('Yes')
	else:
		print('No')


from sys import stdin, stdout
import heapq
test = int(stdin.readline())
for _ in range(test):
	N = int(stdin.readline())
	A = [int(x) for x in stdin.readline().split()]
	heapq.heapify(A)
	while True:
		x = set(list(A))
		if len(A) == len(x):
			if 2048 in A:
				print('YES')
				break
			else:
				print('NO')
				break
		first = heapq.heappop(A)
		second = heapq.heappop(A)
		if first == 2048 or second == 2048:
			print('YES')
			break
		if first == second:
			heapq.heappush(A, first + second)
		else:
			heapq.heappush(A, max(first, second))


def solve(nums):
	d = dict()
	for num in nums:
		cur = num
		if cur == 2048:
			return 'YES'
		while d.get(cur, False):
			d[cur] = False
			cur = 2 * cur
			if cur == 2048:
				return 'YES'
		d[cur] = True
	return 'NO'
q = int(input())
for _ in range(q):
	n = int(input())
	nums = list(map(int, input().split()))
	print(solve(nums))


t = int(input())
for _ in range(t):
	n = int(input())
	l1 = [int(x) for x in input().split() if int(x) <= 2048]
	if 2048 in l1:
		print('YES')
	else:
		l1.sort(reverse=True)
		while l1 and (not 2048 in l1):
			if l1.count(l1[-1]) >= 2:
				k = l1.pop()
				l1.pop()
				l1.append(k * 2)
				l1.sort(reverse=True)
			else:
				l1.pop()
		if len(l1) and 2048 in l1:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	n = int(input())
	d = dict()
	d[1] = 0
	d[2] = 0
	d[4] = 0
	d[8] = 0
	d[16] = 0
	d[32] = 0
	d[64] = 0
	d[128] = 0
	d[256] = 0
	d[512] = 0
	d[1024] = 0
	d[2048] = 0
	for i in [int(x) for x in input().split()]:
		try:
			d[i] += 1
		except:
			pass
	d[2] += d[1] // 2
	d[4] += d[2] // 2
	d[8] += d[4] // 2
	d[16] += d[8] // 2
	d[32] += d[16] // 2
	d[64] += d[32] // 2
	d[128] += d[64] // 2
	d[256] += d[128] // 2
	d[512] += d[256] // 2
	d[1024] += d[512] // 2
	d[2048] += d[1024] // 2
	if d[2048] >= 1:
		print('YES')
	else:
		print('NO')


from collections import *
I = input
for _ in [0] * int(I()):
	I()
	c = Counter(map(int, I().split()))
	i = 1
	while i < 2048:
		c[i * 2] += c[i] // 2
		i *= 2
	print('YNEOS'[c[2048] < 1::2])


from collections import Counter
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

def solve():
	_ = int(input())
	L = list(map(int, input().split()))
	L = list(filter(lambda x: x <= 2048, L))
	C_L = Counter(L)
	mul_2 = [2 ** v for v in range(11)]
	for v in mul_2:
		cnt = C_L[v]
		new_num = cnt // 2
		C_L[v * 2] += new_num
	if C_L[2048] > 0:
		print('YES')
	else:
		print('NO')
N = int(input())
for _ in range(N):
	solve()


n = int(input())
for i in range(n):
	c = input()
	l = list(input().split())
	m = 0
	a = 0
	for k in range(0, 12):
		a = str(int(2048 / 2 ** k))
		m += l.count(a) / 2 ** k
	if m >= 1:
		print('YES')
	else:
		print('NO')


def f(lst):
	if 2048 in lst:
		return 'Yes'
	finished = False
	(count, length) = (0, len(lst))
	while not finished:
		if 2048 in lst:
			return 'Yes'
		if lst[0] in lst[1:]:
			a = lst[0]
			lst.pop(0)
			lst.remove(a)
			lst.append(2 * a)
			count = 0
		else:
			lst = lst[1:] + [lst[0]]
			count += 1
		if count == len(lst):
			finished = True
	return 'No'
number = int(input())
for i in range(number):
	iter = int(input())
	lst = input().split(' ')
	lst = list(map(lambda elem: int(elem), lst))
	print(f(lst))


s = []
T = int(input())
for t in range(T):
	sum = 0
	n = int(input())
	a = [int(k) for k in input().split()]
	a.sort()
	for i in a:
		if i <= 2048:
			sum = sum + i
	if sum >= 2048:
		s.append('YES')
	else:
		s.append('NO')
for i in s:
	print(i)


from collections import Counter
T = int(input())
while T > 0:
	try:
		n = int(input())
		S = [int(x) for x in input().split()]
		c = Counter(S)
		i = 1
		while i < 2048:
			c[i * 2] += c[i] // 2
			i = i * 2
		if c[2048] >= 1:
			print('Yes')
		else:
			print('No')
		T -= 1
	except:
		break


n = int(input())
for i in range(n):
	ff = {}
	r = int(input())
	for j in input().split():
		ff[int(j)] = ff.get(int(j), 0) + 1
	if ff.get(1, 0) > 0:
		ff[2] = ff.get(2, 0) + ff[1] // 2
	for j in range(1, 11):
		c = 2 ** j
		if ff.get(c, 0) >= 2:
			ff[2 ** (j + 1)] = ff.get(2 ** (j + 1), 0) + ff[c] // 2
	if ff.get(2048) != None:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	i = n - 1
	x = 2048
	c = 0
	while i >= 0:
		if l[i] > 2048:
			i -= 1
		elif l[i] <= 2048:
			x = x - l[i]
			if x == 0:
				c = 1
			i -= 1
	if c:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	while len(l) != len(set(l)) and 2048 not in set(l):
		for i in set(l):
			if l.count(i) > 1:
				l.remove(i)
				l.remove(i)
				l.append(i * 2)
	if 2048 in l:
		print('yes')
	else:
		print('no')


n = int(input())
for test_case in range(n):
	input()
	nums_strings = input().split(' ')
	nums = {}
	contains_2048 = False
	for s in nums_strings:
		si = int(s)
		if si == 2048:
			contains_2048 = True
			print('YES')
			break
		if si < 2048:
			if si in nums:
				nums[si] = nums[si] + 1
			else:
				nums[si] = 1
	if contains_2048:
		continue
	sorted_nums = sorted(nums.items(), key=lambda kv: kv[0], reverse=True)
	left = 2048
	for (num, count) in sorted_nums:
		left -= num * count
		if left <= 0:
			contains_2048 = True
			print('YES')
			break
	if contains_2048:
		continue
	print('NO')


import math
q = int(input())
for _ in range(q):
	n = int(input())
	arr = [int(i) for i in input().split()]
	b = [0] * 12
	for i in arr:
		k = int(math.log2(i))
		if k <= 11:
			b[k] += 1
	for i in range(11):
		if b[i] > 1:
			b[i + 1] += b[i] // 2
	if b[11] > 0:
		print('YES')
	else:
		print('NO')


q = int(input())
l = []
for _ in range(q):
	n = int(input())
	mu = [int(x) for x in input().split() if int(x) <= 2048]
	while 1:
		if 2048 in mu:
			l.append('yes')
			break
		if len(set(mu)) == len(mu):
			l.append('no')
			break
		mu.sort()
		for i in range(len(mu) - 1, 0, -1):
			if mu[i] == mu[i - 1]:
				mu.append(2 * mu[i])
				mu.pop(i - 1)
				mu.pop(i - 1)
for a in l:
	print(a)


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

def si():
	return input()

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

def li():
	return list(mi())
import math
t = ii()
for i in range(t):
	n = ii()
	l = li()
	c1 = c2 = 0
	for i in l:
		if i <= 2048 and i != 1:
			c2 += i // 2
		elif i == 1:
			c1 += 1
		if c1 == 2:
			c2 += 1
			c1 = 0
	if c2 >= 1024:
		print('YES')
	else:
		print('NO')


n = int(input())
tmp = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]
for i in range(n):
	(request, number) = (int(input()), list(map(int, input().split())))
	if sum(number) < 2048:
		print('NO')
	else:
		while True:
			flag = 0
			if 2048 in number:
				print('YES')
				break
			for k in tmp:
				if k in number:
					n1 = number.pop(number.index(k))
					if k in number:
						n2 = number.pop(number.index(k))
						number.append(n1 + n2)
						flag = 1
					else:
						number.append(n1)
			if flag == 0:
				print('NO')
				break


q = int(input())
for i in range(q):
	n = int(input())
	arr = [int(i) for i in input().split()]
	sm = 0
	q = 0
	for i in range(n):
		if sm >= 2048:
			print('Yes')
			q = 1
			break
		if arr[i] <= 2048:
			sm += arr[i]
	if sm >= 2048 and q != 1:
		print('Yes')
		continue
	if q == 0:
		print('No')


q = int(input())
d = []
for k in range(12):
	d.append(2 ** k)
for i in range(q):
	n = int(input())
	x = list(map(int, input().split()))
	ans = 0
	a = 12 * [0]
	for j in range(n):
		if x[j] in d:
			a[d.index(x[j])] += 1
	for l in range(len(a) - 1):
		if a[l] > 1:
			a[l + 1] += a[l] // 2
	if a[-1] > 0:
		print('YES')
	else:
		print('NO')


import sys

def main():

	def input():
		return sys.stdin.readline()[:-1]
	q = int(input())
	for _ in range(q):
		n = int(input())
		s = list(map(int, input().split()))
		t = 0
		for e in s:
			if e > 2048:
				pass
			else:
				t += e
		print('YES' if t >= 2048 else 'NO')
main()


q = int(input())
while q > 0:
	n = int(input())
	s = [int(x) for x in input().split(' ')]
	while True:
		flag = True
		for i in s:
			if i < 2048 and s.count(i) > 1:
				s.append(2 * i)
				s.remove(i)
				s.remove(i)
				flag = False
		if flag:
			print('YES' if s.count(2048) != 0 else 'NO')
			break
	q -= 1


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if 2048 in l:
		print('YES')
	else:
		sum = 0
		l.sort()
		flag = 0
		for i in range(0, n):
			if flag == 1:
				break
			sum = 0
			for j in range(i, n):
				sum += l[j]
				if sum > 2048:
					break
				if sum == 2048:
					flag = 1
					break
		if flag == 1:
			print('YES')
		else:
			print('NO')


def go_through(x):
	for k in range(0, 11):
		kn = 2 ** k
		k_if = x.count(int(kn)) // 2
		if k_if > 0:
			for r1 in range(0, 2 * k_if):
				x.remove(int(kn))
			for r2 in range(0, k_if):
				x.append(int(kn) * 2)
	return x
a = input()
for i in range(0, int(a)):
	b = input()
	c = list(map(int, input().split(' ', int(b) - 1)))
	go_through(c)
	if c.count(2048) > 0:
		print('YES')
	else:
		print('NO')
	continue


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	dp = [0] * 3001
	for i in arr:
		if i < 3000:
			dp[i] += 1
	arr1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]
	ex = 0
	for i in arr1:
		ex = (ex + dp[i]) // 2
	if dp[2048] or ex >= 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	_ = input()
	L = [int(x) for x in input().split() if int(x) <= 2048]
	print('YES' if sum(L) >= 2048 else 'NO')


def sePuedeFormar(n, numeros):
	if n == 1:
		if 1 in numeros:
			numeros.pop(numeros.index(1))
			return True
		else:
			return False
	elif n in numeros:
		numeros.pop(numeros.index(n))
		return True
	else:
		return sePuedeFormar(n / 2, numeros) and sePuedeFormar(n / 2, numeros)
q = int(input())
queries = []
for i in range(q):
	n = input()
	queries.append(list(map(int, input().split())))
for numeros in queries:
	print('YES') if sePuedeFormar(2048, numeros) else print('NO')


for q in range(int(input())):
	L = int(input())
	S = list(map(int, input().split(' ')))
	S = [x for x in S if x <= 2048]
	S.sort()
	i = 0
	while len(set(S)) != len(S) and 2048 not in S:
		try:
			if S[i] == S[i + 1]:
				S[i] = S[i] + S[i + 1]
				S.remove(S[i + 1])
			i = (i + 1) % (len(S) - 1)
			S.sort()
		except:
			break
	if 2048 in S:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	l1 = list(map(int, input().split()))
	sum1 = 0
	for i in range(len(l1)):
		if l1[i] <= 2048:
			sum1 += l1[i]
	if sum1 >= 2048:
		print('YES')
	else:
		print('NO')


cnt = {}
T = int(input())
while T:
	T -= 1
	i = 1
	while i <= 2048:
		cnt[i] = 0
		i *= 2
	n = int(input())
	for i in input().split():
		i = int(i)
		if i >= 1 and i <= 2048:
			cnt[i] += 1
	i = 1
	while i < 2048:
		cnt[i * 2] += int(cnt[i] / 2)
		i *= 2
	if cnt[2048]:
		print('YES')
	else:
		print('NO')


queries = int(input())
for _ in range(queries):
	cardinality = int(input())
	multiset = map(int, input().split())
	multiset = filter(lambda x: x <= 2048, multiset)
	if sum(multiset) < 2048:
		print('NO')
	else:
		print('yes')


from collections import Counter
q = int(input())
for i in range(q):
	m = int(input())
	m = Counter(list(map(int, input().split())))
	if m[2048] or m[1024] >= 2:
		print('YES')
		continue
	lasts = 0
	j = 1
	while j < 2047:
		lasts = m[j] + lasts // 2
		j *= 2
	if lasts >= 2:
		print('YES')
	else:
		print('NO')


dict = {}
for i in range(11):
	dict[2 ** (11 - i)] = 2 ** i
q = int(input())
for i in range(q):
	n = int(input())
	q = [int(i) for i in input().split()]
	if 2048 in q:
		print('YES')
		continue
	while max(q) not in dict:
		q.remove(max(q))
		if len(q) == 0:
			break
		n = n - 1
	if len(q) == 0:
		print('NO')
		continue
	if dict[max(q)] > n:
		print('NO')
		continue
	if dict[max(q)] <= n:
		if sum(q) < 2048:
			print('NO')
			continue
		else:
			print('YES')


def log(n):
	ans = 0
	while n > 1:
		n //= 2
		ans += 1
	return ans
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	for x in s:
		if x <= 2048:
			a[log(x)] += 1
	for i in range(11):
		x = a[i]
		x = str(bin(x))[2:]
		x = x[::-1]
		for j in range(len(x)):
			if x[j] == '1':
				if i + j >= 11:
					a[11] += 1
					continue
				a[i + j] += 1
	print('YNEOS'[a[11] <= 0::2])


q = int(input())
for u in range(q):
	n = int(input())
	s = [int(i) for i in input().split()]
	if 2048 in s:
		print('YES')
		continue
	a = []
	sumN = 0
	for i in range(n):
		if s[i] < 2048:
			a.append(s[i])
			sumN += s[i]
	if sumN >= 2048:
		print('YES')
		continue
	else:
		print('NO')
		continue


q = int(input())
ns = []
n = []
i = 0
while i < q:
	nt = int(input())
	n = list(map(int, input().split()))
	mk = []
	an = 0
	i2 = 0
	while i2 < 12:
		i3 = 0
		g = n.count(2 ** i2)
		mz = 0
		while i3 < 12 - i2:
			if g - mz + mk.count(2 ** i2) >= 2048 / 2 ** i3 / 2 ** i2:
				if g - mz + mk.count(2 ** i2) >= 1 and i2 == 11:
					ns.append('YES')
					an = 1
				else:
					mz += 2048 / 2 ** i3 / 2 ** i2
					mk.append(2048 / 2 ** i3)
			i3 += 1
		i2 += 1
	if an == 0:
		ns.append('NO')
	i += 1
print(*ns, sep='\n')


mod = 10 ** 9 + 7
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
import collections
import math
import heapq
from random import randint as rn

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

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

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

def sin():
	return input()

def inin():
	return int(input())

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

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

def main():
	t = inin()
	for _ in range(t):
		n = inin()
		l = ain()
		d = {}
		for i in l:
			if i not in d:
				d[i] = 1
			else:
				d[i] += 1
		for i in range(12):
			if 2 ** i not in d:
				d[2 ** i] = 0
			if 2 ** (i + 1) not in d:
				d[2 ** (i + 1)] = 0
			d[2 ** (i + 1)] += d[2 ** i] // 2
		if d[2048] > 0:
			print('YES')
		else:
			print('NO')
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

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

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

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

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

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


q = int(input())
for i in range(q):
	n = int(input())
	arr = list(map(int, input().split()))
	cnts = [0 for _ in range(13)]
	for i in range(13):
		for a in arr:
			if a == 1 << i:
				cnts[i] += 1
	for i in range(0, 12):
		cnts[i + 1] += cnts[i] // 2
	print('YES' if cnts[11] > 0 else 'NO')


def main():
	answer = ''
	for query in range(int(input())):
		n = int(input())
		ms = [x for x in list(map(int, input().split(' '))) if x <= 2048]
		if sum(ms) >= 2048:
			answer += 'YES \n'
		else:
			answer += 'NO \n'
	print(answer)
main()


from sys import stdin
from sys import setrecursionlimit as SRL
SRL(10 ** 7)
rd = stdin.readline
rrd = lambda : map(int, rd().strip().split())
T = int(input())
while T:
	n = int(input())
	a = list(rrd())
	tot = 0
	for i in a:
		if i <= 2048:
			tot += i
	if tot >= 2048:
		print('YES')
	else:
		print('NO')
	T -= 1


q = int(input())
for cnt in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	if 2048 in a:
		print('YES')
		continue
	if len(a) < 2:
		print('NO')
		continue
	while len(a) and a[0] < 2048:
		if len(a) < 2:
			break
		if a[0] == a[1]:
			a.pop(0)
			t = a.pop(0)
			a = [t + t] + a
		else:
			a.pop(0)
		a.sort()
	if 2048 == a[0]:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	arr = list(map(int, input().split()))
	count = 0
	for i in arr:
		if i <= 2048:
			count = count + i
	if count >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
p = {}
a = 1
for i in range(30):
	p[a] = i
	a <<= 1
for i in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	k = [0 for i in range(30)]
	for si in s:
		k[p[si]] += 1
	for i in range(p[2048]):
		k[i + 1] += k[i] // 2
	print('YES' if k[p[2048]] > 0 else 'NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print('YES' if sum(filter(lambda a: a <= 2048, a)) >= 2048 else 'NO')


import math
for q in range(int(input())):
	n = int(input())
	s = [int(math.log2(int(i))) for i in input().split()]
	if 11 in s:
		print('YES')
	elif all([s[o] > 11 for o in range(n)]):
		print('NO')
	else:
		c = 0
		for i in range(11):
			c = (s.count(i) + c) // 2
		if c >= 1:
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	int(input())
	inl = list(map(int, input().split()))
	count = 0
	for j in inl:
		if j <= 2048:
			count += j
	if count >= 2048:
		print('YES')
	else:
		print('NO')


T = int(input())
for t in range(T):
	n = int(input())
	l = list(map(int, input().split()))
	for i in range(len(l)):
		if l[i] > 2048:
			l[i] = 0
	if sum(l) >= 2048:
		print('YES')
	else:
		print('NO')


import math
N = int(input())
while N > 0:
	num_type = [0] * 12
	n = int(input())
	for i in input().split():
		k = round(math.log(int(i), 2))
		if k < 12:
			num_type[k] += 1
	for i in range(11):
		tmp = num_type[i]
		num_type[i] %= 2
		num_type[i + 1] += tmp // 2
	if num_type[11] > 0:
		print('YES')
	else:
		print('NO')
	N -= 1


t = int(input())
for case in range(t):
	n = int(input())
	a = [int(x) for x in input().split(' ') if int(x) <= 2048]
	if sum(a) >= 2048:
		ans = 'YES'
	else:
		ans = 'NO'
	print(ans)


z = int(input())
i = 0
while i < z:
	a = int(input())
	st = input()
	c = 0
	d = []
	while c < a:
		if int(st.split(' ')[c]) <= 2048:
			d.append(int(st.split(' ')[c]))
		c = c + 1
	if sum(d) >= 2048:
		print('YES')
	else:
		print('NO')
	i = i + 1


t = int(input())
cnt = 0
su = 0
r = []

def init(a):
	for p in range(len(a)):
		a[p] = int(a[p])
	return a
for i in range(t):
	su = 0
	n = int(input())
	d = input().split()
	d = init(d)
	for j in range(len(d)):
		if d[j] <= 2048:
			su = su + d[j]
	if su >= 2048:
		r.append('YES')
	else:
		r.append('NO')
for k in range(t):
	print(r[k])


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	count = Counter(ar)
	ar.sort(reverse=True)
	c = 0
	flag = False
	for i in ar:
		c += i
		if c == 2048:
			print('Yes')
			flag = True
			break
		if c > 2048:
			c -= i
	if not flag:
		print('No')


from collections import *
I = input
for _ in [0] * int(I()):
	I()
	c = Counter(map(int, input().split()))
	i = 1
	while i < 2048:
		if c[i] < 2:
			i *= 2
		else:
			c[i] -= 2
			c[i * 2] += 1
	print('NYOE S'[2048 in c::2])


import math
T = int(input())
while T > 0:
	N = int(input())
	arr = [int(x) for x in input().split()]
	freq_dict = {}
	temp = [0] * 30
	for x in arr:
		temp[int(math.log2(x))] += 1
	for i in range(11):
		temp[i + 1] = temp[i + 1] + temp[i] // 2
		temp[i] = temp[i] % 2
	if temp[11] > 0:
		print('YES')
	else:
		print('NO')
	T -= 1


def main():
	t = int(input())
	for i in range(t):
		m = int(input())
		arr = [int(i) for i in input().split()]
		arr = sorted(arr)
		new = []
		for i in range(m):
			if arr[i] > 2048:
				break
			new.append(arr[i])
		if sum(new) >= 2048:
			print('YES')
		else:
			print('NO')
main()


from math import log2
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(p) for p in input().split()]
	cntr = 0
	if 2048 in arr:
		print('yes')
		continue
	for i in range(len(arr)):
		if arr[i] < 2048:
			cntr += arr[i]
	if cntr >= 2048:
		print('yes')
	else:
		print('no')


for i in range(int(input())):
	input()
	numlist = [int(x) for x in input().split() if int(x) <= 2048]
	print('YES' if sum(numlist) >= 2048 else 'NO')


import bisect
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate

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

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

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

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

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

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

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

def string_list():
	return list(input())

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

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

def check(ans, i):
	while ans[i] == 2:
		ans[i] = 0
		i = 2 * i
		try:
			ans[i] += 1
		except KeyError:
			ans[i] = 1
	return ans

def solve():
	n = int(input())
	arr = list_input()
	ans = {}
	for i in arr:
		if i == 2048:
			print('yes')
			return
		elif i <= 1024:
			try:
				ans[i] += 1
				ans = check(ans, i)
			except KeyError:
				ans[i] = 1
	if ans == {}:
		print('no')
	else:
		try:
			t = ans[2048]
			print('yes')
		except KeyError:
			print('no')
t = int(input())
for _ in range(t):
	solve()


def query_reduce(query):
	if 2048 in query:
		return True
	while len(query) > len(set(query)):
		query.sort(reverse=True)
		if query[-1] == query[-2]:
			query[-2] *= 2
		query.pop()
		if 2048 in query:
			return True
	else:
		return False
anz_query = int(input().strip())
querys = []
for i in range(anz_query):
	input()
	querys.append([int(x) for x in input().strip().split(' ')])
for _set in querys:
	if query_reduce(_set):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = sorted([int(x) for x in input().split()])
	d = dict()
	if a[0] > 2048:
		print('NO')
	else:
		for x in a:
			if x in d:
				d[x] += 1
			else:
				d[x] = 1
		for x in [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]:
			count = 0
			if x in d:
				count = d[x] // 2
			if 2 * x in d:
				d[x + x] += count
			else:
				d[x + x] = count
		if d[2048] > 0:
			print('YES')
		else:
			print('NO')


s = int(input())
while s > 0:
	l = int(input())
	n = input()
	n = [int(i) / 2048.0 if int(i) <= 2048 else 0 for i in n.split()]
	if sum(n) >= 1:
		print('YES')
	else:
		print('NO')
	s -= 1


from math import log2

def solve(vetor):
	vetor_potencia = [0 for i in range(40)]
	for num in vetor:
		x = int(log2(num))
		vetor_potencia[x] += 1
	for i in range(1, len(vetor_potencia)):
		vetor_potencia[i] += vetor_potencia[i - 1] // 2
	if vetor_potencia[11] >= 1:
		return True
	else:
		return False
n = int(input())
for _ in range(n):
	x = int(input())
	vetor = list(map(int, input().split()))
	if solve(vetor):
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(0, q):
	N = int(input())
	S = input().split()
	su = 0
	for a in S:
		k = int(a)
		if k <= 2048:
			su = su + k
		if su >= 2048:
			print('YES')
			break
	if su < 2048:
		print('NO')


qs = int(input())
seqs = []
for i in range(qs):
	int(input())
	seqs.append([int(i) for i in input().split()])
for q in range(qs):
	s = seqs[q]
	s.sort()
	total = 2048
	i = 0
	while total > 0 and i < len(s) and (2048 not in s):
		if s.count(s[i]) > 1:
			s.pop(i)
			s[s.index(s[i])] *= 2
			s.sort()
		else:
			i += 1
	if 2048 in s:
		print('YES')
	else:
		print('NO')


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = []
	i = 0
	while len(a) != 1:
		if 2048 in a:
			break
		while i < n - 1:
			if i + 1 < n and a[i] == a[i + 1]:
				a[i] = 2 * a[i + 1]
				a[i + 1] = 0
				i += 2
			else:
				i += 1
		a.sort()
		x = a.count(0)
		a = a[x:]
		n = len(a)
		i = 0
		if 2048 in a:
			break
		if n == 1:
			break
		temp = Counter(a)
		temp = Counter(list(temp.values()))
		if temp.get(1) and temp[1] == n:
			break
	if 2048 in a:
		print('YES')
	else:
		print('NO')


from math import *
n = int(input())
for i in range(n):
	t = int(input())
	p = input().split(' ')
	l = []
	cnt = [0] * 2049
	st = []
	for j in range(t):
		if int(p[j]) <= 2048:
			l.append(int(p[j]))
			if cnt[int(p[j])] == 0:
				st.append(int(p[j]))
			cnt[int(p[j])] += 1
	l.sort()
	st.sort()
	ans = 0
	test = 1
	size = len(st)
	while test == 1 and ans == 0:
		test = 0
		for j in range(size):
			if cnt[st[j]] == 0:
				continue
			if 2048 // st[j] <= cnt[st[j]]:
				print('YES')
				ans = 1
				break
			elif int(log2(cnt[st[j]])) > 0:
				test = 1
				z = 2 ** int(log2(cnt[st[j]]))
				if cnt[st[j] * z] == 0:
					st.append(st[j] * z)
					size += 1
				cnt[st[j] * z] += 1
				cnt[st[j]] -= z
	if ans == 0:
		print('NO')


n = int(input())
for i in range(0, n):
	a = int(input())
	b = input()
	c = [int(t) for t in b.split()]
	d = 0
	for j in range(0, len(c)):
		if c[j - 1] <= 2048:
			d += c[j - 1]
			if d >= 2048:
				print('YES')
				break
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	count = 0
	for i in range(n):
		if lst[i] <= 2048:
			count += lst[i]
	if count >= 2048:
		print('YES')
	else:
		print('NO')


def game(s):
	for i in [2 ** j for j in range(12)]:
		if 2048 in s:
			print('YES')
			return
		indexes = [j for (j, x) in enumerate(s) if x == i]
		j = 0
		while 2 * j + 1 < len(indexes):
			s[indexes[2 * j]] *= 2
			s[indexes[2 * j + 1]] = 0
			j += 1
	print('NO')
q = int(input())
for i in range(int(q)):
	_ = input()
	s = list(map(int, input().split()))
	game(s)


q = int(input())
for games in range(q):
	n = int(input())
	multiset = sorted([int(x) for x in input().split()])
	lenght = len(multiset)
	while True:
		if 2048 in multiset:
			break
		for i in range(len(multiset) - 1):
			if multiset[i] == multiset[i + 1]:
				multiset[i] += multiset[i]
				del multiset[i + 1]
				multiset.sort()
				break
		if len(multiset) < lenght:
			lenght = len(multiset)
		else:
			break
	print('YES') if 2048 in multiset else print('NO')


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

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

def read_int_array():
	return [int(i) for i in input().strip().split(' ')]
for _ in range(read_int()):
	n = read_int()
	a = list(sorted(read_int_array()))
	bi = bisect_left(a, 2048)
	found = 0 <= bi < n and a[bi] == 2048
	while not found and len(a) > 1:
		n = len(a)
		i = 1
		while i < n:
			if a[i] == a[i - 1]:
				break
			i += 1
		if i == n:
			break
		x = a[i] + a[i - 1]
		if x == 2048:
			found = True
			break
		del a[i - 1]
		del a[i - 1]
		insort_left(a, x)
	print('YES' if found else 'NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	temp = 0
	for j in range(n):
		if a[j] <= 2048:
			if temp < 2048:
				temp += a[j]
	if temp == 2048:
		print('yes')
	else:
		print('no')


import math
q = int(input())
while q > 0:
	s = []
	n = int(input())
	s.append(list(map(int, input().split())))
	f = [0] * 12
	for i in range(n):
		if s[0][i] > 2 ** 11:
			continue
		f[int(math.log(s[0][i]) / math.log(2))] += 1
	for i in range(1, 12):
		f[i] += int(f[i - 1] / 2)
	if f[11] > 0:
		print('YES')
	else:
		print('NO')
	q -= 1


for i in range(int(input())):
	n = int(input())
	S = list(map(int, input().split()))
	while 2048 not in S:
		new_S = []
		for j in S:
			if j not in new_S:
				new_S.append(j)
			else:
				new_S.remove(j)
				new_S.append(2 * j)
		if len(S) == len(new_S):
			break
		S = new_S
	if 2048 in S:
		print('YES')
	else:
		print('NO')


q = int(input())
ans = []
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	length = len(a)
	a.sort()
	if a.__contains__(2048):
		ans.append('YES')
	else:
		ans_list = list(filter(lambda x: x <= 1024, a))
		if sum(ans_list) >= 2048:
			ans.append('YES')
		else:
			ans.append('NO')
for e in ans:
	print(e)


def solve():
	n = int(input())
	a = [x for x in map(int, input().split()) if x <= 2048]
	if sum(a) >= 2048:
		print('YES')
	else:
		print('NO')
t = int(input())
for _ in range(t):
	solve()


def rearrangement(a):
	out = []
	z = len(a)
	for i in range(0, z):
		d = min(a)
		out.append(d)
		a.remove(d)
	return out

def distinct(a):
	out = []
	for item in a:
		if item not in out:
			out.append(item)
	return len(out)
n = int(input())
for i in range(0, n):
	m = int(input())
	l = rearrangement([int(x) for x in input().split()])
	while 1:
		if 2048 in l:
			print('YES')
			break
		while distinct(l) < len(l):
			for j in range(1, len(l)):
				if l[j] == l[j - 1]:
					l.append(2 * l[j])
					l.remove(l[j])
					l.remove(l[j - 1])
					l = rearrangement(l)
					break
			if 2048 in l:
				print('YES')
				break
		if 2048 not in l:
			print('NO')
		break


from collections import Counter

def reduce_set(ms):
	for i in sorted(ms):
		if ms[i] > 1 and i < 2048:
			ms[i << 1] += ms[i] >> 1
			ms[i] = ms[i] & 1
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ms = Counter(arr)
	x = len(ms)
	flag = True
	while flag:
		reduce_set(ms)
		if x == len(ms):
			flag = False
		else:
			x = len(ms)
	if ms[2048]:
		print('YES')
	else:
		print('NO')


import sys
import math, bisect
sys.setrecursionlimit(10 ** 5)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
I = lambda : int(sys.stdin.readline())
neo = lambda : map(int, sys.stdin.readline().split())
Neo = lambda : list(map(int, sys.stdin.readline().split()))
for _ in range(I()):
	n = I()
	t = 2048
	A = Neo()
	k = 1
	f = 0
	while t >= 1:
		p = A.count(t)
		k -= p
		if k <= 0:
			print('YES')
			f = 1
			break
		k = 2 * k
		t = t // 2
	if not f:
		print('NO')


for itr in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c1 = a.count(1)
	c2 = a.count(2) + c1 // 2
	c4 = a.count(4) + c2 // 2
	c8 = a.count(8) + c4 // 2
	c16 = a.count(16) + c8 // 2
	c32 = a.count(32) + c16 // 2
	c64 = a.count(64) + c32 // 2
	c128 = a.count(128) + c64 // 2
	c256 = a.count(256) + c128 // 2
	c512 = a.count(512) + c256 // 2
	c1024 = a.count(1024) + c512 // 2
	c2048 = a.count(2048) + c1024 // 2
	if c2048 > 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	n = int(input())
	data = input().split()
	if '2048' in data:
		print('YES')
	else:
		set = []
		for j in range(n):
			if int(data[j]) < 2048:
				set.append(int(data[j]))
		set.sort(reverse=True)
		sum = 0
		for j in range(len(set)):
			sum += set[j]
		if sum < 2048:
			print('NO')
		else:
			while True:
				if set[0] == 2048:
					print('YES')
					break
				else:
					k = 0
					add = 0
					while k < len(set) - 1:
						if set[k] == set[k + 1]:
							set[k] = 2 * set[k]
							del set[k + 1]
							add += 1
						k += 1
					if add == 0:
						print('NO')
						break


t = int(input())
from collections import defaultdict
for _ in range(t):
	n = int(input())
	dic = defaultdict(int)
	l = list(map(int, input().split()))
	m = []
	for i in range(n):
		if l[i] <= 2048:
			dic[l[i]] += 1
	for i in range(1, 12):
		dic[2 ** i] = dic[2 ** i] + dic[2 ** (i - 1)] // 2
	if dic[2048] > 0:
		print('YES')
	else:
		print('NO')


import math
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	pow2 = [0] * 12
	for i in l:
		if int(math.log(i, 2)) < 12:
			pow2[int(math.log(i, 2))] += 1
	for i in range(len(pow2) - 1):
		if pow2[i] >= 2:
			pow2[i + 1] += pow2[i] // 2
	if pow2[-1] >= 1:
		print('YES')
	else:
		print('NO')


import sys
import math
import bisect
import itertools
import random

def main():
	for _ in range(int(input())):
		n = int(input())
		A = list(map(int, input().split()))
		ans = False
		s = set()
		for a in A:
			if a not in s:
				s.add(a)
			else:
				while a in s:
					s.remove(a)
					a = a * 2
				s.add(a)
			if 2048 in s:
				ans = True
		if ans:
			print('YES')
		else:
			print('NO')
main()


import math
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * 12
	for i in range(len(a)):
		if a[i] < 2049:
			b[round(math.log(a[i], 2))] += 1
	for i in range(len(b) - 1):
		b[i + 1] += b[i] // 2
	if b[-1] > 0:
		print('YES')
	else:
		print('NO')


def win2048(lt, num):
	if 2048 in lt:
		print('YES')
	else:
		for i in range(num):
			if lt[i] > 2048:
				lt[i] = 0
		if sum(lt) >= 2048:
			print('YES')
		else:
			print('NO')
q = int(input())
for k in range(q):
	n = int(input())
	t = [int(x) for x in input().split()]
	win2048(t, n)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	sum = 0
	for j in l:
		if j <= 2048:
			sum += j
	if sum >= 2048 or 2048 in l:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
import heapq
import cProfile, math
from collections import Counter, defaultdict, deque
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
import sys
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
fac_warm_up = False
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7

class MergeFind:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n
		self.lista = [[_] for _ in range(n)]

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		if self.size[a] < self.size[b]:
			(a, b) = (b, a)
		self.num_sets -= 1
		self.parent[b] = a
		self.size[a] += self.size[b]
		self.lista[a] += self.lista[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def prime_factors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

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

def fibonacci_modP(n, MOD):
	if n < 2:
		return 1
	return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD

def factorial_modP_Wilson(n, p):
	if p <= n:
		return 0
	res = p - 1
	for i in range(n + 1, p):
		res = res * cached_fn(InverseEuler, i, p) % p
	return res

def binary(n, digits=20):
	b = bin(n)[2:]
	b = '0' * (digits - len(b)) + b
	return b

def is_prime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def generate_primes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	return prime
factorial_modP = []

def warm_up_fac(MOD):
	global factorial_modP, fac_warm_up
	if fac_warm_up:
		return
	factorial_modP = [1 for _ in range(fac_warm_up_size + 1)]
	for i in range(2, fac_warm_up_size):
		factorial_modP[i] = factorial_modP[i - 1] * i % MOD
	fac_warm_up = True

def InverseEuler(n, MOD):
	return pow(n, MOD - 2, MOD)

def nCr(n, r, MOD):
	global fac_warm_up, factorial_modP
	if not fac_warm_up:
		warm_up_fac(MOD)
		fac_warm_up = True
	return factorial_modP[n] * (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD) % MOD) % MOD

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def display_2D_list(li):
	for i in li:
		print(i)

def prefix_sum(li):
	sm = 0
	res = []
	for i in li:
		sm += i
		res.append(sm)
	return res

def get_int():
	return int(stdin.readline().strip())

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

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result

def ncr(n, r):
	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

def binary_search(i, li):
	fn = lambda x: li[x] - x // i
	x = -1
	b = len(li)
	while b >= 1:
		while b + x < len(li) and fn(b + x) > 0:
			x += b
		b = b // 2
	return x
TestCases = True
fac_warm_up_size = 10 ** 5 + 100
optimise_for_recursion = False

def main():
	n = get_int()
	li = get_list()
	cnt = Counter(li)
	key = 1
	while key <= 2048:
		if key == 2048 and key in cnt and (cnt[key] > 0):
			print('Yes')
			return
		if key in cnt and cnt[key] > 1:
			if 2 * key not in cnt:
				cnt[2 * key] = 0
			cnt[2 * key] += cnt[key] // 2
		key = 2 * key
	print('No')
if TestCases:
	for i in range(get_int()):
		main()
else:
	main() if not optimise_for_recursion else threading.Thread(target=main).start()


q = int(input())
for _ in range(0, q):
	n = int(input())
	tab = [int(i) for i in input().split()]
	possible = False
	if 2048 in tab:
		possible = True
	elif sum([elt for elt in tab if elt < 2048]) >= 2048:
		possible = True
	print('YES' if possible else 'NO')


import math
t = int(input())
for i in range(t):
	n = int(input())
	l = [int(j) for j in input().split()]
	d = {}
	for j in l:
		k = int(math.log2(j))
		if k not in d:
			d[k] = 1
		else:
			d[k] += 1
	for j in range(0, 12):
		if j in d:
			k = int(d[j] // 2)
			if j + 1 in d:
				d[j + 1] += k
			if j + 1 not in d:
				d[j + 1] = k
	if 11 in d:
		if d[11] >= 1:
			print('YES')
		if d[11] == 0:
			print('NO')
	elif 11 not in d:
		print('NO')


q = int(input())
while q:
	size = int(input())
	l = list(map(int, input().split()))
	if 2048 in l:
		print('YES')
		q -= 1
		continue
	l = [item for item in l if item <= 1024]
	if sum(l) >= 2048:
		print('YES')
	else:
		print('NO')
	q -= 1


q = int(input())
for i in range(q):
	input()
	s = [j for j in map(int, input().split()) if j < 2049]
	if sum(s) >= 2048:
		print('YES')
	else:
		print('NO')


l = [list(map(int, input().split())) for i in range(2 * int(input()))][1::2]

def verify(x):
	x = [i for i in x[:] if i <= 2048]
	if sum(x) >= 2048:
		print('yes')
	else:
		print('no')
for i in l:
	verify(i)


q = int(input())
for i in range(q):
	n = int(input())
	x = input()
	y = x.split()
	z = [int(d) for d in y]
	for j in range(n):
		w = 1
		while w < 2048:
			c = z.count(w)
			if c % 2 == 0 and c != 0:
				for a in range(c):
					z.remove(w)
				for b in range(int(c / 2)):
					z.append(2 * w)
			elif c != 1 or c != 0:
				for a in range(c - 1):
					z.remove(w)
				for b in range(c // 2):
					z.append(2 * w)
			w = w * 2
	if 2048 in z:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	a = {}
	for i in range(12):
		a[2 ** i] = 0
	p = []
	n = int(input())
	x = [int(n) for n in input().split()]
	for i in x:
		if i <= 2048:
			p.append(i)
	for i in x:
		if i in a:
			a[i] += 1
	if a[2048] >= 1:
		print('YES')
	elif sum(p) >= 2048:
		print('YES')
	else:
		print('NO')


Q = int(input())
from heapq import *
for q in range(Q):
	n = int(input())
	a_list = list(map(int, input().split()))
	b_list = []
	found = False
	for a in a_list:
		if a == 2048:
			found = True
			break
		elif a <= 1024:
			b_list.append(a)
	if found:
		print('Yes')
		continue
	heapify(b_list)
	while len(b_list) >= 2:
		b1 = heappop(b_list)
		b2 = heappop(b_list)
		if b1 == 1024 and b2 == 1024:
			found = True
			break
		if b1 == b2:
			heappush(b_list, b1 + b2)
		elif b1 > b2:
			heappush(b_list, b1)
		else:
			heappush(b_list, b2)
	if found:
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = list(set(a))
	if 2048 in a:
		print('YES')
	elif n == len(b):
		print('NO')
	else:
		k = 0
		f = 0
		m = [a[i] for i in range(len(a))]
		m.sort()
		while k <= 10:
			r = []
			j = 0
			q = 0
			while j < len(m) - 1:
				if m[j] == m[j + 1]:
					r.append(m[j] + m[j + 1])
					j = j + 2
					q = q + 2
				else:
					r.append(m[j])
					j = j + 1
					q = q + 1
			if q < len(m):
				r.append(m[-1])
			else:
				pass
			m = r
			m.sort()
			if 2048 in m:
				f = 1
				break
			k = k + 1
		if f == 1:
			print('YES')
		else:
			print('NO')


def check(alist):
	for child in alist:
		if child == 2048:
			return 'YES'
	return 'NO'

def checksame(blist):
	i = 0
	global mylist
	while i <= len(blist) - 1:
		if check(blist) is 'YES':
			return
		ith = blist[i]
		k = i + 1
		while k <= len(blist) - 1:
			kth = blist[k]
			if ith == kth:
				blist.append(2 * ith)
				del blist[k]
				del blist[i]
				mylist = blist
				checksame(blist)
				ith = 0
			else:
				k += 1
		i += 1
numberOfQueries = int(input())
nowQueries = 1
while nowQueries <= numberOfQueries:
	nowQueries += 1
	numberOfInther = int(input())
	mylist = list(map(int, input().split()))
	checksame(mylist)
	print(check(mylist))


from collections import Counter
t = int(input())
for _ in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	c = Counter(a)
	flag = 1
	g = 2048
	if g in a:
		print('YES')
		continue
	while flag == 1:
		c = Counter(a)
		v = list(c.values())
		if max(v) < 2:
			break
		else:
			k = list(c.keys())
			for i in range(0, len(k)):
				if c[k[i]] > 1:
					a.append(2 * k[i])
					a.remove(k[i])
					a.remove(k[i])
				if g in a:
					print('YES')
					flag = 0
					break
	if flag == 1:
		if g in a:
			print('YES')
		else:
			print('NO')


q = int(input())

def add_to_counts(counts, num):
	if num not in counts:
		counts[num] = 0
	counts[num] += 1
	if num == 2048:
		return 1
	if counts[num] == 2 and num < 2048:
		counts[num] = 0
		return add_to_counts(counts, num * 2)
	return 0
for i in range(q):
	n = int(input())
	s = [int(i) for i in input().split()]
	counts = {}
	good = False
	for nn in s:
		if nn not in counts:
			counts[nn] = 0
		r = add_to_counts(counts, nn)
		if r:
			good = True
			break
	if good:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	n = int(input())
	arr = filter(lambda x: x <= 2048, map(int, input().split()))
	print('YES' if sum(arr) >= 2048 else 'NO')
	t -= 1


def try_merger(numbers, test_num):
	previous_inex = None
	for (j, num) in enumerate(numbers):
		if num == test_num:
			if previous_inex == None:
				previous_inex = j
			else:
				del numbers[j]
				del numbers[previous_inex]
				numbers.append(test_num * 2)
				return numbers
	return numbers

def game_solver(numbers):
	numbers = [num for num in numbers if num <= 2048]
	while True:
		if 2048 in numbers:
			return True
		or_size = len(numbers)
		for i in range(11):
			test_num = pow(2, i)
			numbers = try_merger(numbers, test_num)
		if len(numbers) == or_size:
			return False
q = int(input())
for _ in range(q):
	n = int(input())
	numbers = [int(num) for num in input().split(' ')]
	if game_solver(numbers):
		print('YES')
	else:
		print('NO')


a = int(input())

def ravn(mass):
	a = len(mass)
	mass = sorted(mass)
	for i in range(a - 1):
		if mass[i] == mass[i + 1] and mass[i] != 0:
			return i
	return -1
for i in range(a):
	n = int(input())
	b = []
	b = map(int, input().split())
	b = list(b)
	b = sorted(b)
	w = []
	if 2048 not in b:
		while ravn(b) != -1:
			d = ravn(b)
			b = sorted(b)
			b.append(int(b[d] + b[d + 1]))
			b = sorted(b)
			b[d] = 0
			b[d + 1] = 0
			b = sorted(b)
			if 2048 in b:
				break
		if 2048 in b:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')
	b.clear()


import math
t = int(input())
for j in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	c = 0
	aa = [0] * 11
	for i in a:
		if i == 2048:
			c = 1
			break
	if c == 1:
		print('YES')
	else:
		for i in a:
			if i < 2048:
				aa[int(math.log2(i))] = aa[int(math.log2(i))] + 1
		for i in range(0, 10):
			aa[i + 1] = aa[i + 1] + aa[i] // 2
		if aa[10] >= 2:
			print('YES')
		else:
			print('NO')


flag = False
a = int(input())
for i in range(a):
	input()
	b = list(map(int, input().split()))
	b.sort()
	flag = False
	while True:
		for i in range(len(b) - 1, -1, -1):
			if b[i] < 2048:
				break
			if b[i] == 2048:
				flag = True
				print('YES')
				break
		if flag == True:
			break
		if len(b) == 1:
			print('NO')
			break
		for i in range(len(b) - 1, 0, -1):
			if b[i] == b[i - 1]:
				b[i - 1] = b[i] + b[i - 1]
				tmp = b[0:i]
				tmp.extend(b[i + 1:len(b)])
				b = tmp
				break
			if i == 1:
				flag = True
				print('NO')
		if flag == True:
			break


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a = [x for x in a if x <= 2048]
	c = defaultdict(lambda : 0)
	for x in a:
		c[x] += 1
	brfl = False
	removal = True
	while removal:
		removal = False
		for x in sorted(c.keys()):
			while c[x] >= 2 and (not brfl):
				if c[2048] >= 1:
					brfl = True
					break
				c[x] -= 2
				c[2 * x] += 1
				removal = True
			if brfl:
				break
	if c[2048] >= 1:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	m = int(input())
	lst = [int(x) for x in input().split()]
	lst2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]
	lst3 = []
	if 2048 in lst:
		print('YES')
	else:
		for j in range(11):
			lst3.append(int(lst.count(lst2[j])))
			a = lst3[0]
		for k in range(1, 11):
			a = a // 2 + lst3[k]
		if a >= 2:
			print('YES')
		else:
			print('NO')


num = int(input())
list_num = []
list_prob = []
for i in range(0, num):
	list_num.append(input())
	list_prob.append(input())
for prob in list_prob:
	listA = prob.split(' ')
	listA = list(map(int, listA))
	while len(listA) > len(set(listA)) and 2048 not in listA:
		for num in listA:
			if listA.count(num) >= 2:
				m = 0
				listA.append(2 * num)
				for i in range(len(listA) - 1, -1, -1):
					if listA[i] == num and m < 2:
						listA.pop(i)
						m += 1
	else:
		if 2048 in listA:
			print('YES')
		else:
			print('NO')


t = int(input())
for o in range(t):
	n = int(input())
	s = 0
	l = [int(x) for x in input().split()]
	for i in range(n):
		if l[i] <= 2048:
			s += l[i]
	if s >= 2048:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	fl = 1
	an = 0
	while fl:
		if 2048 in a:
			an = 1
			break
		fl = 0
		b = []
		d = {}
		for i in a:
			d[i] = d.get(i, 0) + 1
		for i in d.keys():
			for j in range(d[i] % 2):
				b.append(i)
			for j in range(d[i] // 2):
				b.append(i * 2)
				fl = 1
		a = b[:]
	if an == 1:
		print('YES')
	else:
		print('NO')


import math
q = int(input())
for i in range(q):
	n = int(input())
	a = tuple(map(int, input().split()))
	b = [0 for j in range(13)]
	for j in a:
		if j <= 2048:
			b[int(math.log(j, 2))] += 1
	for j in range(11):
		b[j + 1] += b[j] // 2
		b[j] %= 2
	if b[11]:
		print('YES')
	else:
		print('NO')


n = int(input())
for t in range(n):
	num = int(input())
	lis = list(map(int, input().split()))
	m = 2048
	i = 2048
	while i != 0:
		if i in lis:
			m -= i
			lis.remove(i)
		else:
			i = int(i / 2)
		num -= 1
		if m == 0:
			print('YES')
			break
	if m != 0:
		print('NO')


import sys
import queue
for _ in range(int(input())):
	n = input()
	a = list(map(int, input().split()))
	b = filter(lambda x: x <= 2048, a)
	if sum(b) >= 2048:
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	mark = [0] * 2049
	for num in s:
		if num <= 2048:
			mark[num] += 1
	num = 1
	while num < 2048:
		mark[2 * num] += mark[num] // 2
		num *= 2
	if mark[2048] >= 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = map(int, input().split())
	a = set()
	f = 0
	for i in s:
		while i in a:
			a.remove(i)
			i = i * 2
		if i > 2048:
			pass
		elif i == 2048:
			f = 1
			break
		else:
			a.add(i)
	print('YES' if f else 'NO')


T = int(input())
while T > 0:
	T -= 1
	n = int(input())
	A = map(int, input().split())
	cnt = [0] * 40
	for i in A:
		pw = 0
		while i > 1:
			i //= 2
			pw += 1
		cnt[pw] += 1
	for i in range(12):
		cnt[i + 1] += cnt[i] // 2
	if cnt[11] > 0:
		print('YES')
	else:
		print('NO')


def solver():
	k = int(input())
	multi_set = [int(i) for i in input().split() if int(i) <= 2048]
	if sum(multi_set) >= 2048:
		print('YES')
	else:
		print('NO')

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


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	while len(arr) != 0:
		if any((i == 2048 for i in arr)):
			break
		if arr[0] in arr[1:]:
			k = arr[0]
			arr[0] *= 2
			arr.remove(k)
		else:
			arr.remove(arr[0])
		arr.sort()
	if any((i == 2048 for i in arr)):
		print('YES')
	else:
		print('NO')


def go():
	n = int(input())
	a = [int(x) for x in input().split()]
	a = sorted(a)
	b = {}
	for a_i in a:
		if a_i not in b:
			b[a_i] = 0
		b[a_i] += 1
	d = 1
	for i in range(12):
		if i != 0:
			if d not in b:
				b[d] = 0
			b[d] += b.get(d // 2, 0) // 2
		d *= 2
	return b.get(2048, 0) > 0
q = int(input())
for _ in range(q):
	if go():
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	pw = [0] * 200
	for i in l:
		cp = 0
		x = i
		while x % 2 == 0:
			x //= 2
			cp += 1
		pw[cp] += 1
	for p in range(11):
		pw[p + 1] += pw[p] // 2
	print('YES' if pw[11] else 'NO')


for _ in range(int(input())):
	input()
	arr = list(map(int, input().split()))
	for i in range(len(arr)):
		if arr[i] > 2048:
			arr[i] = 0
	if sum(arr) >= 2048:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	s = [x for x in s[:] if x <= 2048]
	ans = 2048
	for i in s[::-1]:
		ans -= i
		if ans == 0:
			print('yes')
			break
		if ans < 0:
			print('no')
			break
	else:
		print('no')


R = lambda : map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in R() if i <= 2048]
	print('YES' if sum(a) >= 2048 else 'NO')


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	m = [int(i) for i in input().split()]
	m = sorted(m)
	MIN_M = min(m)
	i = 0
	while len(set(m)) < len(m):
		if m[i] == m[i + 1] and m[i] != 2048:
			MIN_M = m[i]
			m.remove(m[i])
			m.remove(m[i])
			m.append(MIN_M + MIN_M)
			i = 0
		else:
			i += 1
			if i == len(m) - 1:
				break
		m = sorted(m)
	for i in range(len(m)):
		if m[i] == 2048:
			MIN_M = 2048
			break
	if MIN_M == 2048:
		ans.append('YES')
	else:
		ans.append('NO')
for i in range(t):
	print(ans[i])


def f(i):
	(n, s) = i
	req = True
	while req == True:
		if 2048 in s:
			return 'YES'
		mili = False
		for j in s:
			if s.count(j) >= 2:
				mili = True
				s.append(j * 2)
				s.remove(j)
				s.remove(j)
				break
		if mili == False:
			return 'NO'
		else:
			continue
l = []
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	l.append((n, s))
ans = [f(i) for i in l]
for i in ans:
	print(i)


q = int(input())
for i in range(q):
	n = int(input())
	i = 0
	a = list(map(int, input().split()))
	while i < len(a):
		if a[i] > 2048:
			del a[i]
		else:
			i += 1
	if sum(a) >= 2048:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	p2 = [0] * 13
	for d in lst:
		dpow = 0
		while d > 0:
			dpow += 1
			d //= 2
		if dpow <= 12:
			p2[dpow] += 1
	for i in range(12):
		p2[i + 1] += p2[i] // 2
	print('YES' if p2[12] > 0 else 'NO')


q = int(input())
while q > 0:
	q = q - 1
	n = int(input())
	line = input()
	arr = line.split(' ')
	sum = 0
	for x in arr:
		if int(x) <= 1 << 11:
			sum = sum + int(x)
	if sum >= 1 << 11:
		print('YES')
	else:
		print('NO')


j = 0
sn = list()
ps = 0
q = int(input())
nos = list()
for i in range(q):
	nos.append(int(input()))
	sn.append([int(a) for a in input().split()][:nos[i]])
for i in range(q):
	ps = 0
	sn1 = sn[i]
	nos1 = nos[i]
	sn1.sort()
	c = 0
	n_list = list()
	if 2048 in sn1:
		print('YES')
		ps = 1
	if ps == 0:
		j = 0
		while j < nos1 - 1:
			if j + 1 < len(sn1):
				if sn1[j] == sn1[j + 1]:
					sm = 2 * sn1[j]
					sn1.pop(j)
					sn1.pop(j)
					sn1.insert(j, sm)
					sn1.sort()
					j += -1
					if sm == 2048:
						print('YES')
						c = 1
						break
			j += 1
		if max(sn1) != 2048 and c == 0:
			print('NO')


t = int(input())
while t > 0:
	n = int(input())
	s = list(map(int, input().strip().split()))
	t -= 1
	sum = 0
	for i in range(len(s)):
		if s[i] <= 2048:
			sum += s[i]
	if sum >= 2048:
		print('YES')
	else:
		print('NO')


import sys
r = lambda : sys.stdin.readline().rstrip()
T = int(r())
while T:
	n = int(r())
	L = list(map(int, r().split()))
	s = 0
	flag = False
	for x in L:
		if x > 2048:
			continue
		else:
			s += x
			if s >= 2048:
				flag = True
	if flag:
		print('YES')
	else:
		print('NO')
	T -= 1


n = int(input())
mass = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
for i in range(20):
	mass += [mass[-1] * 2]
for s in range(n):
	k = int(input())
	l = list(map(int, input().split()))
	l.sort()
	mass2 = [0 for i in range(100)]
	for i2 in range(k):
		mass2[mass.index(l[i2])] += 1
	r = 0
	for i3 in range(len(mass2) - 1):
		mass2[i3 + 1] += mass2[i3] // 2
		if mass2[11] != 0:
			print('YES')
			r = 1
			break
	if r == 0:
		print('NO')


q = int(input())
for _ in range(q):
	n = int(input())
	c = list(map(int, input().split()))
	dic = {1: 0, 2: 0, 4: 0, 8: 0, 16: 0, 32: 0, 64: 0, 128: 0, 256: 0, 512: 0, 1024: 0, 2048: 0}
	for num in c:
		if num in dic:
			dic[num] += 1
	if dic[2048] > 0:
		print('YES')
		continue
	x = 1
	while x <= 1024:
		add = dic[x] // 2
		x *= 2
		dic[x] += add
	if dic[2048] > 0:
		print('YES')
	else:
		print('NO')


for _ in '0' * int(input()):
	input()
	ls = list(map(int, input().split()))
	print('YNEOS'[sum(list(filter(lambda x: x <= 2048, ls))) < 2048::2])


t = int(input())
for i in range(t):
	n = input()
	L = [int(x) for x in input().split() if int(x) <= 2048]
	print('YES' if sum(L) >= 2048 else 'NO')


q = int(input())

def solve(numbers):
	numbers = sorted([n for n in numbers if n <= 2048])
	while True:
		if 2048 in numbers:
			return True
		uniq = set(numbers)
		if len(uniq) == len(numbers):
			return False
		next_numbers = []
		for n in uniq:
			count = len([x for x in numbers if x == n])
			next_numbers += [n * 2] * (count // 2) + [n] * (count % 2)
		numbers = next_numbers
for _ in range(q):
	n = int(input())
	numbers = [int(x) for x in input().split(' ')]
	if solve(numbers):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	input()
	a = list(map(int, input().split()))
	for j in range(len(a)):
		if a[j] > 2048:
			a[j] = 0
	print('YES' if sum(a) >= 2048 else 'NO')


def find_pow(n):
	x = 0
	while n > 0:
		n = n // 2
		x += 1
	return x - 1
q = int(input())
while q > 0:
	n = int(input())
	arr = map(int, input().split())
	f = list()
	for i in range(30):
		f.append(0)
	for ele in arr:
		t = find_pow(ele)
		f[t] += 1
	i = 0
	while i < 11:
		f[i + 1] += f[i] // 2
		i += 1
	if f[11] > 0:
		print('YES')
	else:
		print('NO')
	q -= 1


def value():
	return int(input())

def li():
	return [int(_______) for _______ in input().split()]
from collections import *
for _ in range(int(input())):
	q = value()
	a = li()
	ans = []
	for i in a:
		if i <= 2048:
			ans.append(i)
	a = ans
	if sum(a) >= 2048:
		print('YES')
	else:
		print('NO')


import math
q = int(input())
ans = []
for i in range(q):
	n = int(input())
	nums = list(map(int, input().strip().split()))
	a = []
	for x in nums:
		if x <= 2048:
			a.append(x)
	if len(a) == 0:
		ans.append('NO')
		continue
	if max(a) == 2048:
		ans.append('YES')
		continue
	y = a.count(1)
	for j in range(y):
		a.remove(1)
	for j in range(y // 2):
		a.append(2)
	if len(a) == 1:
		ans.append('NO')
		continue
	b = [int(math.log(x, 2)) for x in a]
	flag = True
	while len(b) > 1:
		D = min(b)
		I = D + 1
		y = b.count(D)
		for j in range(y):
			b.remove(D)
		for j in range(y // 2):
			b.append(I)
		if max(b) == 11:
			ans.append('YES')
			flag = False
			break
	if flag:
		ans.append('NO')
print('\n'.join(ans))


q = int(input())
for i in range(q):
	n = int(input())
	a = list(map(int, input().split()))
	new = sum((i for i in a if i <= 2048))
	if new >= 2048:
		print('YES')
	else:
		print('NO')


for k in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	hsh = [0] * 2049
	for i in range(n):
		if a[i] < 2049:
			hsh[a[i]] += 1
	for i in range(1, 12):
		hsh[int(2 ** i)] += hsh[int(2 ** (i - 1))] // 2
	if hsh[2048]:
		print('Yes')
	else:
		print('No')