Shashank is a newbie to mathematics, and he is very excited after knowing that a given l of cardinality N has (2^{N} - 1) non-empty sublist. He writes down all the non-empty sublists for a given set A. For each sublist, he calculates sublist_sum, which is the sum of elements and denotes them by S_{1}, S_{2}, S_{3}, ... , S(2^{N}-1).

He then defines a special_sum, P.

P = 2^{S_{1}}  + 2^{S_{2}}  + 2^{S_{3}}  .... + 2^{S(2^{N}-1)} and reports P % (10^{9} + 7).   

Input Format 

The first line contains an integer N, i.e., the size of list A. 

The next line will contain N integers, each representing an element of list A.  

Output Format 

Print special_sum, P modulo (10^{9} + 7).  

Constraints 

1 ≤ N ≤ 10^{5} 

0 ≤ a_{i} ≤ 10^{10} , where i ∈ [1 .. N]  

Sample Input  

3
1 1 2

Sample Output  

44

Explanation  

For given list, sublist and calculations are given below 

1. {1} and 2^{1} = 2 

2. {1} and 2^{1} = 2 

3. {2} and 2^{2} = 4 

4. {1,1} and 2^{2} = 4 

5. {1,2} and 2^{3} = 8 

6. {1,2} and 2^{3} = 8 

7. {1,1,2} and 2^{4} = 16 

So total sum will be 44.

Difficulty: MEDIUM
Tags: Matrices

Starter code:

Solutions:
P = 1000000007
PHI = P - 1
n = int(input())
a = [int(s) % PHI for s in input().split()]
ret = 1
for x in a:
	ret = ret * (1 + pow(2, x, P)) % P
print((ret - 1) % P)


n = int(input())
ans = 1
p = int(1000000000.0 + 7)
s = input().strip().split()
for i in s:
	k = int(i)
	tmp = 1 + pow(2, k, p)
	ans *= tmp
	ans %= p
print(ans - 1)


from sys import stdin as cin
from itertools import combinations as c
mod = 1000000007
n = int(cin.readline())
a = list(map(int, cin.readline().split()))
b = list((pow(2, x, mod) for x in a))
s = 1
for x in b:
	s = s * (x + 1) % mod
print(s - 1)


import sys
MOD = 1000000007
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
P = 1
for a in A:
	P = P * (1 + pow(2, a, MOD)) % MOD
print((P - 1) % MOD)


modulo = 10 ** 9 + 7

def twopow(N):
	if N == 0:
		return 1
	p = 2
	res = 2
	while p <= N:
		res = res * res % modulo
		p = p * 2
	return res * twopow(N % (p / 2)) % modulo % modulo

def solve(A):
	result = twopow(A[-1])
	for x in reversed(A[:-1]):
		t = twopow(x)
		result = ((t + 1) * result + t) % modulo
	return result
input()
print(solve([int(x) for x in input().split(' ')]))


n = int(input())
nums = [int(i) for i in input().split()]
tot = 1
for i in nums:
	tot *= (pow(2, i, 1000000007) + 1) % 1000000007
	tot = tot % 1000000007
print((tot - 1) % 1000000007)


def ExpMod(n):
	k2i = 2
	ans = 1
	while n:
		if n % 2 == 1:
			ans = ans * k2i % (10 ** 9 + 7)
		k2i = k2i * k2i % (10 ** 9 + 7)
		n >>= 1
	return ans
N = int(input(''))
a = [int(i) for i in input('').split(' ')]
sum_ = [0] * len(a)
sum_[0] = ExpMod(a[0])
Sum = 0
for i in range(1, len(a)):
	Sum = (Sum + sum_[i - 1]) % (10 ** 9 + 7)
	sum_[i] = (Sum + 1) * ExpMod(a[i]) % (10 ** 9 + 7)
print(sum(sum_) % (10 ** 9 + 7))


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


MOD = 10 ** 9 + 7
N = int(input())
D = {}
for a in (int(_) for _ in input().split()):
	D[a] = D.get(a, 0) + 1
s = 1
for a in D:
	s *= pow(1 + pow(2, a, MOD), D[a], MOD)
	s %= MOD
print(s - 1)


import functools, operator as op, sys
MOD = 1000000007
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
P = functools.reduce(op.mul, ((1 + pow(2, a, MOD)) % MOD for a in A), 1)
print((P - 1) % MOD)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


