Luntik came out for a morning stroll and found an array $a$ of length $n$. He calculated the sum $s$ of the elements of the array ($s= \sum_{i=1}^{n} a_i$). Luntik calls a subsequence of the array $a$ nearly full if the sum of the numbers in that subsequence is equal to $s-1$.

Luntik really wants to know the number of nearly full subsequences of the array $a$. But he needs to come home so he asks you to solve that problem!

A sequence $x$ is a subsequence of a sequence $y$ if $x$ can be obtained from $y$ by deletion of several (possibly, zero or all) elements.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases. The next $2 \cdot t$ lines contain descriptions of test cases. The description of each test case consists of two lines.

The first line of each test case contains a single integer $n$ ($1 \le n \le 60$) — the length of the array.

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le 10^9$) — the elements of the array $a$.


-----Output-----

For each test case print the number of nearly full subsequences of the array.


-----Examples-----

Input
5
5
1 2 3 4 5
2
1000 1000
2
1 0
5
3 0 2 1 1
5
2 1 0 3 0
Output
1
0
2
4
4


-----Note-----

In the first test case, $s=1+2+3+4+5=15$, only $(2,3,4,5)$ is a nearly full subsequence among all subsequences, the sum in it is equal to $2+3+4+5=14=15-1$.

In the second test case, there are no nearly full subsequences.

In the third test case, $s=1+0=1$, the nearly full subsequences are $(0)$ and $()$ (the sum of an empty subsequence is $0$).

Source: codeforces | Difficulty: EASY
Tags: Combinatorics

Mathematics


Solutions:
import math
case = int(input())
for i in range(case):
	n = int(input())
	ll = list(input().split())
	(zero, one) = (ll.count('0'), ll.count('1'))
	print(2 ** zero * one)


for _ in range(0, int(input())):
	n = int(input())
	v = input().split()
	o = v.count('1')
	z = v.count('0')
	print(2 ** z * o)


t = int(input())
for i in range(0, t):
	n = int(input())
	a = input().split()
	l1 = []
	for j in a:
		l1.append(int(j))
	a1 = l1.count(0)
	a2 = l1.count(1)
	print(pow(2, a1) * a2)


t = int(input())
for i in range(t):
	n = int(input())
	m = input().split()
	a = m.count('0')
	b = m.count('1')
	print(2 ** a * b)


from math import factorial
t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	k = 0
	cnt = A.count(0)
	for j in range(1, cnt + 1):
		k += factorial(cnt) // (factorial(j) * factorial(cnt - j))
	if k == 0:
		print(A.count(1))
	else:
		print(A.count(1) * (k + 1))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	x = a.count(1)
	y = a.count(0)
	print(x * 2 ** y, '\n')


n = int(input())
for i in range(n):
	line = input().split()
	line = input().split()
	a = 0
	b = 0
	for c in line:
		if c == '0':
			a += 1
		if c == '1':
			b += 1
	print(2 ** a * b)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	n0 = 0
	n1 = 0
	for ele in a:
		if ele == 1:
			n1 += 1
		elif ele == 0:
			n0 += 1
	if n1 == 0:
		print(0)
	else:
		print(n1 * int(pow(2, n0)))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	o = a.count(1)
	z = a.count(0)
	if z > 0:
		print(int(pow(2, z)) * o)
	else:
		print(o)


def fatorial(n):
	aux = n
	result = 1
	if n == 0:
		return 1
	while aux > 0:
		result = result * aux
		aux = aux - 1
	return result
test = int(input())
for i in range(0, test):
	n = int(input())
	array = list(map(int, input().split()[:n]))
	ones = 0
	zeros = 0
	for k in array:
		if k == 1:
			ones = ones + 1
		elif k == 0:
			zeros = zeros + 1
	if ones < 1:
		print(0)
	else:
		comb = ones
		if zeros > 0:
			comb = comb * 2 ** zeros
		print(int(comb))


import math
from collections import defaultdict
for cases in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	cnt1 = l.count(1)
	cnt0 = l.count(0)
	ans = cnt1 * 2 ** cnt0
	print(ans)


for _ in range(int(input())):
	input()
	arr = list(map(int, input().split()))
	null = 1
	tt = 0
	for i in arr:
		if i == 0:
			null *= 2
		if i == 1:
			tt += 1
	print(null * tt)


import math
t = int(input())
for tc in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	o = arr.count(1)
	z = arr.count(0)
	print(o * 2 ** z)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	ones = 0
	zero = 0
	for i in arr:
		if i == 1:
			ones += 1
		elif i == 0:
			zero += 1
	print(2 ** zero * ones)


t = int(input())
while t:
	n = int(input())
	a = input().split()
	cnt = a.count('1')
	cnt2 = 2 ** a.count('0')
	print(cnt * cnt2)
	t = t - 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(c0, c1) = (a.count(0), a.count(1))
	print(2 ** c0 * c1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	(z, e) = (a.count(0), a.count(1))
	print(2 ** z * e)


import sys
l = sys.stdin.readlines()
l = l[2:]

def full(arr):
	ones = 0
	zeros = 0
	for x in arr:
		if x == 1:
			ones += 1
		if x == 0:
			zeros += 1
	return ones * 2 ** zeros
for x in l[::2]:
	print(full([int(x) for x in x.split()]))


for i in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	if n == 2 and sum(arr) == 1:
		print(2)
	elif 1 in arr:
		print(arr.count(1) * 2 ** arr.count(0))
	else:
		print(0)


from math import *
from collections import *
from itertools import *
from functools import *
from bisect import *
from heapq import *
from operator import *
from sys import *
setrecursionlimit(100000000)
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = l.count(1) * 2 ** l.count(0)
	print(ans)


def print_luntik_and_subsequences():
	input()
	arr = input().split()
	cnt0 = cnt1 = 0
	for element in arr:
		if element == '0':
			cnt0 += 1
		elif element == '1':
			cnt1 += 1
	print(str(cnt1 * 2 ** cnt0))
num_test = int(input())
for _ in range(num_test):
	print_luntik_and_subsequences()


import sys
from functools import lru_cache
from collections import defaultdict, deque
from types import GeneratorType
input = sys.stdin.readline

def arithm(n):
	return (n + 1) * n // 2

def solve(a):
	num_ones = sum((num == 1 for num in a))
	num_zeros = sum((num == 0 for num in a))
	return num_ones * 2 ** num_zeros
t = int(input())
for _ in range(t):
	_ = input()
	a = [int(val) for val in input().split()]
	print(solve(a))


import sys
import bisect
input = sys.stdin.readline

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	(zeros, ones) = (a.count(0), a.count(1))
	print(ones * 2 ** zeros)
t = int(input())
for _ in range(t):
	solve()


from math import comb

def main():
	import sys
	input = sys.stdin.readline
	M = int(1000000000.0 + 7)
	for _ in range(int(input())):
		n = int(input())
		l = list(map(int, input().split()))
		o = l.count(1)
		z = l.count(0)
		s = 1
		if o > 0:
			for i in range(z):
				s += comb(z, i + 1)
			s *= o
			print(s)
		else:
			print(0)
main()


t = int(input())
for T in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	(one, zero) = (a.count(1), a.count(0))
	ans = one + (pow(2, zero) - 1) * one
	print(ans)


t = int(input())
for i in range(t):
	a = int(input())
	x = list(map(int, input().split()))
	r = x.count(1) * 2 ** x.count(0)
	print(r)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	if a.count(1) == 0:
		print(0)
	else:
		k = a.count(1)
		if a.count(0) > 0:
			k *= 2 ** a.count(0)
		print(k)


import sys

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

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

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

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

def C(n, k, mod):
	return FACT(n, mod) * pow(FACT(k, mod) * FACT(n - k, mod) % mod, mod - 2, mod) % mod

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)
for _ in range(II()):
	n = II()
	a = LI()
	one = a.count(1)
	zer = a.count(0)
	print(2 ** zer * one)


