Harryxun/stf_run huggingface dataset:
n = int(input())
A = list(map(int, input().split()))
# 2本以上ある棒, 4本以上を選び出してsort, 大きいものから選ぶ
A = sorted(A)
c = collections.Counter(A)
c_2 = sorted(c.items(), key=lambda x:x[0], reverse=True)
count = 0
for i in range(n):
    if c_2[i][1] >=4 and count==0:
        ans = c_2[i][0] **2
        count+=2
        break
    elif c_2[i][1]>=2:
        if count==0:
            ans = c_2[i][0]
            count+=1
        elif count==1:
            ans *= c_2[i][0]
            count+=1
            break
if count!=2:
    print(0)
else:
    print(ans)

### FIXED CODE ###

import collections
n = int(input())
A = list(map(int, input().split()))
# 2本以上ある棒, 4本以上を選び出してsort, 大きいものから選ぶ
A = sorted(A)
c = collections.Counter(A)
c_2 = sorted(c.items(), key=lambda x:x[0], reverse=True)
count = 0
for i in range(n):
    if c_2[i][1] >=4 and count==0:
        ans = c_2[i][0] **2
        count+=2
        break
    elif c_2[i][1]>=2:
        if count==0:
            ans = c_2[i][0]
            count+=1
        elif count==1:
            ans *= c_2[i][0]
            count+=1
            break
if count!=2:
    print(0)
else:
    print(ans)
import numpy as np
def main():
    ttt = []
    n = int(input())
    N, M = map(int, input().split())
    e = list(map(int, input().split()))
    #e = [[int(i) for i in input().split()] for i in range(int(input()))]
    #n = 3
    #e = [[21,-11],[81234,94124,52141
    for j in range(n):
        t = N - e[j]*0.006
        tt = abs(M - t)
        ttt.append(tt)
    ttt = np.array(ttt)
    print(np.argmin(ttt)+1)
main()


### FIXED CODE ###

def main():
  a, b = (int(_) for _ in input().split())
  print(int(a+b/2))
main()
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
res = []

def solve(l, r):
  global res
  if r <= l: return
  res.append((l, r))
  solve(l + 1, r - 1)


solve(1, M + 1)
solve(M + 2, M * 2 + 1)
for r in res: print(*r)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N, M = map(int, input().split())
res = []

def solve(l, r):
  global res
  if r <= l: return
  res.append((l, r))
  solve(l + 1, r - 1)


solve(1, M + 1)
solve(M + 2, M * 2 + 1)
for r in res: print(*r)
H, W, M = map(int, input().split())
B = []
c={}
d={}

for i in range(M):
    b = list(map(int, input().split()))
    if b[0] not in c.keys():
        c[b[0]] =1
    else:
        c[b[0]] +=1
        
    if b[1] not in d.keys():
        d[b[1]] =1
    else:
        d[b[1]] +=1
    B.append(b)
#print(B)
#print(c,d,B)
c_max =max(c.values())
cc = [kv[0] for kv in c.items() if kv[1] == c_max]
d_max= max(d.values())
dd = [kv[0] for kv in d.items() if kv[1] == d_max]
#print(c_max,d_max)
#print(cc,c_max,dd,d_max)
if c_max == H and d_max== W:
    print((c_max+d_max)-1)
else:    
    for i in range (len(cc)):
        for n in range(len(dd)):
            #print(i, n, cc[i], dd[n])
            if [cc[i], dd[n]] not in B:
                print(c_max+d_max)
                break
        
            if i == len(cc)-1 and n == len(dd)-1:
                print((c_max+d_max)-1)

### FIXED CODE ###

n, x, t = map(int, input().split())