MOD = 10 ** 9 + 7
T = int(input())
A = [int(x) for x in input().split()]
res = 1
for x in A:
	res = res * (1 + pow(2, x, MOD)) % MOD
print((res - 1) % MOD)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


import sys
MOD = 1000000007
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
P = 1
for a in A:
	P = P * (1 + pow(2, a, MOD)) % MOD
print((P - 1) % MOD)


import sys
MOD = 1000000007
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
P = 1
for a in A:
	P = P * (1 + pow(2, a, MOD)) % MOD
print((P - 1) % MOD)


from itertools import combinations
size = int(input())
array = list(map(int, input().split()))
m = 10 ** 9 + 7
total = 1
for e in array:
	total *= int(pow(2, e, m)) + 1
	total = total % m
print(total - 1)


import sys
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
Sum = 1
for a in arr:
	Sum = Sum * (1 + pow(2, a, 1000000007)) % 1000000007
print((Sum - 1) % 1000000007)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


mod = 1000000007
from decimal import Decimal

def mypow(n):
	if n == 0:
		return 1
	if n == 1:
		return 2
	v = mypow(n >> 1)
	v = v * v % mod
	if n & 1:
		return (v << 1) % mod
	return v

def solve():
	n = int(input())
	s = input().split()
	a = []
	for i in range(0, n):
		a.append(int(s[i]))
	ret = mypow(a[0])
	for i in range(1, n):
		v = mypow(a[i])
		ret = (ret + ret * v + v) % mod
	print(ret)
solve()