import sys, math
input = sys.stdin.readline
INF = int(1000000000.0) + 7

def solve():
	n = int(input())
	data = list(map(int, input().split()))
	z = data.count(0)
	o = data.count(1)
	print(o * pow(2, z))
t = int(input())
while t:
	t -= 1
	solve()


m = int(input())

def solve():
	n = int(input())
	arr = list(map(int, input().split(' ')))
	(o, z) = (0, 0)
	for i in arr:
		if i == 0:
			z += 1
		if i == 1:
			o += 1
	return o * 2 ** z
for i in range(m):
	print(solve())


from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = l.count(1)
	b = l.count(0)
	ans = 0
	if a == 0:
		ans = 0
	elif b == 0:
		ans = a
	else:
		ans = 2 ** b * a
	print(ans)


n = int(input())
for i in range(n):
	length = int(input())
	numbers = list(map(int, input().split()[:length]))
	print(numbers.count(1) * 2 ** numbers.count(0))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	zero = 0
	one = 0
	for i in arr:
		if i == 1:
			one += 1
		elif i == 0:
			zero += 1
	print(pow(2, zero) * one)


n = int(input())
a = []
for i in range(n):
	n1 = int(input())
	arr = list(map(int, input().split()))
	b = sum(arr)
	c = arr.count(1)
	d = arr.count(0)
	if sum == 1 and c > 0 and (d > 0):
		a.append(1)
	elif sum != 1 and c > 0 and (d > 0):
		a.append(c * 2 ** d)
	elif sum != 1 and c > 0 and (d == 0):
		a.append(c)
	elif c == 0:
		a.append(0)
for i in range(n):
	print(a[i])


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ones = l.count(1)
	zeros = l.count(0)
	print(ones * 2 ** zeros)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	cnt0 = 0
	cnt1 = 0
	for x in a:
		if x == 1:
			cnt1 += 1
		elif x == 0:
			cnt0 += 1
	print(cnt1 * (1 << cnt0))


def luntik(array):
	zeroes = array.count(0)
	ones = array.count(1)
	return ones * 2 ** zeroes
for i in range(int(input())):
	input()
	array = list(map(int, input().split()))
	print(luntik(array))


def main():
	for t in range(int(input())):
		n = int(input())
		arr = list(map(int, input().split()))
		zeros = arr.count(0)
		ones = arr.count(1)
		print(2 ** zeros * ones)
main()


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	count1 = arr.count(1)
	count0 = arr.count(0)
	if count1 == 0:
		print(0)
	else:
		print(2 ** count0 * count1)


import math

def solve(a, n):
	a1 = a.count(1)
	a2 = a.count(0)
	a2 = int(math.pow(2, a2))
	if a1 == 0 and a2 == 0 or a1 == 0:
		print('0')
		return
	elif a1 > 0 and a2 == 0:
		print(a1)
	elif a2 > 0 and a1 > 0:
		print(a1 * a2)
t = int(input(''))
for i in range(t):
	n = int(input(''))
	a = list(map(int, input('').strip().split()))[:n]
	solve(a, n)


for t in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	c1 = l.count(1)
	c0 = l.count(0)
	if c0 > 0:
		ans = 2 ** c0
		print(ans * c1)
	else:
		print(c1)


t = int(input(''))
for i in range(t):
	n = int(input(''))
	l = list(map(int, input('').split()))
	z = l.count(0)
	o = l.count(1)
	print(2 ** z * o)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	while len(arr) == n:
		zeroes = 0
		ones = 0
		for a in arr:
			if a == 1:
				ones += 1
			if a == 0:
				zeroes += 1
		ans = ones + ones * (2 ** zeroes - 1)
		print(ans)
		break
	else:
		print('wrong input')


import math

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

def stringlsit():
	return input().split(' ')

def solve():
	n = int(input())
	a = intlist()
	ones = a.count(1)
	zeros = a.count(0)
	return ones * 2 ** zeros
t = input()
for tt in range(int(t)):
	print(solve())


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	m = input().split()
	if bool(m.count('0')):
		ans.append(2 ** m.count('0') * m.count('1'))
	else:
		ans.append(m.count('1'))
for i in range(len(ans)):
	print(ans[i])


from math import ceil
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c0 = a.count(0)
	c1 = a.count(1)
	print(2 ** c0 * c1)


for _ in range(int(input())):
	n = int(input())
	lst = [*map(int, input().split())]
	ones = lst.count(1)
	zeros = lst.count(0)
	res = 0
	if zeros == 0:
		res = ones
	else:
		res = ones * 2 ** zeros
	print(res)


from sys import stdin
t = int(stdin.readline())
for i in range(t):
	n = int(stdin.readline())
	nums = list(map(int, stdin.readline().split()))
	zero = nums.count(0)
	one = nums.count(1)
	print(2 ** zero * one)


for _ in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	f = b.count(1)
	r = b.count(0)
	if r == 0:
		print(f)
	elif f == 0:
		print(0)
	else:
		print(f * 2 ** r if r < f else f * 2 ** r)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = l.count(1)
	e = l.count(0)
	print(d * 2 ** e)


from collections import Counter
import math
import bisect
from sys import stdin, stdout
input = stdin.readline
mod = 10 ** 9 + 7

def inp():
	return map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	a = list(inp())
	d = Counter(a)
	p = d.get(1, 0)
	q = d.get(0, 0)
	print(p * 2 ** q)


for i in range(int(input())):
	n = int(input())
	a = input().split()
	print(a.count('1') * 2 ** a.count('0'))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	n1 = l.count(0)
	m = l.count(1)

	def power(x, n):
		res = 1
		while n > 0:
			if n % 2 == 0:
				n = n // 2
				x = x * x
			else:
				n = n - 1
				res = res * x
		return res
	a = power(2, n1)
	print(a * m)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	print(a.count(1) * 2 ** a.count(0))
t = int(input())
for i in range(t):
	solve()


N = int(input())
for i in range(N):
	n = int(input())
	mas = list(map(int, input().split()))
	dick = {0: 0, 1: 0}
	for x in mas:
		if x in dick:
			dick[x] += 1
	print(dick[1] * 2 ** dick[0])


from os import path, truncate
from sys import int_info, stdin, stdout
if path.exists('tc.txt'):
	stdin = open('tc.txt', 'r')

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

def gms():
	return map(str, stdin.readline().strip().split())

def gari():
	return list(map(int, stdin.readline().strip().split()))

def gart():
	return tuple(map(int, stdin.readline().strip().split()))

def gars():
	return list(map(str, stdin.readline().strip().split()))

def gs():
	return stdin.readline().strip()

def gls():
	return list(stdin.readline().strip())

def gi():
	return int(stdin.readline())
for _ in range(int(input())):
	n = map(int, input())
	l = list(map(int, input().split()))
	n0 = l.count(0)
	n1 = l.count(1)
	if n1 == 0:
		print(0)
	else:
		print(2 ** n0 * n1)


from math import factorial
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	one = arr.count(1)
	zero = arr.count(0)
	temp = 2 ** zero * one
	print(temp)


t = int(input())
for q in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	j = arr.count(0)
	o = arr.count(1)
	if o == 0:
		print(0)
	else:
		print(o * 2 ** j)


test = int(input())
for i in range(test):
	n = int(input())
	arr = [int(ele) for ele in input().split()]
	ones = 0
	zeros = 0
	for ele in arr:
		if ele == 0:
			zeros += 1
		if ele == 1:
			ones += 1
	print(ones * 2 ** zeros)