if n % x !=0:
    a = ((n // x)+1) * t 
else:
    a=(n//x)*t
print(a)
a,b,c=input(),split(",")
print(a,b,c)

### FIXED CODE ###

print(*input().split(","))
n=int(input())
line=list(str(input()))
line.replace('E',0)
line.replace('W',1)
def turn_e(x):
  count=0
  for i in range(x):
    if line[i]==1:
      count+=1
  return count
def turn_w(x):
  count=0
  for i in range(x+1,n):
    if line[i]==0:
      count+=1
  return count
v=n
for i in range(n):
  if (turn_e(i)+turn_w(i))<v:
    v=turn_e(i)+turn_w(i)
print(v)

### FIXED CODE ###

n=int(input())
s=input()
e=s.count('E')
w=0
ans=e+w
p=0
for i in s:
  if p==1:
    w+=1
    p=0
  if i=='E':
    e-=1
  else:
    p=1
  ans=min(ans,e+w)
print(ans)
# -*- coding: utf-8 -*-

import os
import sys
import math
import numpy as np


N = int(input())
A = np.array([int(input()) for i in range(N)])

counter = np.zeros(np.max(A)+1)

for a in A:
    counter[a] += 1

counter %= 2

print(int(np.sum(counter)))

### FIXED CODE ###

# -*- coding: utf-8 -*-

import os
import sys
import math
import numpy as np


N = int(input())
A = np.array([int(input()) for i in range(N)])

counter = {}

for a in A:
    if a in counter.keys():
        counter[a] = abs(counter[a] - 1)
    else:
        counter[a] = 1

print(sum(counter.values()))
import numpy as np

def main():
    N = int(input())
    A, B, C = np.zeros((N,3))

    for i in range(N):
        A[i], B[i], C[i] = [int(x) for x in input().split()]

    DP = np.full((N,3),-float("inf"),dtype=int)

    act = [A,B,C]

    for i, X in enumerate(act):
        DP[0][i] = X[0]
    
    for i in range(N-1):
        for x, X in enumerate(act):
            for y, Y in enumerate(act):
                if x != y:
                    DP[i+1][x] = max(DP[i+1][x],DP[i][y]+Y[i+1])

    print(DP[-1].max())

if __name__ == "__main__":
    main()
    pass

### FIXED CODE ###

def main():
    N = int(input())
    DP = [[0 for i in range(3)] for j in range(N+1)]
    
    for i in range(N):
        a = list(map(int, input().split()))
        for x in range(3):
            for y in range(3):
                if x != y:
                    DP[i+1][y] = max(DP[i+1][y],DP[i][x]+a[y])
    print(max(DP[-1]))

if __name__ == "__main__":
    main()
    pass
#! -*- coding:utf-8 -*-

def search(values,hp,vp,fruit):
	if not (0<=hp<len(values)): return
	if not (0<=vp<len(values[hp])): return
	if fruit!=values[hp][vp]: return
	values[hp][vp]=True
	search(values,hp-1,vp,fruit)
	search(values,hp+1,vp,fruit)
	search(values,hp,vp-1,fruit)
	search(values,hp,vp+1,fruit)

def solve(values):
	count=0
	for i in range(len(values)):
		for j in range(len(values[i])):
			if values[i][j] in ['@','#','*']:
				search(values,i,j,values[i][j])
				count+=1
	return count

def main():
	line,values=input(),list()
	while line!='0 0':
		H,W = list(map(int,line.strip().split(' ')))
		value = list()
		for _ in range(H):
			value.append([x for x in input().strip()])
		values.append(value)
		line = input()
	for value in values:
		print(solve(value))

if __name__=='__main__':
	main()

### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**6)

def search(field,hp,vp,item):
	if not (0<=hp<len(field)): return
	if not (0<=vp<len(field[hp])): return
	if item!=field[hp][vp]: return
	field[hp][vp]=True
	for dh,dv in [[0,1],[0,-1],[1,0],[-1,0]]:
		search(field,hp+dh,vp+dv,item)
#	search(field,hp-1,vp,item)
#	search(field,hp+1,vp,item)
#	search(field,hp,vp-1,item)
#	search(field,hp,vp+1,item)

def solve(field):
	count,valid_items=0,set(['@','#','*'])
	for i in range(len(field)):
		for j in range(len(field[i])):
			if field[i][j] in valid_items:
				search(field,i,j,field[i][j])
				count+=1
	return count

def main():
	line = input().strip()
	while line!='0 0':
		H,W = list(map(int,line.split(' ')))
		field = list()
		for _ in range(H):
			field.append(list(input().strip()))
		print(solve(field))
		line = input().strip()

if __name__=='__main__':
	main()
n = input()
print(len(set(list(map(int, [input() for i in range(n)])))))

### FIXED CODE ###

n = int(input())
print(len(set(list(map(int, [input() for i in range(n)])))))
s = set(list(map(int, input().split(' '))))
if s == set([1,9,7,4]):
    print(YES)
else:
    print(NO)

### FIXED CODE ###

s = set(list(map(int, input().split(' '))))
if s == set([1,9,7,4]):
    print("YES")
else:
    print("NO")
import fraction
from functools import reduce

def gcd_list(numbers):
    return reduce(fraction.gcd, numbers)

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

print(gcd_list(A))


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = min(A)
while True:
    for i in range(len(A)):
        if A[i] % ans != 0:
            A[i] %= ans
    if min(A) < ans:
        ans = min(A)
    else:
        break
print(ans)
s = input()
ans = [0 for _ in range(len(s))]
temp = 0
start = 0
for i in range(len(s) - 1):
    if s[i] == "R" and s[i + 1] == "L":
        pivot = i
    if s[i] == "L" and s[i + 1] == "R":
        temp += 1
        s[pivot] = s[pivot + 1] = temp // 2
        if temp % 2 == 1:
            s[pivot] = s[pivot + 1] = temp // 2
            if (pivot - start) % 2 == 1:
                s[pivot + 1] += 1
            else:
                s[pivot] += 1
        temp = -1
        start = i + 1
    temp += 1
s[pivot] = s[pivot + 1] = temp // 2
if temp % 2 == 1:
    s[pivot] = s[pivot + 1] = temp // 2
    if (pivot - start) % 2 == 1:
        s[pivot + 1] += 1
    else:
        s[pivot] += 1
for a in s:
    print(a, end = "")


### FIXED CODE ###

s = input()
ans = [0 for _ in range(len(s))]
temp = 0
start = 0
for i in range(len(s) - 1):
    if s[i] == "R" and s[i + 1] == "L":
        pivot = i
    if s[i] == "L" and s[i + 1] == "R":
        temp += 1
        ans[pivot] = ans[pivot + 1] = temp // 2
        if temp % 2 == 1:
            if (pivot - start) % 2 == 1:
                ans[pivot + 1] += 1
            else:
                ans[pivot] += 1
        temp = -1
        start = i + 1
    temp += 1
temp += 1
ans[pivot] = ans[pivot + 1] = temp // 2
if temp % 2 == 1:
    if (pivot - start) % 2 == 1:
        ans[pivot + 1] += 1
    else:
        ans[pivot] += 1
for a in ans:
    print(str(a) + " ", end = "")
import sys
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]
sys.setrecursionlimit(m)
ans = n * (n - 1) // 2
result = [ans]
leader = [-1] * n
size = [1] * n


def leader_check(i):
    if leader[i] == -1:
        return i
    ln = leader_check(leader[i])
    leader[i] = ln
    return ln

for a, b in ab[:0:-1]:
    a, b = a - 1, b - 1
    la = leader_check(a)
    lb = leader_check(b)
    if la != lb:
        leader[la] = lb
        ans -= size[la] * size[lb]
        size[lb] += size[la]
    result.append(ans)

for i in result[::-1]:
    print(i)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]

ans = n * (n - 1) // 2
result = [ans]
leader = [-1] * n
size = [1] * n


def leader_check(i):
    if leader[i] == -1:
        return i
    ln = leader_check(leader[i])
    leader[i] = ln
    return ln

for a, b in ab[:0:-1]:
    a, b = a - 1, b - 1
    la = leader_check(a)
    lb = leader_check(b)
    if la != lb:
        leader[la] = lb
        ans -= size[la] * size[lb]
        size[lb] += size[la]
    result.append(ans)

for i in result[::-1]:
    print(i)
X, Y= list(map(ord, input().split()))
if(X > Y):
  print(">")
elsif(Y < X):
  print("<")
else:
  print("=")

### FIXED CODE ###

X, Y= list(map(ord, input().split()))
if(X > Y):
  print(">")
elif(Y > X):
  print("<")
else:
  print("=")
# Hello World program in Python
from collections import Counter as cn

d = int(input())
l = []
for k in range(d):
  r = input()
   
  l.append(cn(r))

oi = l[0]

for g in range(1,d):
    oi = oi & l[g]
    
    
print("".join(sorted(oi.elements())))


### FIXED CODE ###

#
from collections import Counter

a,b,c = map(int,input().split())
if(b-a ==  c-b):
    print("YES")
else:
    print("NO")
import numpy as np
from scipy.sparse.csgraph import dijkstra

@np.vectorize
def trans(s):
    return 1 if s == "#" else 0

H, W = map(int, input().split())
S = np.array([trans([w for w in input()]) for _ in range(H)]).flatten()

def adjacency_matrix(H, W):
    t1 = [1 if i % W != W - 1 else 0 for i in range(H * W - 1)]
    t2 = [1 for _ in range(H * W - W)]
    return np.diag(t1, k=1) + np.diag(t1, k=-1) + np.diag(t2, k=W) + np.diag(t2, k=-W)
    
def different_colors(colors):
    return np.array([np.abs(colors - c) for c in colors])


ad = adjacency_matrix(H, W)
df = different_colors(S)

di = dijkstra(ad * df)
co = np.logical_and(di > 0, di < np.inf)

print(int(np.sum(co * df) / 2))

### FIXED CODE ###


import numpy as np
from collections import deque
import sys

def parse(inp):
    H, W = map(int, next(inp).split())
    return np.array([list(next(inp).strip()) for _ in range(H)])

dis = [0, 0, 1, -1]
djs = [1, -1, 0, 0]

def search(S, i, j, Q, R):
    H, W = S.shape
    R[i, j] = True
    Q.append((i, j))
    n0 = 0
    n1 = 0
    while Q:
        i, j = Q.popleft()
        if S[i, j] == "#":
            n1 += 1
        else:
            n0 += 1
        gen = ((i + di, j + dj) for di, dj in zip(dis, djs))
        ijs = (g for g in gen if 0 <= g[0] and g[0] < H and 0 <= g[1] and g[1] < W)
        for ni, nj in ijs:
            if not R[ni, nj] and S[ni, nj] != S[i, j]:
                R[ni, nj] = True
                Q.append((ni, nj))
    return n0 * n1


def test(S):
    i, j = 0, 0
    Q = deque()
    R = np.full(S.shape, False)
    H, W = S.shape
    n = 0
    for i in range(H):
        for j in range(W):
            if not R[i, j]:
                n += search(S, i, j, Q, R)
    return n

print(test(parse(sys.stdin)))
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, M = mi()
 
l = [i for i in range(1, N+1)]
 
if N % 2:
    for i in range(M):
        print(N//2-i, N//2+i+1)
else:
    for i in range(M//2, M):
        print(1+i-M//2, N-i+M//2)
    for i in range(M//2):
        print(N//2-i, N//2+i+2)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, M = mi()
 
l = [i for i in range(1, N+1)]
 
if N % 2:
    for i in range(M):
        print(N//2-i, N//2+i+1)
else:
    for i in range(M//2, M):
        print(1+i-M//2, N-i+M//2)
    for i in range(M//2):
        print(N//2-i, N//2+i+2)
n,t=list(map(int,input().split()))
lis = []
for i in range(n):
  s,k = list(map(int,input().split()))
  if k <= t:
    lis.append(s)
print(min(lis))


### FIXED CODE ###

n,t=list(map(int,input().split()))
lis = []
for i in range(n):
  s,k = list(map(int,input().split()))
  if k <= t:
    lis.append(s)
if lis == []:
  print("TLE")
  quit()
print(min(lis))
a = int(input())
b = int(input())
c = int(input())
print(x = a - b // c)


### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
print((a - b) % c)
def gcd(a,b):
	x,y = min(a,b), max(a,b)
	while x*y>0:
		x,y = y-x,x
	return y

N,M=map(int,input().split())
S=input()
T=input()
g=gcd(N,M)
p,q=M//g,N//g
print((N//g)*M) if S[0::q]==T[0::p] else print('-1')

### FIXED CODE ###

def gcd(a,b):
	x,y = min(a,b), max(a,b)
	while x*y>0:
		x,y = min(x,y), max(x,y)
		x,y = y-x,x
	return y

N,M=map(int,input().split())
S=input()
T=input()
g=gcd(N,M)
p,q=M//g,N//g
print((N//g)*M) if S[0::q]==T[0::p] else print('-1')
N = input()
if N % 2 == 0:
    print(N/2-1)
else:
    print((N-1)/2)
   

### FIXED CODE ###

N = int(input())
if N%2 == 0:
    print(int(N/2-1))
else:
    print(int((N-1)/2))
n=int(input())
a=[]
x=str(input())
a[0]=x
d=bool(True)
for i in range(1, n):
  y=str(input)
  if x[len(x)]!=y[0]:
    d=False
  for i in range(a.size()):
    if y==a[i]:
      d=False
  a.append(y)

if  d:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n=int(input())
a=[]
x=str(input())
a.append(x)
d=bool(True)

for i in range(1, n):
  y=str(input())
  if x[len(x)-1]!=y[0]:
    d=False
    
  for j in range(len(a)):
    if y==a[j]:
      d=False
  a.append(y)
  x=y

if  d==True:
  print("Yes")
else:
  print("No")
import sys
n, m, q = map(int, input().split())
alis, blis, clis, dlis = [], [], [], []
for _ in range(q):
    a, b, c, d = map(int, input().split())
    alis.append(a)
    blis.append(b)
    clis.append(c)
    dlis.append(d)
sys.setrecursionlimit(10**9)
Alist = [] 
def dfs(A):
    if len(A)==(n+1):
        Alist.append(A)
        return
    for i in range(A[-1], m+1):
        A.append(i)
        dfs(A)

dfs([1])

ans = 0
for A in Alist:
    score = 0
    for i in range(q):
        if A[blis[i]] - A[alis[i]] == clis[i]:
            score += dlis[i]
    ans = max(ans, score)

print(ans)

### FIXED CODE ###

import sys
n, m, q = map(int, input().split())
alis, blis, clis, dlis = [], [], [], []
for _ in range(q):
    a, b, c, d = map(int, input().split())
    alis.append(a)
    blis.append(b)
    clis.append(c)
    dlis.append(d)
sys.setrecursionlimit(10**9)
Alist = [] 
def dfs(A):
    if len(A)==(n+1):
        Alist.append(A)
        return
    for i in range(A[-1], m+1):
        dfs(A+[i])

dfs([1])

ans = 0
for A in Alist:
    score = 0
    for i in range(q):
        if A[blis[i]] - A[alis[i]] == clis[i]:
            score += dlis[i]
    ans = max(ans, score)

print(ans)
import sys;

def init(n_):
    length = 1;
    while(length < n_):
        length*=2
    element=[0]*(2*length-1)
    for i in range(2*length-1):
        element[i] = 0
    return element,length

def update(k,a,element):
    k+=n-1
    element[k]+=a
    while(k > 0):
        k = (int)((k-1)/2)
        element[k] = element[k*2+1]+element[k*2+2]

def findmin(a, b):
    return findquery(a,b+1,0,0,n)

def findquery(a, b, k, l, r):
    if(r <= a or b <= l):
        return 0
    if(a <= l and r <= b):
        return element[k]

    vl = findquery(a,b,k*2+1,l,(int)((l+r)/2+0.5))
    vr = findquery(a,b,k*2+2,(int)((l+r)/2),r)
    return vl+vr

n,q = map(int, input().split());

element,n = init(n)

for i in range(q):
    query,key,value = map(int, input().split());
    if(query == 0):
        update(key,value,element)
    else :
        print(findmin(key,value))


### FIXED CODE ###

import sys;

def init(n_):
    length = 1;
    while(length < n_):
        length*=2
    element = [0]*(2*length-1)
    for i in range(2*length-1):
        element[i] = 0
    return element,length

def update(k,a,element):
    k+=n-1
    element[k]+=a
    while(k > 0):
        k = (int)((k-1)/2)
        element[k] = element[k*2+1]+element[k*2+2]

def findmin(a, b):
    return findquery(a,b+1,0,0,n)

def findquery(a, b, k, l, r):
    if(r <= a or b <= l):
        return 0
    if(a <= l and r <= b):
        return element[k]

    vl = findquery(a,b,k*2+1,l,(int)((l+r)/2+0.5))
    vr = findquery(a,b,k*2+2,(int)((l+r)/2),r)
    return vl+vr

n,q = map(int, input().split());

element,n = init(n)

for i in range(q):
    query,key,value = map(int, input().split());
    if(query == 0):
        update(key-1,value,element)
    else :
        print(findmin(key-1,value-1))
import math
n=int(input())
T=[]
for  i in range(n):
	T.append(int(input()))

ans=T[0]
for i in range(1,len(T)):
	ans=ans*T[i]/math.gcd(int(ans),T[i])


print(int(ans))

### FIXED CODE ###

import fractions as math
n=int(input())
T=[]
for  i in range(n):
	T.append(int(input()))

ans=T[0]
for i in range(1,len(T)):
	ans=ans*T[i]//math.gcd(int(ans),T[i])


print(int(ans))
import sys
def main():
	input = sys.stdin.readline
    N = int(input())
    A = [x for x in input().split()]
    l = [0] * N
    B = set(A)
    C = list(B)
    for i in C:
        l[int(i)-1] = A.count(i)
    for i in range(N):
        print(l[i])
        
main()

### FIXED CODE ###

def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    l = [0]*N
    for i in A:
        l[i-1] += 1
    for j in l:
        print(j)
main()
N, X = map(int, input().split())

# list_l = [int(x) for x in input().split()]

position  = 0
count = 0

for i in range(N):
    position += int(input())
    if position <+ X:
        count += 1

print(count)


### FIXED CODE ###

N, X = map(int, input().split())

list_l = [int(x) for x in input().split()]

position = 0
count = 1

for l in list_l:
    position += l
    if position <= X:
        count += 1

print(count)
n,m=map(int,input().split())
l=[input().split() for _ in range(m)]
arr=[]
ac,wa=0,0
acl=[False for _ in range(m)]
for r in l:
  p,s=int(r[0]),r[1]
  if s=='AC' and acl[p]==False:
    arr.append([p,s])
    acl[p]=True
  elif s=='WA' and acl[p]==False:
    arr.append([p,s])
    
for r in arr:
  p,s=r
  if s=='WA' and acl[p]:
    wa+=1
  elif s=='AC':
    ac+=1
    
print(ac,wa)

### FIXED CODE ###

n,m=map(int,input().split())
l=[input().split() for _ in range(m)]
arr=[]
ac,wa=0,0
acl=[False for _ in range(n)]
for r in l:
  p,s=int(r[0])-1,r[1]
  if s=='AC' and acl[p]==False:
    arr.append([p,s])
    acl[p]=True
  elif s=='WA' and acl[p]==False:
    arr.append([p,s])
    
for r in arr:
  p,s=r
  if s=='WA' and acl[p]:
    wa+=1
  elif s=='AC':
    ac+=1
    
print(ac,wa)
N = int(input())
A = list(map(int,input().split()))
P = [2**i for i in range(len(A))]

# A = A[::-1]
# P = P[::-1]

# ans = 0
# node = 0
# for i in range(len(A)-1):
#     node = node + A[i]
#     node = min(node,2 * (P[i+1] - A[i+1]))
#     ans += node
#     if node <= 0:
#         print (-1)
#         exit()
#     print (node)
    
# ans += 1
# print (ans)

if A[0] > 0:
    print(-1)
    exit()
if A[-1] >= 2**N:
    print (-1)
    exit()

ans = [0]
node = [0]
def rec(i):
    if i==0:
        ans[0]+=1
        return 1
    node[0] = node[0] + A[i]
    node[0] = min(node[0], 2*rec(i-1))
    ans[0] += node[0]
    #print (node[0],node[0]-A[i])
    if i!=N and node[0] - A[i] <= 0:
        print(-1)
        exit()
    return node[0] - A[i]
rec(N)
print (ans[0])

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
P = [2**i for i in range(len(A))]
import sys
sys.setrecursionlimit(10**9)
# A = A[::-1]
# P = P[::-1]

# ans = 0
# node = 0
# for i in range(len(A)-1):
#     node = node + A[i]
#     node = min(node,2 * (P[i+1] - A[i+1]))
#     ans += node
#     if node <= 0:
#         print (-1)
#         exit()
#     print (node)
    
# ans += 1
# print (ans)

if N==0 and A[0]==1:
    print(1)
    exit()
if A[0] > 0:
    print(-1)
    exit()
# if A[-1] > 2**N:
#     print (-1)
#     exit()

# for a,p in zip(A[::-1],P[::-1]):
#     if a > p:
#         print (-1)
#         exit()

ans = [0]
node = [0]
def rec(i):
    if i==0:
        ans[0]+=1
        return 1
    node[0] = node[0] + A[i]
    node[0] = min(node[0], 2*rec(i-1))
    ans[0] += node[0]
    #print (node[0],node[0]-A[i])

    if (i!=N and node[0] - A[i] <= 0) or (node[0] - A[i] < 0):
        print(-1)
        exit()
    return node[0] - A[i]
rec(N)
print (ans[0])
a,b,x=map(int,input().split())
if a >= x:
  print("NO")
elif a+b <= x:
  print("NO")
else:
  print(YES)

### FIXED CODE ###

A,B,X=map(int,input().split())
if A>X:
  print("NO")
elif A+B<X:
  print("NO")
else:
  print("YES")
a,b,c=map(int,list(input()))
print(min(a*b,c))


### FIXED CODE ###

a,b,c=map(int,input().split())
print(min(a*b,c))
import numpy as np
N , M = map(int, input().split())
a = list()
for n in range(M):
	a.append(int(input()))
dp = np.zeros(N+1)
dp[0] = 1
dp[1] = 0 if a[0] == 1 else 1
for n in range(2,N+1):
	if n in a:
		dp[n] = 0
	else:
		dp[n] = (int(dp[n-1])+int(dp[n-2]))%(10**9+7)
print(int(dp[N]))


### FIXED CODE ###

import numpy as np
N , M = map(int, input().split())
a = list()
for n in range(M):
    a.append(int(input()))
dp = np.zeros(N+1)
dp[0] = 1
if M == 0:
    dp[1] = 1
else:
    dp[1] = 0 if a[0] == 1 else 1
ok = [False]*(N+1)
for x in a:
    ok[x] = True
for n in range(2,N+1):
    if ok[n]:
        continue
    dp[n] = (dp[n-1]+dp[n-2])%(10**9+7)
print(int(dp[N]))