from functools import reduce
length = int(input())
array = list(map(int, input().split()))
mod = 1000000007
print(reduce(lambda a, b: a * b % mod, [1 + pow(2, num, mod) for num in array], 1) - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


from functools import reduce
m = 10 ** 9 + 7
N = int(input())
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


from functools import reduce
(n, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


mod = 1000000007
n = int(input())
l = [int(i) for i in input().split()]
ans = [0 for i in range(n)]
ans[0] = (pow(2, l[0], mod) + 1) % mod
for i in range(1, n):
	ans[i] = ans[i - 1] * (pow(2, l[i], mod) + 1) % mod
print((ans[n - 1] - 1) % mod)


import sys
MOD = 1000000007
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
P = 1
for a in A:
	P = P * (1 + pow(2, a, MOD)) % MOD
print((P - 1) % MOD)


MOD = 10 ** 9 + 7
n = int(input())
tab = list(map(int, input().split()))
result = 2 ** tab[0]
for x in tab[1:]:
	result = (result * (1 + pow(2, x, MOD)) + pow(2, x, MOD)) % MOD
print(result)


from functools import reduce
_ = input()
modo = 10 ** 9 + 7
ls = [1] + list((int(i) for i in input().strip().split()))
res = reduce(lambda x, y: x * (1 + pow(2, y, modo)) % modo, ls)
print(modo - 1 if res == 0 else res - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


input()
P = 10 ** 9 + 7
r = 1
for a in map(int, input().split()):
	r = r * (pow(2, a, P) + 1) % P
print((r + P - 1) % P)


_ = int(input())
a = map(int, input().split())
m = pow(10, 9) + 7
v = 1
for u in a:
	v *= 1 + pow(2, u, m)
	v %= m
v = (v - 1) % m
print(v)


from itertools import combinations, chain
n = int(input())
l = list(map(int, input().split()))
r = 1
MOD = 10 ** 9 + 7
for a in l:
	aux = 1
	x = 2
	while a != 0:
		if a & 1:
			aux = aux * x % MOD
		x = x * x % MOD
		a >>= 1
	aux += 1
	r = r * aux % MOD
print(r - 1)


import itertools
cases = int(input())
lst = [int(x) for x in input().split()]
for i in range(len(lst)):
	lst[i] = 1 + pow(2, lst[i], 10 ** 9 + 7)
sm = lst[0]
for j in range(1, len(lst)):
	sm = lst[j] * sm % (10 ** 9 + 7)
print(sm - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
arr = [int(1 + pow(2, int(i), m)) for i in input().strip().split(' ')]
print(reduce(lambda x, y: x * y % m, arr) - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


from functools import reduce
n = int(input())
a = [int(x) for x in input().split()]
mod = 10 ** 9 + 7
print(reduce(lambda a, b: a * b % mod, [1 + pow(2, x, mod) for x in a], 1) - 1)


from functools import reduce
print((reduce(lambda x, y: x * y % 1000000007, map(lambda y: pow(2, int(y), 1000000007) + 1, (input(), input().split())[1])) - 1) % 1000000007)


res = 1
m = int(1000000000.0 + 7)
input()
for i in [int(x) for x in input().split()]:
	res *= pow(2, i, m) + 1
	res = res % m
print(res - 1)


p = 1000000007
input()
result = 1
for i in map(int, input().split()):
	result *= pow(2, i, p) + 1
	result %= p
print((result - 1) % p)


from functools import reduce
M = 10 ** 9 + 7
N = int(input())
S = [int(x) for x in input().split()]
S = map(lambda x: pow(2, x, M) + 1, S)
print(reduce(lambda x, y: x * y % M, S) - 1 % M)


Num = int(input().strip())
s = 0
for x in input().split(' '):
	y = pow(2, int(x), 10 ** 9 + 7)
	s = (y * (s + 1) + s) % (10 ** 9 + 7)
print(s)


base = 10 ** 9 + 7

def mod_exp(n):
	result = 1
	two_to_two_to_i = 2
	i = 0
	while n >> i:
		if n >> i & 1:
			result = result * two_to_two_to_i % base
		i += 1
		two_to_two_to_i = two_to_two_to_i * two_to_two_to_i % base
	return result
N = int(input())
A = [int(a_i) for a_i in input().strip().split(' ')]
P = mod_exp(A[-1])
for a_i in reversed(A[:-1]):
	two_to_a_i = mod_exp(a_i)
	P = ((1 + two_to_a_i) * P + two_to_a_i) % base
print(P)


from functools import reduce
(n, m) = (int(input()), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().strip().split(' ')]) - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


n = int(input())
a_list = [int(x) for x in input().strip().split(' ')]
ans = 1
m = 10 ** 9 + 7
for a in a_list:
	ans *= 1 + pow(2, a, m)
print((ans - 1) % m)


inf = float('inf')
read_ints = lambda : list(map(int, input().split()))

def power_mod(N, k, MOD):
	if k == 0:
		return 1
	if k % 2 == 0:
		return power_mod(N, k / 2, MOD) ** 2 % MOD
	return N * (power_mod(N, (k - 1) / 2, MOD) ** 2 % MOD) % MOD

def solve(N, A, MOD):
	ans = 1
	for a in A:
		ans = ans * (power_mod(2, a, MOD) + 1) % MOD
	return (ans - 1) % MOD
N = int(input())
A = read_ints()
print(solve(N, A, 1000000007))


mod = 1000000007
n = int(input())
a = [(pow(2, int(item), mod) + 1) % mod for item in input().split()]
p = 1
for i in range(n):
	p = p * a[i] % mod
print(p - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


input()
nums = [int(x) for x in input().split(' ')]
res = 1
MOD = 1000000007
for num in nums:
	res = res * (1 + pow(2, num, MOD)) % MOD
print(res - 1)


n = int(input())
a = [int(x) for x in input().strip().split(' ')]
su = 0
for x in a:
	su = (pow(2, x, 1000000007) + su + su * pow(2, x, 1000000007)) % 1000000007
print(su)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


n = int(input())
(p, B) = (1, 10 ** 9 + 7)
for a in map(int, input().split()):
	p = p * (1 + pow(2, a, B)) % B
print(p - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


from functools import reduce
N = int(1000000000.0) + 7

def add(a, b):
	return (a + b) % N

def mult(a, b):
	return a * b % N
n = int(input())
p = reduce(mult, (1 + pow(2, int(x), N) for x in input().split()))
p = add(p, -1)
print(p)


B = 10 ** 9 + 7

def blah(i, L, s):
	return (pow(2, L[i], B) + (pow(2, L[i], B) + 1) * s) % B
N = int(input())
L = [int(i) for i in input().split()]
t = 0
for j in range(len(L)):
	t = blah(len(L) - 1 - j, L, t)
print(t)


import sys
import itertools
N = int(input())
A = list(map(int, input().split()))
all_subsets = []
ans = 1
for a in A:
	ans *= pow(2, a, 1000000007) + 1
print((ans - 1) % 1000000007)
sys.exit()
for i in range(1, N + 1):
	all_subsets += list(itertools.combinations(A, i))
for s in all_subsets:
	ans += pow(2, sum(s), 1000000007)
print(ans % 1000000007)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


def modpower(a, n, p):
	prod = 1
	power = a
	while n > 0:
		if n % 2 == 1:
			prod = prod * power % p
		power = power ** 2 % p
		n //= 2
	return prod
N = int(input())
L = list(map(int, input().split()))
p = 10 ** 9 + 7
prod = 1
for n in L:
	n %= p - 1
	prod = prod * (1 + modpower(2, n, p)) % p
print((prod + p - 1) % p)


N = int(input())
m = 1000000007
A = [int(a) for a in input().split()]
P = 1
for a in A:
	P = P * (pow(2, a, m) + 1) % m
P = P - 1
print(P)


import sys
MOD = 10 ** 9 + 7
N = int(input())
P = 0
A = [int(i) for i in input().split()]
for a in A:
	P = (P + (P + 1) * pow(2, a, MOD)) % MOD
print(P)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


N = int(input())
a = [int(x) for x in input().split()]
modulo = 10 ** 9 + 7
P = pow(2, a[0], modulo)
for cnt in range(1, N):
	P = pow(2, a[cnt], modulo) * (1 + P) + P
	P %= modulo
print(P)


import sys
MOD = 1000000007
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
P = 1
for a in A:
	P = P * (1 + pow(2, a, MOD)) % MOD
print((P - 1) % MOD)


n = int(input())
mm = 10 ** 9 + 7
a = [int(x) % (mm - 1) for x in input().split()]

def power(x):
	p = 2
	ret = 1
	while x > 0:
		if x & 1 == 1:
			ret = ret * p % mm
		p = p * p % mm
		x >>= 1
	return ret
ret = 1
for val in a:
	ret *= power(val) + 1
	ret %= mm
print(mm - 1 if ret == 0 else ret - 1)


N = int(input())
A = list(map(int, input().strip().split(' ')))

def f(A):
	MOD = 10 ** 9 + 7
	ans = 1
	for i in range(len(A)):
		ans *= pow(2, A[i], MOD) + 1
	ans -= 1
	ans %= MOD
	return ans
print(f(A))


p = 10 ** 9 + 7
n = int(input())
A = [int(a) for a in input().strip().split(' ')]
ans = 1
for i in range(n):
	ans *= 1 + pow(2, A[i], p)
	ans %= p
print(ans - 1)


import sys
N = int(input())
arr = list(map(int, input().split()))
P = int(1000000000.0 + 7)

def lpow(a):
	if a == 0:
		return 1
	elif a == 1:
		return 2
	else:
		b = a // 2
		x = lpow(b)
		y = x * x % P
		if a % 2 == 0:
			return y
		else:
			return y * 2 % P

def fac(a):
	return (lpow(a) + 1) % P
sum_tot = 1
for a in arr:
	sum_tot *= fac(a)
	sum_tot %= P
sum_tot -= 1
sum_tot %= P
print(sum_tot)


M = 10 ** 9 + 7

def m(i):
	return pow(2, i, M)
n = int(input())
l = list(map(int, input().split()))
L = list(map(m, l))
ans = 1
for i in range(n):
	ans *= 1 + L[i]
	ans %= M
print((ans - 1) % M)


t = int(input().strip())
elem = input().strip().split()
k = []
for a0 in range(t):
	k.append(int(elem[a0]))
l = 10 ** 9 + 7
prod = 1
for i in range(t):
	prod = prod * (pow(2, k[i], l) + 1)
print((prod - 1) % l)


n = int(input())
lst = list(map(int, input().split()))
val = 1
for i in range(n):
	val *= 1 + pow(2, lst[i], 1000000007)
print((val - 1) % 1000000007)


def fex(a, n):
	ans = 1
	while n:
		if n & 1:
			ans = ans * a % m7
		a = a * a % m7
		n >>= 1
	return ans
n = int(input().strip())
m7 = 10 ** 9 + 7
A = list(map(int, input().strip().split()))
Ar = [fex(2, x) + 1 for x in A]
s1 = 1
for a in Ar:
	s1 = s1 * a % m7
print(s1 - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


def power(a, b, mod):
	if b == 0:
		return 1
	else:
		result = 1
		c = a
		while b > 0:
			if b % 2 == 1:
				result = result * c % mod
			c = c ** 2 % mod
			b = b // 2
		return result
n = int(input())
ar = list(map(int, input().split()))
mod = pow(10, 9) + 7
total = 1
for x in ar:
	factor = power(2, x, mod) + 1
	total = total * factor % mod
print(total - 1)


MOD = 10 ** 9 + 7

def powmod(a):
	f = 2
	p = 1
	while a > 0:
		if a % 2 == 1:
			p = p * f % MOD
		a //= 2
		f = f * f % MOD
	return p
n = int(input())
list = [int(i) for i in input().split()]
p = 1
for a in list:
	p = (powmod(a) + 1) * p % MOD
print(p - 1)


n = int(input())
a = list(map(int, input().strip().split(' ')))
x = 1
d = 1000000007
for i in range(n):
	x = x * (pow(2, a[i], d) + 1) % d
x -= 1
print(x)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


import math

def pow2(r):
	l = 1
	x = 10 ** 9 + 7
	for i in range(r):
		l = l % x * (2 % x)
	return l % x
n = int(input())
x = 10 ** 9 + 7
m = 1
a = list(map(int, input().split()))
for k in range(n):
	r = a[k]
	m = m % x * ((1 % x + pow(2, r, x)) % x)
print((m - 1) % x)


import sys
MOD = 1000000007
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
P = 1
for a in A:
	P = P * (1 + pow(2, a, MOD)) % MOD
print((P - 1) % MOD)


t = int(input())
x = 1
for i in list(map(int, input().strip().split(' '))):
	x *= pow(2, i, 10 ** 9 + 7) + 1
print((x - 1) % (10 ** 9 + 7))


from functools import reduce
(_, m) = (input(), 10 ** 9 + 7)
print(reduce(lambda a, b: a * b % m, [1 + pow(2, int(x), m) for x in input().split()], 1) - 1)


n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
f = pow(2, a[0], mod)
for i in range(1, n):
	f = ((f + 1) * (pow(2, a[i], mod) + 1) - 1) % mod
print(f)


from functools import reduce
(N, m) = (int(input()), 10 ** 9 + 7)
res = reduce(lambda x, y: x * y % m, [pow(2, int(x), m) + 1 for x in input().split()])
print(res - 1)


from functools import reduce
(N, m) = (int(input()), 10 ** 9 + 7)
res = reduce(lambda x, y: x * y % m, [pow(2, int(x), m) + 1 for x in input().split()])
print(res - 1)


T = int(input().strip())
arr = [int(i) for i in input().split()]
s = 1
for i in arr:
	s = s * (pow(2, i, 10 ** 9 + 7) + 1)
print(s % (10 ** 9 + 7) - 1)


n = int(input())
a = list(map(int, input().strip().split()))
res = 1
for j in a:
	k = (pow(2, j, 1000000007) + 1) % 1000000007
	res = res * k % 1000000007
print(res - 1)


n = int(input())
mod = 10 ** 9 + 7
data = list(map(int, input().split()))
ans = 1
for x in data:
	ans = ans * (1 + pow(2, x, mod)) % mod
ans = (ans + mod - 1) % mod
print(ans)


s = 1
N = int(input())
a = input().split()
a = [int(x) for x in a]
for i in range(N):
	s = s * (1 + pow(2, a[i], 1000000007)) % 1000000007
s = (s - 1) % 1000000007
print(s)


n = int(input())
input_set = list(map(int, input().strip().split(' ')))
p = 1
mod = 10 ** 9 + 7
for element in input_set:
	p *= pow(2, element, mod) + 1
p %= mod
print(p - 1)


n = int(input())
mod_val = 10 ** 9 + 7

def psum(ar):
	prev_sum = 0
	prev_factor = 1
	for i in range(len(ar)):
		x = pow(2, ar[i], mod_val)
		prev_sum = (prev_sum % mod_val + prev_factor * x % mod_val) % mod_val
		prev_factor = prev_factor * (x + 1) % mod_val
	return prev_sum
print(psum(list(map(int, input().split(' ')))))