for u in range(int(input())):
	n = int(input())
	x = [int(w) for w in input().split()]
	a = x.count(0)
	b = x.count(1)
	ans = 2 ** a * b
	print(ans)


T = int(input())
for t in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	count0 = count1 = 0
	total = 0
	if 1 in a:
		for num in a:
			if num == 0:
				count0 += 1
			elif num == 1:
				count1 += 1
		if count1 == 1:
			total += 2 ** count0 - 1
			print(total + 1)
		else:
			total += count1 * (2 ** count0 - 1)
			print(total + count1)
	else:
		print(0)


a = int(input())
for i in range(a):
	c = int(input())
	b = [int(x) for x in input().split()]
	count = 0
	mark = 0
	for j in range(len(b)):
		if b[j] == 1:
			count = count + 1
		if b[j] == 0:
			mark = mark + 1
	c = pow(2, mark)
	d = count * c
	print(d)


for _ in range(int(input())):
	input()
	a = input().split()
	print(a.count('1') << a.count('0'))


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	print(a.count(1) * pow(2, a.count(0)))


from collections import Counter
for i in range(int(input())):
	c = int(input())
	d = list(input().split())
	x = Counter(d)
	zero = x['0'] if x['0'] else 0
	one = x['1'] if x['1'] else 0
	if not zero:
		print(one)
	else:
		print(2 ** zero * one)


t = int(input().strip())
for _ in range(t):
	n = input()
	a = [int(i) for i in input().strip().split()]
	zeros = 0
	ones = 0
	for i in a:
		if i == 1:
			ones += 1
		elif i == 0:
			zeros += 1
	print(ones * 2 ** zeros)


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for t in range(int(input())):
	n = int(input())
	(c0, c1) = (0, 0)
	num = list(map(int, input().split()))
	for i in num:
		if i == 1:
			c1 += 1
		elif i == 0:
			c0 += 1
	print(c1 * 2 ** c0)


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

def solve():
	(n,) = read_nums()
	elems = read_nums()
	zeros = elems.count(0)
	ones = elems.count(1)
	print(ones * 2 ** zeros)

def main():
	(t,) = read_nums()
	for _ in range(t):
		solve()
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x1 = a.count(1)
	x0 = a.count(0)
	print(2 ** x0 * x1)


t = int(input())
g = []
for i in range(t):
	n = int(input())
	mass = input().split(' ')
	if mass.count('1') > 0:
		g.append(2 ** mass.count('0') * mass.count('1'))
	else:
		g.append('0')
print(*g, sep='\n')


t = int(input())
answer = []
for a in range(t):
	n = int(input())
	lst = list(map(lambda x: int(x), input().split()))
	c0 = lst.count(0)
	c1 = lst.count(1)
	answer.append(2 ** c0 * c1)
print('\n'.join([str(i) for i in answer]))


x = int(input())
for i in range(x):
	n = int(input())
	a = list(map(int, input().strip().split()))[:n]
	ones = 0
	zeros = 0
	for j in range(n):
		if a[j] == 1:
			ones += 1
		if a[j] == 0:
			zeros += 1
	if ones >= 1:
		if zeros > 1:
			print(2 ** zeros * ones)
		elif zeros == 1:
			print(ones * 2)
		else:
			print(ones)
	else:
		print(0)


cases = int(input())
for _ in range(cases):
	num = int(input())
	arr = list(map(int, input().split()))
	ans = arr.count(1) * 2 ** arr.count(0)
	print(ans)


import sys
from math import factorial, gcd
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify, nlargest, nsmallest
from itertools import groupby, accumulate
from copy import deepcopy
MOD = 10 ** 9 + 7
INF = float('inf')
input = sys.stdin.readline
rl = lambda : list(map(int, input().split()))
rs = lambda : sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	A = rl()
	total = sum(A)
	c = A.count(1)
	if c == 0:
		print(0)
	else:
		x = A.count(0)
		if total == 1 or c == 1:
			print(2 ** x)
		elif x == 0:
			print(c)
		else:
			print(2 ** x * c)


from sys import stdin, stdout
t = int(stdin.readline().strip())
for _ in range(t):
	n = int(stdin.readline().strip())
	arr = list(map(int, stdin.readline().strip().split()))
	c1 = arr.count(1)
	c0 = arr.count(0)
	if c0 > 0 and c1:
		print(pow(2, c0) * c1)
	else:
		print(c1)


from collections import Counter
import string
import math
import bisect
import sys
from fractions import Fraction

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(arrber_of_variables):
	if arrber_of_variables == 1:
		return int(sys.stdin.readline())
	if arrber_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
testcases = vary(1)
for _ in range(testcases):
	n = vary(1)
	arr = array_int()
	pt = arr.count(1)
	st = arr.count(0)
	if pt > 0:
		if st == 0:
			print(pt)
		else:
			print(pt * 2 ** st)
	else:
		print(0)


t = int(input())

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	zeros = 0
	ans = 0
	calc = False
	add = 0
	for a in arr:
		if a == 0:
			zeros += 1
		elif a == 1:
			if not calc:
				calc = True
				add = 1 << zeros
			ans += add
		else:
			break
	print(ans)
for _ in range(t):
	solve()


T = int(input())
for t in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	(one, zero) = (0, 0)
	for i in range(n):
		one += arr[i] == 1
		zero += arr[i] == 0
	s = 0
	for i in range(one):
		s += 2 ** zero
	print(s)


t = int(input())
for i in range(t):
	n = int(input())
	a = []
	nulls = 0
	ones = 0
	st = input().split()
	for j in range(n):
		q = int(st[j])
		if q == 0:
			nulls += 1
		if q == 1:
			ones += 1
	z = 2 ** nulls * ones
	print(z)


for s in [*open(0)][2::2]:
	f = s.split().count
	print(f('1') << f('0'))


t = int(input())
for t_i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	zer = a.count(0)
	one = a.count(1)
	print(2 ** zer * one)


for s in [*open(0)][2::2]:
	a = s.split()
	print(a.count('1') << a.count('0'))


def f(arr, n, s):
	if n == 0 and s > 0:
		return 0
	if s == 0:
		return 1
	if arr[n - 1] <= s:
		return f(arr, n - 1, arr[n - 1]) + f(arr, n - 1, s)
	else:
		return f(arr, n - 1, s)
t = int(input(''))
for _ in range(t):
	n = int(input(''))
	arr = list(map(int, input('').split(' ')))
	total = sum(arr)
	zeroes = arr.count(0)
	ans = 0
	for i in arr:
		if i == 1:
			ans += 2 ** zeroes
	print(ans)


for tc in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	cnts = [0, 0]
	for num in a:
		if num == 0 or num == 1:
			cnts[num] += 1
	print(cnts[1] * 2 ** cnts[0])


import math
import os
import sys
from io import BytesIO, IOBase
M = 1000000007
import random
import heapq
import threading
import bisect
import time
from functools import *
from collections import *
from itertools import *
BUFSIZE = 8192
import array

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

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

def out(var):
	sys.stdout.write(str(var))

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

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())

def build(arr, a, b, st, node):
	if a == b:
		st[node] = arr[a]
		return st[node]
	mid = (a + b) // 2
	st[node] = min(build(arr, a, mid, st, 2 * node + 1), build(arr, mid + 1, b, st, 2 * node + 2))
	return st[node]

def getmin(arr, a, b, l, r, st, node):
	if l > b or r < a:
		return float('inf')
	if l <= a and r >= b:
		return st[node]
	mid = (a + b) // 2
	return min(getmin(arr, a, mid, l, r, st, 2 * node + 1), getmin(arr, mid + 1, b, l, r, st, 2 * node + 2))

def chck(x, y, z):
	if abs(x[0] * (y[1] - z[1]) + y[0] * (z[1] - x[1]) + z[0] * (x[1] - y[1])) > 0:
		return True
	return False

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		n = inpu()
		arr = lis()
		if arr.count(1) == 0:
			print(0)
			continue
		one = arr.count(1)
		zero = arr.count(0)
		c = zero
		print(2 ** c * one)
main()


t = int(input())
for i in range(0, t):
	d = int(input())
	a = list(map(int, input().split()))
	c = sum(a)
	d = []
	count = 0
	num = 0
	for ele in a:
		if ele == 1:
			count = count + 1
		elif ele == 0:
			num = num + 1
	if count == 1 and num == 0:
		print(1)
	elif count == 1 and num > 0:
		print(pow(2, num))
	elif count > 1:
		print(count * pow(2, num))
	else:
		print(0)


for _ in range(int(input())):
	n = int(input())
	arr = [int(item) for item in input().split()]
	ones = 0
	zeros = 0
	for i in range(n):
		if arr[i] == 1:
			ones += 1
		if arr[i] == 0:
			zeros += 1
	subsequences_formed = (2 ** zeros - 1) * ones
	print(ones + subsequences_formed)


for _ in range(int(input())):
	n = int(input())
	ai = list(map(int, input().split()))
	ctz = ai.count(0)
	cto = ai.count(1)
	print(pow(2, ctz) * cto)


def C(n, k):
	if k == n or k == 0:
		return 1
	if k != 1:
		return C(n - 1, k) + C(n - 1, k - 1)
	else:
		return n
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	cnk = 1
	n0 = a.count(0)
	n1 = a.count(1)
	if n0 == 0:
		cnk = 0
	for j in range(1, n0):
		cnk = cnk * 2 + 1
	ans = n1 + n1 * cnk
	print(ans)


import sys
import string
from decimal import Decimal
from math import log

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

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

def inpstrlist():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
t = int(input())
for _ in range(t):
	n = inp()
	arr = inplist()
	one = arr.count(1)
	zero = arr.count(0)
	x = 2 ** zero
	x = x * one
	print(x)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	one = l.count(1)
	zero = l.count(0)
	print(one * 2 ** zero)


import io, os
import sys
from sys import stdin
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, namedtuple
from math import gcd, ceil, floor, factorial
from itertools import combinations, permutations
input = sys.stdin.buffer.readline

def init(n):
	comb = [[0] * n for _ in range(n)]
	for i in range(n):
		for j in range(i + 1):
			if j == 0:
				comb[i][j] = 1
			else:
				comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1]
	return comb

def work(n, a, comb):
	ans = 0
	zero = one = 0
	for i in a:
		if i == 0:
			zero += 1
		if i == 1:
			one += 1
	ans = comb[one][1] * pow(2, zero)
	return ans

def main():
	test = int(input())
	comb = init(70)
	for idt in range(test):
		n = int(input())
		a = list(map(int, input().split()))
		ans = work(n, a, comb)
		print(ans)
	return
main()


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')
from itertools import permutations
from collections import *
from collections import deque
from operator import itemgetter, attrgetter
from decimal import *
import bisect
import math
import heapq as hq
MOD = 10 ** 9 + 7

def is_prime(n):
	if n == 2 or n == 3:
		return True
	if n < 2 or n % 2 == 0:
		return False
	if n < 9:
		return True
	if n % 3 == 0:
		return False
	r = int(n ** 0.5)
	f = 5
	while f <= r:
		if n % f == 0:
			return False
		if n % (f + 2) == 0:
			return False
		f += 6
	return True

def pow(a, b, m):
	ans = 1
	while b:
		if b & 1:
			ans = ans * a % m
		b //= 2
		a = a * a % m
	return ans

def ispalindrome(s):
	if s[:] == s[::-1]:
		return 1
	return 0
dp = []
limit = []
v = []

def dpdfs(u, t=-1):
	dp[0][u] = 0
	dp[1][u] = 0
	for i in v[u]:
		if i == t:
			continue
		if dp[1][i] == -1:
			dpdfs(i, u)
		dp[0][u] += max(abs(limit[0][u] - limit[1][i]) + dp[1][i], abs(limit[0][u] - limit[0][i]) + dp[0][i])
		dp[1][u] += max(abs(limit[1][u] - limit[1][i]) + dp[1][i], abs(limit[1][u] - limit[0][i]) + dp[0][i])
vis = []
f = 0
from math import factorial as fact
from queue import PriorityQueue

def z_algorithm(s):
	res = [0] * len(s)
	res[0] = len(s)
	(i, j) = (1, 0)
	while i < len(s):
		while i + j < len(s) and s[j] == s[i + j]:
			j += 1
		res[i] = j
		if j == 0:
			i += 1
			continue
		k = 1
		while i + k < len(s) and k + res[k] < j:
			res[i + k] = res[k]
			k += 1
		(i, j) = (i + k, j - k)
	return res

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

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

def gcdExtended(a, b):
	if a == 0:
		return (b, 0, 1)
	(gcd, x1, y1) = gcdExtended(b % a, a)
	x = y1 - b // a * x1
	y = x1
	return (gcd, x, y)
import re
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	cnt1 = 0
	cnt0 = 0
	for i in l:
		if i == 0:
			cnt0 += 1
		elif i == 1:
			cnt1 += 1
	print(cnt1 * 2 ** cnt0)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	m = l.count(1)
	k = l.count(0)
	s = sum(l)
	if s - 1 == 0:
		ans = pow(2, k)
		print(ans)
	else:
		arr = m * 1
		b = pow(2, k) - 1
		ans = arr + arr * b
		print(ans)


from collections import Counter, defaultdict, OrderedDict, deque
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from typing import List
import itertools
import math
import heapq
import string
import random
(MIN, MAX, MOD) = (-1061109567, 1061109567, 1000000007)
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')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

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

def N():
	return int(input())
for _ in range(N()):
	n = N()
	a = RLL()
	(o, z) = (a.count(1), a.count(0))
	print(o * pow(2, z))


from collections import Counter

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

def solve():
	(n,) = readline()
	a = readline()
	c = Counter(a)
	z = c[0]
	e = c[1]
	print(e * 2 ** z)
t = int(input())
for __ in range(t):
	solve()


from math import factorial

def f(k, n):
	return factorial(n) // (factorial(k) * factorial(n - k))
for _ in range(int(input())):
	n = int(input())
	one = 0
	zero = 0
	cnt = 0
	for i in list(map(int, input().split())):
		if i == 1:
			one += 1
		if i == 0:
			zero += 1
	cnt += one
	k = zero
	while zero > 0:
		cnt += one * f(zero, k)
		zero -= 1
	print(cnt)


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	if s.count(1) == 0:
		print(0)
	else:
		print(2 ** s.count(0) * s.count(1))


import sys, os
from io import BytesIO, IOBase
import bisect

def main():
	for _ in range(inp.single()):
		n = inp.single()
		a = inp.list()
		if a.count(1) == 0:
			print(0)
			continue
		if a.count(0) == 0:
			print(a.count(1))
			continue
		print(2 ** a.count(0) * a.count(1))
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')

def memodict(f):

	class memodict(dict):

		def __missing__(self, key):
			ret = self[key] = f(key)
			return ret
	return memodict().__getitem__

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def is_prime(n):
	if n < 5 or n & 1 == 0 or n % 3 == 0:
		return 2 <= n <= 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			p = p * p % n
			if p == n - 1:
				break
		else:
			return False
	return True

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

class inputs:

	def single(self):
		return int(input())

	def mul(self):
		return map(int, input().split())

	def list(self):
		return list(map(int, input().split()))
inp = inputs()
main()


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	ones = arr.count(1)
	zeros = arr.count(0)
	print(ones * 2 ** zeros)


import sys
inp = sys.stdin.readline()
test = int(inp.strip('\n'))
result = ''
for i in range(test):
	inp = sys.stdin.readline()
	n = int(inp.strip('\n'))
	inp = sys.stdin.readline()
	a = list(map(int, inp.strip('\n').split()))
	ones = zeroes = 0
	for val in a:
		if val == 0:
			zeroes += 1
		elif val == 1:
			ones += 1
	val = ones * (1 << zeroes)
	sys.stdout.write(str(val) + '\n')


t = int(input())
o = 0
while o != t:
	o += 1
	n = int(input())
	a = list(map(int, input().split()))
	n1 = 0
	n0 = 0
	for j in range(len(a)):
		if a[j] == 1:
			n1 += 1
		if a[j] == 0:
			n0 += 1
	l = 1
	for k in range(1, n0 + 1):
		l *= 2
	if n0 == 0:
		print(n1)
	if n0 != 0:
		print(n1 * l)


t = int(input())
ans = [0] * t
for i in range(t):
	n = int(input())
	s = 0
	q0 = 0
	q1 = 0
	a = list(map(int, input().split()))
	for j in range(n):
		if a[j] == 0:
			q0 += 1
		elif a[j] == 1:
			q1 += 1
	ans[i] = q1 << q0
for i in range(t):
	print(ans[i])


from math import factorial as f

def get(a, b):
	return f(a) // (f(b) * f(a - b))
test = int(input())
for t in range(test):
	ans = 0
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	c0 = a.count(0)
	c1 = a.count(1)
	if c1 == 0:
		print(0)
		continue
	for i in range(c0 + 1):
		ans += get(c0, i) * c1
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	s = sum(arr)
	if arr.count(0) + arr.count(1) == 0:
		print('0')
	else:
		print(arr.count(1) * 2 ** arr.count(0))


for z in range(int(input())):
	n = int(input())
	l = list(map(int, input().strip().split()))
	(a, b) = (0, 0)
	k = 0
	if 0 in l:
		a = l.count(0)
	if 1 in l:
		b = l.count(1)
		k += 1
	a = 2 ** a
	if k == 0:
		print(0)
	else:
		print(a * b)


import bisect
import collections
import copy
import enum
import functools
import heapq
import itertools
import math
import random
import re
import sys
import time
import string
from typing import List
sys.setrecursionlimit(3001)
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	sa = sum(arr)
	c1 = arr.count(1)
	c0 = arr.count(0)
	print(c1 * 2 ** c0)


n = int(input())
for i in range(n):
	l = int(input())
	a = map(int, input().split())
	count_zeros = 0
	count_ones = 0
	for j in a:
		if j == 0:
			count_zeros += 1
		if j == 1:
			count_ones += 1
	print(count_ones * 2 ** count_zeros)


from collections import deque, defaultdict
from math import sqrt, ceil, factorial, floor, inf, log2, sqrt, gcd
import bisect
import copy
from itertools import combinations
import sys
import heapq

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

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

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

def binomialCoef(n, k):
	C = [[0 for x in range(k + 1)] for x in range(n + 1)]
	for i in range(n + 1):
		for j in range(min(i, k) + 1):
			if j == 0 or j == i:
				C[i][j] = 1
			else:
				C[i][j] = C[i - 1][j - 1] + C[i - 1][j]
	return C[n][k]
for _ in range(int(input())):
	n = int(input())
	a = get_array()
	ones = a.count(1)
	zeros = a.count(0)
	tot = 0
	for i in range(zeros + 1):
		tot += binomialCoef(zeros, i)
	tot = int(tot)
	print(tot * ones)


def main():
	t = int(input())
	while t > 0:
		n = int(input())
		a = list(map(int, input().split()))
		print(2 ** a.count(0) * a.count(1))
		t -= 1
main()


import math
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	cnt0 = 0
	cnt1 = 0
	for j in a:
		if j == 0:
			cnt0 += 1
		elif j == 1:
			cnt1 += 1
	if cnt0 != 0:
		print(int(cnt1 * math.pow(2, cnt0)))
	else:
		print(cnt1)


from math import factorial

def fac(g):
	if g == 1:
		return 2
	if g == 0:
		return 1
	if g >= 2:
		return 2 ** g
for i in range(int(input())):
	n = int(input())
	arr = [*map(int, input().split())]
	cz = 0
	ce = 0
	for i in arr:
		if i == 0:
			cz += 1
		if i == 1:
			ce += 1
	ans = ce * fac(cz)
	print(ans)


for i in range(int(input())):
	n = int(input())
	A = [int(k) for k in input().split()]
	o = A.count(1)
	z = A.count(0)
	print(2 ** z * o)


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')
from collections import defaultdict, deque
from math import ceil, floor, sqrt, log2, gcd, pi
from heapq import heappush, heappop
from bisect import bisect_left, bisect
from functools import reduce
from copy import deepcopy
import sys
abc = 'abcdefghijklmnopqrstuvwxyz'
ABC = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	one = arr.count(1)
	zero = arr.count(0)
	if one == 0:
		print(0)
	elif zero != 0:
		print(one * 2 ** (zero - 1) * 2)
	else:
		print(one)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(a) for a in input().split()]
	s = sum(a)
	print(a.count(1) * 2 ** a.count(0))


import sys

def readnum():
	input = sys.stdin.readline
	a = list(map(int, input().split()))
	return a

def print(val):
	sys.stdout.write(str(val) + '\n')
t = readnum()[0]
for _ in range(t):
	n = readnum()[0]
	arr = readnum()
	(zeros, ones) = (0, 0)
	for i in range(n):
		if arr[i] == 1:
			ones += 1
		elif arr[i] == 0:
			zeros += 1
	print(ones * 2 ** zeros)


t = int(input())
for i in range(t):
	n = int(input())
	s = input().split(' ')
	one = 0
	zero = 0
	for j in s:
		if j == '1':
			one += 1
		if j == '0':
			zero += 1
	print(one + one * (2 ** zero - 1))


import sys
input = lambda : sys.stdin.readline().rstrip()
import bisect
import itertools
import math
from collections import deque
from collections import Counter
import copy

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	one = a.count(1)
	zero = a.count(0)
	print(one * 2 ** zero)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = [int(i) for i in input().split()]
	o = arr.count(1)
	z = arr.count(0)
	if z > 0:
		print(o + o * (2 ** z - 1))
	else:
		print(o)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	full = sum(a)
	ones = a.count(1)
	zeros = a.count(0)
	print(ones * (2 ** zeros if zeros else 1))


def las(ltt, sltt):
	l = ltt.count(1)
	if l == 0:
		return 0
	out = l
	p = ltt.count(0)
	x = 2 ** p * l
	if p == 0:
		return out
	return x

def main():
	nc = int(input())
	for i in range(nc):
		sltt = int(input())
		ltt = list(map(int, input().split()))
		print(las(ltt, sltt))
main()


inf = float('inf')
import sys
import pprint
import logging
from logging import getLogger
import array

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

def maps():
	return [int(i) for i in input().split()]
logging.basicConfig(format='%(message)s', level=logging.WARNING)
logger = getLogger(__name__)
logger.setLevel(logging.INFO)

def debug(msg, *args):
	logger.info(f'{msg}={pprint.pformat(args)}')
from collections import defaultdict
from itertools import combinations
from math import factorial
for _ in range(*maps()):
	(n,) = maps()
	a = list(maps())
	d = defaultdict(int)
	for i in a:
		d[i] += 1
	goal = sum(a) - 1
	if d[0] + d[1] == 0:
		print(0)
		continue
	if d[1] == 0:
		print(0)
		continue
	ans = d[1] * pow(2, d[0])
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	one_count = arr.count(1)
	zero_count = arr.count(0)
	print(one_count * pow(2, zero_count))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	count_0 = 0
	count_1 = 0
	for i in range(n):
		if l[i] == 0:
			count_0 += 1
		elif l[i] == 1:
			count_1 += 1
	if count_1 == 0:
		ans = 0
	elif count_0 == 0:
		ans = count_1
	else:
		ans = count_1 * 2 ** count_0
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print(arr.count(1) << arr.count(0))


def nCr(n, r):
	return fact(n) / (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res *= i
	return res

def solve():
	n = int(input())
	arr = list()
	(cnt1, cnt0) = (0, 0)
	arr = L()
	for i in range(n):
		if arr[i] == 1:
			cnt1 += 1
		elif arr[i] == 0:
			cnt0 += 1
	if cnt0 > 0 and cnt1:
		print(pow(2, cnt0) * cnt1)
	else:
		print(cnt1)
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
H = 1000000000 + 7
for _ in range(I()):
	solve()


from sys import stdin, stdout
input = stdin.readline

def output(answer):
	stdout.write('{}\n'.format(answer))
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	(cn0, cn1) = (0, 0)
	for val in arr:
		if val == 0:
			cn0 += 1
		if val == 1:
			cn1 += 1
	output(2 ** cn0 * cn1)


import io, os, sys
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
output = sys.stdout.write

def solve(N, nums):
	c0 = sum((1 for num in nums if num == 0))
	c1 = sum((1 for num in nums if num == 1))
	return c1 * (1 << c0)

def main():
	T = int(input())
	for _ in range(T):
		N = int(input())
		nums = list(map(int, input().split()))
		out = solve(N, nums)
		output(str(out) + '\n')
main()


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	c1 = 0
	c0 = 0
	for i in range(n):
		if a[i] == 0:
			c0 += 1
		if a[i] == 1:
			c1 += 1
	print(c1 * pow(2, c0))


for i in range(int(input())):
	nenado = input()
	a = list(map(int, input().split()))
	one = a.count(1)
	zero = a.count(0)
	print(one * 2 ** zero)


import math
t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	z = a.count(0)
	o = a.count(1)
	print(int(math.pow(2, z) * o))
	t -= 1


t = int(input())
for h in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	s = sum(A)
	r = 0
	d = 0
	for i in range(n):
		if A[i] == 1:
			r += 1
		if A[i] == 0:
			d += 1
	print(r * 2 ** d)


import math
from heapq import heappush, heappop, heapify
import random
import string
from collections import deque
from bisect import bisect, bisect_left, bisect_right, insort
import sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
H = 1000000000 + 7
for _ in range(I()):
	n = I()
	l = L()
	print(pow(2, l.count(0)) * l.count(1))


num = int(input())
for i in range(num):
	n = int(input())
	arr = input().split(' ')
	arr = list(map(int, arr))
	tot = 1
	a = arr.count(1)
	b = arr.count(0)
	if a == 0:
		print(0)
	elif b == 0:
		print(tot * a)
	else:
		print(tot * a * 2 ** b)


def luntik_and_subsequences(a):
	count_0 = 0
	count_1 = 0
	for ai in a:
		if ai == 0:
			count_0 += 1
		elif ai == 1:
			count_1 += 1
	return count_1 * 2 ** count_0
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	print(luntik_and_subsequences(a))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split(' ')))
	k = l.count(1)
	p = l.count(0)
	print(2 ** p * k)


n = int(input())
for i in range(n):
	l = int(input())
	in1 = input().split()
	in1 = list(map(int, in1))
	n0 = in1.count(0)
	n1 = in1.count(1)
	s = sum(in1)
	if s == 0:
		print(0)
	elif s == 1:
		print(2 ** (l - 1))
	elif n1 != 0:
		print(n1 * 2 ** n0)
	else:
		print(0)


import os
import sys
from io import BytesIO, IOBase
from math import cos, pi, ceil, pi, tan, floor, gcd, sqrt, log2, factorial, log10
from collections import Counter
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase
from statistics import mean, median, mode
from bisect import *
alpha = ascii_lowercase
beta = ascii_uppercase

def nextPowerOf2(n):
	p = 1
	if n and (not n & n - 1):
		return n
	while p < n:
		p <<= 1
	return p

def isComposite(n):
	if n <= 1:
		return False
	if n <= 3:
		return False
	if n % 2 == 0 or n % 3 == 0:
		return True
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return True
		i = i + 6
	return False

def get_Divisors(n):
	arr = []
	i = 1
	while i <= sqrt(n):
		if n % i == 0:
			if n / i == i:
				arr.append(i)
			else:
				arr.append(i)
				arr.append(n // i)
		i = i + 1
	return arr

def isprime(n):
	if n == 1:
		return 0
	i = 2
	while i * i <= n:
		if n % i == 0:
			return 0
		i += 1
	return 1

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

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

def create_matrix(n, m):
	mat = [[] for i in range(n)]
	for i in range(n):
		for j in range(m):
			mat[i].append(0)
	return mat

def main():
	for ttt in range(int(input())):
		n = int(input())
		arr = list(map(int, input().split()))
		ans = 0
		cc = 0
		for i in range(n):
			if arr[i] == 1:
				ans += 1
			if arr[i] == 0:
				cc += 1
		print(ans * 2 ** cc)
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()


for nt in range(int(input())):
	_ = int(input())
	a = list(map(int, input().split()))
	zeros = a.count(0)
	ones = a.count(1)
	ans = ones * (1 << zeros)
	print(ans)


import math
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	zero = l.count(0)
	one = l.count(1)
	print((1 << zero) * one)


import math
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip().split()))
	count0 = 0
	count1 = 0
	for i in a:
		if i == 1:
			count1 += 1
		if i == 0:
			count0 += 1
	print(int(count1 * math.pow(2, count0)))


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	xd = [0, 0]
	for i in range(n):
		if x[i] == 1:
			xd[1] += 1
		elif x[i] == 0:
			xd[0] += 1
	print(2 ** xd[0] * xd[1])


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))
get = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(get())):
	n = int(get())
	l = list(map(int, get().split()))
	s = sum(l)
	ans = 0
	z = 0
	for i in range(n):
		if l[i] == 1:
			ans += 1
		if l[i] == 0:
			z += 1
	if ans >= 0:
		print(ans * 2 ** z)
	else:
		print(0)


T = int(input())
for i in range(T):
	n = int(input())
	a = map(int, input().split())
	num0 = num1 = 0
	for j in a:
		if j == 0:
			num0 += 1
		elif j == 1:
			num1 += 1
	print(2 ** num0 * num1)


t = int(input())
for i in range(t):
	input()
	array = input().split()
	total = 0
	for j in array:
		if j == '1':
			total += 1
	for j in array:
		if j == '0':
			total *= 2
	print(total)


from sys import stdin, stdout, setrecursionlimit
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
from collections import defaultdict as dd, Counter as C, deque
from math import ceil, gcd, sqrt, factorial, log2, floor
from bisect import bisect_right as br, bisect_left as bl
from heapq import *
mod = 10 ** 9 + 7
inf = 1 << 60
for _ in range(it()):
	n = it()
	l = mp()
	k = C(l)
	zero = k[0]
	one = k[1]
	print(2 ** zero * one)


import math
TEST_MODE = False

def cust_print(stuff):
	if TEST_MODE:
		print(stuff)
	else:
		pass
output = []

def f(n, a):
	output.append(str(pow(2, a.count('0')) * a.count('1')))
test_cases = int(input())
for i in range(test_cases):
	cust_print(f'\n---- Call {i + 1} ----\n')
	n = int(input())
	a = input().split()
	f(n, a)
cust_print('\n---- Final output ----\n')
print('\n'.join(output))


import sys
for _ in range(int(input())):
	n = int(input())
	x = [int(i) for i in input().split()]
	print(x.count(1) * 2 ** x.count(0))


ans = []
for _ in range(int(input())):
	n = int(input())
	u = list(map(int, input().split()))
	s0 = 0
	s1 = 0
	for i in range(n):
		if u[i] == 0:
			s0 += 1
		elif u[i] == 1:
			s1 += 1
	ans.append(s1 * 2 ** s0)
print('\n'.join(map(str, ans)))


n = int(input())
list1 = []
for i in range(n):
	n1 = int(input())
	list1.append([int(x) for x in input().split()])
for i in list1:
	if i.count(0) != 0 and i.count(1) != 0:
		print(2 ** i.count(0) * i.count(1))
	elif i.count(1) != 0:
		print(i.count(1))
	else:
		print(0)


for s in [*open(0)][2::2]:
	l = [*map(int, s.split())]
	print(l.count(1) * 2 ** l.count(0))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split(' ')))
	a = 0
	b = 0
	for i in range(n):
		if l[i] == 1:
			a = a + 1
		elif l[i] == 0:
			b = b + 1
	if a == 0 and b == 0:
		print(0)
	elif b == 0:
		print(a)
	elif a == 0:
		print(0)
	else:
		print(a * 2 ** b)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(x, y) = (0, 0)
	for i in range(n):
		if a[i] == 0:
			x += 1
		if a[i] == 1:
			y += 1
	print(y * 2 ** x)


import math

def primeFactors(n):
	l = []
	c = 2
	while n > 1:
		if n % c == 0:
			l.append(c)
			n = n / c
		else:
			c = c + 1
	return l

def primeFactors(n):
	l = []
	c = 2
	while n > 1:
		if n % c == 0:
			l.append(c)
			n = n / c
		else:
			c = c + 1
	return l

def prime(n):
	prime_flag = 0
	if n > 1:
		for i in range(2, int(math.sqrt(n)) + 1):
			if n % i == 0:
				prime_flag = 1
				break
	return prime_flag
t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	if 1 not in l:
		print(0)
	else:
		z = l.count(0)
		one = l.count(1)
		ans = math.pow(2, z) * one
		print(int(ans))
	t = t - 1


import math
for _ in range(int(input())):
	n = int(input())
	lst = [int(i) for i in input().split()]
	x = lst.count(0)
	y = lst.count(1)
	if y == 0:
		print(0)
	elif x == 0:
		print(y)
	else:
		z = 2 ** x
		print(z * y)


def C(n, k):
	if 0 <= k <= n:
		nn = 1
		kk = 1
		for t in range(1, min(k, n - k) + 1):
			nn *= n
			kk *= t
			n -= 1
		return nn // kk
	else:
		return 0
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(i) for i in input().split()]
	if a.count(1) == 0:
		print(0)
	else:
		(cnt0, cnt1) = (a.count(0), a.count(1))
		vv = 1
		for cnt in range(1, cnt0 + 1):
			vv += C(cnt0, cnt)
		ans = a.count(1) * vv
		print(ans)


import io, os, sys
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
output = sys.stdout.write

def solve(N, nums):
	res = 0
	for (i, num) in enumerate(nums):
		if nums[i] != 1:
			continue
		left = sum((1 for j in range(i) if nums[j] == 0))
		right = sum((1 for j in range(i + 1, N) if nums[j] == 0))
		res += (1 << left) * (1 << right)
	return res

def main():
	T = int(input())
	for _ in range(T):
		N = int(input())
		nums = list(map(int, input().split()))
		out = solve(N, nums)
		output(str(out) + '\n')
main()


from sys import stdin, exit
from bisect import bisect_left as bl, bisect_right as br
from itertools import accumulate
yes = lambda : print('YES')
no = lambda : print('NO')
input = lambda : stdin.readline()[:-1]
intput = lambda : int(input())
sinput = lambda : input().split()
intsput = lambda : map(int, sinput())

def dprint(*args, **kwargs):
	if debugging:
		print(*args, **kwargs)
debugging = 1
t = intput()
for _ in range(t):
	n = intput()
	a = list(intsput())
	print(2 ** a.count(0) * a.count(1))


def solve():
	n = int(input())
	arr = [int(x) for x in input().split()]
	s = sum(arr)
	zeros = [a for a in arr if a == 0]
	ones = [a for a in arr if a == 1]
	if len(ones) == 1 and s == 1:
		return 2 ** (n - 1)
	return len(ones) * 2 ** len(zeros)
for _ in range(int(input())):
	print(solve())


def fact(n):
	ans = 1
	for i in range(1, n + 1):
		ans *= i
	return ans

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		ans = 0
		c0 = a.count(0)
		c1 = a.count(1)
		ans += c1
		for i in range(1, c0 + 1):
			ans += c1 * (fact(c0) // (fact(i) * fact(c0 - i)))
		print(ans)
main()


t = int(input())
for i in range(t):
	n = int(input())
	cnt_1 = 0
	cnt_0 = 0
	a = input().split()
	for i in a:
		if i == '1':
			cnt_1 += 1
		elif i == '0':
			cnt_0 += 1
	print(cnt_1 * 2 ** cnt_0)


from sys import *
input = stdin.readline
import threading
from bisect import *
import math
from collections import *
import operator
from heapq import *
from itertools import *
inf = 10 ** 19
mod = 10 ** 9 + 7
MOD = 998244353
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
dx = [-1, 0]
dy = [0, -1]
setrecursionlimit(200005)

def asc(c):
	return ord(c) - 97 + 1
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	zero = a.count(0)
	one = a.count(1)
	if one == n:
		print(one)
	elif zero == n:
		print(0)
	else:
		print(one * pow(2, zero))


cases = int(input())
for _ in range(cases):
	b = input()
	values = list(map(int, input().split()))
	answer = 0
	if 1 in values:
		answer += values.count(1) * 2 ** values.count(0)
	print(answer)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	cm = Counter(m)
	print(2 ** cm[0] * cm[1])


from math import pow
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	c1 = arr.count(1)
	c0 = arr.count(0)
	print(int(pow(2, c0) * c1))


for _ in range(int(input())):
	l = input()
	t = input().split()
	ans = 0
	res = 0
	for i in range(len(t)):
		t[i] = int(t[i])
		ans += t[i]
	if ans == 1:
		res += 1
	t.sort()
	l0 = t.count(0)
	l1 = t.count(1)
	p = [1]
	for i in range(1, 63):
		p.append(2 * p[i - 1])
	print(p[l0] * l1)


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

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

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

def get_int():
	return int(sys.stdin.readline().strip())

def get_list_strings():
	return list(map(str, sys.stdin.readline().strip().split()))

def solve(n, arr):
	tot = sum(arr)
	zeros = 0
	ones = 0
	for ele in arr:
		if ele == 0:
			zeros += 1
		if ele == 1:
			ones += 1
	if ones == 0:
		print(0)
		return
	rem = n - zeros
	rem -= ones
	ans = ones * 2 ** zeros
	print(ans)
T = get_int()
while T:
	n = get_int()
	arr = get_list()
	solve(n, arr)
	T -= 1


import sys
input = sys.stdin.readline
print = sys.stdout.write
a = int(input())
for i in range(a):
	b = int(input())
	c = list(map(int, input().split()))
	ans = 0
	ans2 = 0
	for i in c:
		if i == 1:
			ans += 1
		elif i == 0:
			ans2 += 1
	print(str(ans * 2 ** ans2) + '\n')


import sys
input = iter(sys.stdin.read().splitlines()).__next__

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	num_ones = a.count(1)
	num_zeros = a.count(0)
	return 2 ** num_zeros * num_ones
t = int(input())
output = []
for _ in range(t):
	output.append(solve())
print(*output, sep='\n')


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	s = sum(a)
	ans = 0
	ed = a.count(1)
	nu = a.count(0)
	if nu == 0 and ed == 0:
		print(0)
	elif nu > 0 and ed == 0:
		print(0)
	elif nu == 0 and ed > 0:
		print(ed)
	elif nu > 0 and ed > 0:
		print(ed * 2 ** nu)


import math

def comb(n, r):
	x = math.factorial(n) / (math.factorial(r) * math.factorial(n - r))
	return int(x)

def solve():
	n = int(input())
	l = list(map(int, input().split()))
	if 0 not in l and 1 not in l:
		ans = 0
		print(ans)
		return
	if 0 not in l and 1 in l:
		ans = l.count(1)
		print(ans)
		return
	elif 0 in l and 1 not in l:
		ans = 0
		print(ans)
		return
	elif 0 in l and 1 in l:
		x = l.count(0)
		x1 = pow(2, x) - 1
		y = l.count(1)
		ans = x1 * y + y
		print(ans)
		return
t = int(input())
while t != 0:
	solve()
	t -= 1


for i in range(int(input())):
	n = input()
	mas = list(map(int, input().split()))
	zero = 0
	one = 0
	a = 0
	for i in mas:
		if i == 0:
			zero += 1
		if i == 1:
			one += 1
	print(one * 2 ** zero)


for _ in range(int(input())):
	n = int(input())
	(counter1, counter2) = (0, 0)
	line = [int(ch) for ch in input().split()]
	if 1 not in line:
		print(0)
		continue
	for i in range(len(line)):
		if line[i] == 1:
			counter1 += 1
	for i in range(len(line)):
		if line[i] == 0:
			counter2 += 1
	if counter1 == 0:
		print(counter2)
	elif counter2 == 0:
		print(counter1)
	else:
		print(counter1 * 2 ** counter2)


import math
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	one = 0
	zer = 0
	for i in a:
		if i == 1:
			one += 1
		elif i == 0:
			zer += 1
	print(one * 2 ** zer)


t = int(input())
for x in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	count0 = a.count(0)
	count1 = a.count(1)
	if count0 != 0:
		num1 = 2 ** count0 * count1
	else:
		num1 = count1
	print(num1)


from collections import defaultdict
fact = [0] * 61
fact[0] = 1
for i in range(1, 61):
	fact[i] = fact[i - 1] * i

def nCr(n, k):
	if k == 0:
		return 1
	if n == k:
		return 1
	return fact[n] // (fact[k] * (fact[n] - fact[k]))

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	ans = 0
	numOnes = sum([1 for i in a if i == 1])
	numZeros = sum([1 for i in a if i == 0])
	if numOnes == 0:
		print(0)
		return
	print(2 ** numZeros * numOnes)
	return
t = int(input())
for _ in range(t):
	solve()


n = int(input())
for i in range(n):
	k = int(input())
	s = input().split()
	c_0 = 0
	c_1 = 0
	for j in s:
		if j == '0':
			c_0 += 1
		elif j == '1':
			c_1 += 1
	print(2 ** c_0 * c_1)


t = int(input())
for i in range(t):
	int(input())
	array = list(map(int, input().split()))
	print(2 ** array.count(0) * array.count(1))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	z = 0
	o = 0
	for i in range(n):
		if a[i] == 0:
			z += 1
		elif a[i] == 1:
			o += 1
	ans = 2 ** z * o
	print(ans)


import sys
input = sys.stdin.readline

def ajj(N):
	prev = 1
	ans = 0
	ans += prev
	for i in range(1, N + 1):
		curr = prev * (N - i + 1) // i
		ans += curr
		prev = curr
	return ans
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ze = 0
	on = 0
	for i in a:
		if i == 1:
			on += 1
		if i == 0:
			ze += 1
	print(ajj(ze) * on)


from sys import stdin

def read_input():
	n = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	return (n, a)

def solve(n, a):
	(zero, one) = (0, 0)
	for ai in a:
		if ai == 0:
			zero += 1
		elif ai == 1:
			one += 1
	return one * 2 ** zero

def main():
	t = int(stdin.readline())
	for _ in range(t):
		input = read_input()
		answer = solve(*input)
		print(answer)
main()


t = int(input())
for test in range(t):
	n = int(input())
	array = list(map(int, input().split()))
	(z, o) = (0, 0)
	for i in range(n):
		if array[i] == 0:
			z += 1
		elif array[i] == 1:
			o += 1
	print(o * 2 ** z)


import sys
input = sys.stdin.readline
for tc in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	z = a.count(0)
	o = a.count(1)
	print(2 ** z * o)


import sys
inp = sys.stdin.readline

def solve():
	n = int(inp())
	c1 = 0
	c0 = 0
	for i in map(int, inp().split()):
		if i == 1:
			c1 += 1
		elif i == 0:
			c0 += 1
	print(c1 * 2 ** c0)

def main():
	for i in range(int(inp())):
		solve()
main()


t = int(input())
i = 0
while i < t:
	mul = 1
	add = 0
	n = int(input())
	m = list(map(int, input().split()))
	j = 0
	while j < n:
		if m[j] == 0:
			mul *= 2
		if m[j] == 1:
			add += 1
		j += 1
	print('%d\n' % (mul * add))
	i += 1


testes = int(input())
resultados = [None] * testes
for i in range(testes):
	n = int(input())
	sequencia = list(map(int, input().split(' ')))
	if 1 in sequencia:
		if 0 in sequencia:
			resultados[i] = sequencia.count(1) * 2 ** sequencia.count(0)
		else:
			resultados[i] = sequencia.count(1)
	else:
		resultados[i] = 0
print(*resultados, sep='\n')


import math

def comb(n, p):
	C = math.factorial(n) / (math.factorial(p) * math.factorial(n - p))
	return int(C)
t = int(input())
for i in range(t):
	tam = int(input())
	nums = list(map(int, input().split()))
	if 1 not in nums:
		print(0)
		continue
	uns = nums.count(1)
	zeros = nums.count(0)
	soma = 0
	if sum(nums) == 1:
		soma += 1
	elif uns == 1:
		soma += 1
	if uns > 1:
		soma += comb(uns, uns - 1)
	soma = soma * 2 ** zeros
	print(soma)


import math
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = l.count(0)
	b = l.count(1)
	if a > 0 and b > 0:
		print(int(math.pow(2, a) * b))
	else:
		print(b)


t = int(input())
for i in range(0, t):
	num = int(input())
	l = list(map(int, input().split()))
	a = 0
	b = 0
	for i in range(0, num):
		if l[i] == 1:
			a += 1
		if l[i] == 0:
			b += 1
	print(2 ** b * a)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = 0
	(z, o) = (0, 0)
	for x in a:
		if x == 0:
			z += 1
		elif x == 1:
			o += 1
	print(pow(2, z) * o)


a = input()
while True:
	try:
		t = int(input())
		a = [int(i) for i in input().split()]
		n_0 = a.count(0)
		n_1 = a.count(1)
		ans = 0
		ans += n_1 * 2 ** n_0
		if sum(a) == 1:
			ans = 2 ** n_0
		print(ans)
	except:
		break


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	print(l.count(1) * 2 ** l.count(0))


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	cnt = [0] * 2
	for num in arr:
		if num <= 1:
			cnt[num] += 1
	return cnt[1] * 2 ** cnt[0]
for _ in range(int(input())):
	print(solve())


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	z = arr.count(0)
	o = arr.count(1)
	ans = pow(2, z) * o
	print(ans)