Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
mx = []
for i in range(n):
    x = a.pop(i)
    mx.append(max(a))
    a.insert(i, x)
for i in range(n):
    print(mx[i])


### FIXED CODE ###

import copy
n = int(input())
a = [int(input()) for _ in range(n)]
s = copy.copy(a)
s.sort(reverse=True)
first = s[0]
second = s[1]
mx = []
for i in range(n):
    if a[i] == first:
        mx.append(second)
    else:
        mx.append(first)
for i in range(n):
    print(mx[i])
### BUGGY CODE ###

n,x=map(int,input().split())
r=list(map(int,input().split()))
r.append(x)
r.sort()
d=[]
e=[]
for i in range(n):
  if r[i+1]!=r[i]:
    d.append(r[i+1]-r[i])
d=list(set(d))
#print(d)
while len(d)>1:
  m=min(d)
  for i in range(len(d)-1):
    if d[i+1]!=d[i]:
      e.append(d[i+1]-d[i])
  d=e[:]
  d.append(m)
  d=list(set(d))
  d.sort()
  #print(d)
print(*d)

### FIXED CODE ###

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

n,x=map(int,input().split())
r=list(map(int,input().split()))
r.append(x)
r.sort()
d=[]
e=[]
for i in range(n):
  if r[i+1]!=r[i]:
    d.append(r[i+1]-r[i])
d=list(set(d))
ans=gcd(d[0],d[-1])
for y in d:
  if y%ans!=0:
    ans=gcd(ans,y)
print(ans)
### BUGGY CODE ###

def main():
    import copy

    h,w = map(int,input().split())
    a = [input() for _ in range(h)]
    b = [[False]*w for _ in range(h)]
    c = []
    d = [(-1,0), (1,0), (0,-1), (0,1)]
    ans = 0

    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                b[i][j] = True
                c.append((i,j))

    while True:
        tmp = []
        for i,j in c:
            for d1,d2 in d:
                if 0 <= i + d1 < h and 0 <= j + d2 < w:
                    if not b[i+d1][j+d2]:
                        tmp.append((i+d1, j+d2))
                        b[i+d1][j+d2] = True
        if tmp:
            c = copy.deepcopy(tmp)
            ans += 1
        else:
            break

    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import copy
#import time

h,w = map(int,input().split())
a = [input() for _ in range(h)]
b = [[False]*w for _ in range(h)]
#s = time.time()
c = []
d = [(-1,0), (1,0), (0,-1), (0,1)]
ans = 0

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            b[i][j] = True
            c.append((i,j))
#print(time.time()-s)

while True:
    tmp = []
    cnt = 0
    for i,j in c:
        for d1,d2 in d:
            if 0 <= i + d1 < h and 0 <= j + d2 < w:
                if not b[i+d1][j+d2]:
                    tmp.append((i+d1, j+d2))
                    b[i+d1][j+d2] = True
                    cnt += 1
    #print(time.time()-s)
    if cnt > 0:
        c = copy.copy(tmp)
        ans += 1
    else:
        break
    #print(time.time()-s)

print(ans)
### BUGGY CODE ###

import math

N,M = map(int, input().split())
L = list(map(int, input().split()))

L = sorted(L,reverse=True)


for i in range(0,M):
	L[0] = int(math.floor(L[0] / 2))
	L = sorted(L,reverse=True)
	
print(sum(L))

### FIXED CODE ###

import heapq

N,M = map(int, input().split())
L = [-int(i) for i in input().split()]
heapq.heapify(L)



for i in range(M):
    h = -(-heapq.heappop(L) // 2)
 
    heapq.heappush(L,h)

print(-sum(L))
### BUGGY CODE ###

N = int(input())
X = []
Y = []
P = []
for _ in range(N):
    x, y, p = map(int, input().split())
    X.append(x)
    Y.append(y)
    P.append(p)

DX = [[0] * (1 << N) for _ in range(N)]
DY = [[0] * (1 << N) for _ in range(N)]

for i, x in enumerate(X):
    for k in range(1 << N):
        d = abs(x)
        for j, xx in enumerate(X):
            if k & (1 << j):
                d = min(d, abs(xx - x))
        DX[i][k] = d * P[i]
for i, y in enumerate(Y):
    for k in range(1 << N):
        d = abs(y)
        for j, yy in enumerate(Y):
            if k & (1 << j):
                d = min(d, abs(yy - y))
        DY[i][k] = d * P[i]

ANS = [1 << 100] * (N + 1)
PC = [0] * (1 << N)
for i in range(1, 1 << N):
    PC[i] = PC[i^1] + 1 if i % 2 else PC[i//2]

RA = []
for i in range(1 << N):
    t = []
    for j in range(N):
        if i & (1 << j):
            t.append(j)
    RA.append(t)

mm = (1 << N) - 1
for i in range(1 << N):
    m = i ^ mm
    j = m
    while 1:
        ans = 0
        for k in RA[i^j^mm]:
            ans += min(DX[k][i], DY[k][j])
        
        pc = PC[i] + PC[j]
        ANS[pc] = min(ANS[pc], ans)
        
        if not j:
            break
        j = m & (j - 1)
for i in range(1 << N):
    m = i ^ mm
    j = m
    while 1:
        ans = 0
        for k in RA[i^j^mm]:
            ans += min(DX[k][i], DY[k][j])
        
        pc = PC[i] + PC[j]
        ANS[pc] = min(ANS[pc], ans)
        
        if not j:
            break
        j = m & (j - 1)

print(*ANS, sep = "\n")


### FIXED CODE ###

N = int(input())
X = []
Y = []
P = []
for _ in range(N):
    x, y, p = map(int, input().split())
    X.append(x)
    Y.append(y)
    P.append(p)

DX = [[0] * (1 << N) for _ in range(N)]
DY = [[0] * (1 << N) for _ in range(N)]

for i, x in enumerate(X):
    for k in range(1 << N):
        d = abs(x)
        for j, xx in enumerate(X):
            if k & (1 << j):
                d = min(d, abs(xx - x))
        DX[i][k] = d * P[i]
for i, y in enumerate(Y):
    for k in range(1 << N):
        d = abs(y)
        for j, yy in enumerate(Y):
            if k & (1 << j):
                d = min(d, abs(yy - y))
        DY[i][k] = d * P[i]

ANS = [1 << 100] * (N + 1)
PC = [0] * (1 << N)
for i in range(1, 1 << N):
    j = i ^ (i & (-i))
    PC[i] = PC[j] + 1

RA = []
for i in range(1 << N):
    t = []
    for j in range(N):
        if i & (1 << j):
            t.append(j)
    RA.append(tuple(t))


mm = (1 << N) - 1
for i in range(1 << N):
    m = i ^ mm
    j = m
    while 1:
        ans = 0
        for k in RA[i^j^mm]:
            ans += min(DX[k][i], DY[k][j])
        
        pc = PC[i] + PC[j]
        ANS[pc] = min(ANS[pc], ans)
        
        if not j:
            break
        j = m & (j - 1)

print(*ANS, sep = "\n")
### BUGGY CODE ###

N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))
for i in T:
    if i in D:
        D.pop(D.index(i))
    else:
        print("NO")
        exit()
print("YES")


### FIXED CODE ###

N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

D.sort();T.sort()
di = 0
ti = 0
while True:
     d = D[di];t=T[ti]
     if d==t:
         di+=1;ti+=1
     elif d>t:
         print("NO")
         exit()
     elif t>d:
         di+=1
     if ti >= len(T):
         print("YES")
         exit()
     if di >= len(D):
         print(di)
         print("NO")
         exit()
### BUGGY CODE ###

# from pprint import pprint
# import math
# import collections

# n = int(input())
n, m = map(int, input().split(' '))
a = list(map(int, input().split(' ')))

for _m in range(m):
    a = sorted(a, reverse=True)

    a[0] = a[0] // 2

ans = sum(a)
print(ans)


### FIXED CODE ###

# from pprint import pprint
import math

# import collections

# n = int(input())
n, m = map(int, input().split(' '))
a = list(map(lambda x: int(x) * (-1), input().split(' ')))
# a = sorted(a, reverse=True)
# b = [math.log2(_a) for _a in a]


import heapq

q_a = heapq.heapify(a)

for m in range(m):
    x = heapq.heappop(a) * (-1)
    heapq.heappush(a, (x // 2) * (-1))

print(sum(a) * (-1))
### BUGGY CODE ###

n, k = map(int, input().split())
h = tuple(map(int, input().split()))

INF = float('inf')
dp = [INF] * n
dp[0] = 0
# dp[i] = (足場iにたどり着いた時点でのコストの最小値)

for i in range(n):
    for j in range(i + 1, min(i + k + 1, n)):
        dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))

print(dp[n - 1])


### FIXED CODE ###

n, k = map(int, input().split())
h = tuple(map(int, input().split()))

INF = float('inf')
dp = [INF] * n
dp[0] = 0
# dp[i] = (足場iにたどり着いた時点でのコストの最小値)

for i in range(n):
    for j in range(i + 1, min(i + k + 1, n)):
        dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))

print(dp[n - 1])
### BUGGY CODE ###

N,K = map(int,input().split())
LR = [list(map(int,input().split())) for i in range(K)]
LR.sort()
mod = 998244353
ma = [0] * N
ma[0] = 1
for i in range(N):
    if i >1:
        ma[i] += ma[i-1]
    p = ma[i]
    if p != 0:
        for l,r in LR:
            if i+l <N:
                ma[i+l] += p
            if i+r+1<N:
                ma[i+r+1] -= p
print(ma[N-1]%mod)

### FIXED CODE ###

N,K = map(int,input().split())
LR = [list(map(int,input().split())) for i in range(K)]
LR.sort()
mod = 998244353
ma = [0] * N
ma[0] = 1
for i in range(N):
    if i >1:
        ma[i] += ma[i-1]
    p = ma[i]%mod
    if p != 0:
        for l,r in LR:
            if i+l <N:
                ma[i+l] += p
            else:
                break
            if i+r+1<N:
                ma[i+r+1] -= p
print(ma[N-1]%mod)
### BUGGY CODE ###

def main():
    import sys
    from fractions import gcd
    input = sys.stdin.readline

    def init(init_val):
        #set_val
        for i in range(n):
            seg[i+num-1]=init_val[i]    
        #built
        for i in range(num-2,-1,-1) :
            seg[i]=gcd(seg[2*i+1],seg[2*i+2]) 
        
    def update(k,x):
        k += num-1
        seg[k] = x
        while k:
            k = (k-1)//2
            seg[k] = gcd(seg[k*2+1],seg[k*2+2])
        
    def query(p,q):
        if q<=p:
            return ide_ele
        p += num-1
        q += num-2
        res=ide_ele
        while q-p>1:
            if p&1 == 0:
                res = gcd(res,seg[p])
            if q&1 == 1:
                res = gcd(res,seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = gcd(res,seg[p])
        else:
            res = gcd(gcd(res,seg[p]),seg[q])
        return res



    n = int(input())
    a = tuple(map(int,input().split()))

    #####単位元######
    ide_ele = 0

    #num:n以上の最小の2のべき乗
    num =2**(n-1).bit_length()
    seg=[ide_ele]*2*num
    init(a)

    ans = -1
    for i in range(n):
        ans = max(ans,gcd(query(0,i),query(i+1,n)))
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

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

X = [0]*N
Y = [0]*N

import fractions

X[0]=A[0]
for i in range(1,N):
    X[i] = fractions.gcd(X[i-1], A[i])

Y[N-1]=A[N-1]
for i in range(1,N):
    Y[N-1-i] = fractions.gcd(Y[N-i], A[N-1-i])

cand = []
cand.append(X[N-2])
cand.append(X[N-1])#=Y[0]
cand.append(Y[1])
for i in range(1,N-1):
    cand.append(fractions.gcd(X[i-1],Y[i+1]))

print(max(cand))
### BUGGY CODE ###

n = int(input())
s = input()
r_list = set([])
b_list = set([])
g_list = set([])

for i in range(n):
    if s[i] == 'R':
        r_list.add(i)
    elif s[i] == 'B':
        b_list.add(i)
    else:
        g_list.add(i)
        
ans = 0
for r in r_list:
    for b in b_list:
        ans += len(g_list - {2 * b - r, 2 * r - b, (b + r) / 2})
print(ans)

### FIXED CODE ###

n = int(input())
s = input()
r = s.count('R')
g = s.count('G')
b = n - r - g

ans = r * g * b
for i in range(1, (n // 2) + 1):
    for j in range(0, n - (2 * i) + 1):
        if j + (2 * i) >= n:
            break
        if ((s[j] != s[j + i]) & (s[j] != s[j + (2 * i)]) & (s[i + j] != s[j + (2 * i)])):
            ans -= 1
        
print(ans)
### BUGGY CODE ###

N,K,Q = map(int, input().split())
A =[int(input()) for _ in range(Q)]
ans =[]
for i in range(N):
    ans.append(A.count(i+1))
for i in range(N):
    if K - (Q-ans[i]) > 0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

N,K,Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
cnt =[0,]*N
for i in range(Q):
    cnt[(A[i]-1)] += 1
for i in range(N):
    if K-Q+cnt[i] > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
count=1
for i in range(n):
    count=count*a[i]
if count>10**18:
    print(-1)
else:
    print(count)

### FIXED CODE ###

n = int(input())
lis = list(map(int,input().split()))
ans = 1
if 0 in lis:
  print(0)
  exit()
for num in lis:
  ans *= num
  if ans > 10 ** 18:
    print(-1)
    exit()
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Wed Mar  4 19:06:03 2020

@author: Kanaru Sato
"""
import math

X = int(input())

target = X
flag = 0

while flag == 0:
    rootX = int(math.sqrt(X))
    for i in range(2, rootX+1):
        if X%i == 0:
            if X%2 == 0:
                X += 1
                break
            else:
                X += 2
                break
        elif i == rootX:
            flag = 1
            break
        else:
            continue

print(X)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Wed Mar  4 19:06:03 2020

@author: Kanaru Sato
"""
import math

X = int(input())

target = X
flag = 0

if X == 2 or X == 3:
    flag = 1

while flag == 0:
    rootX = int(math.sqrt(X))
    for i in range(2, rootX+1):
        if X%i == 0:
            if X%2 == 0:
                X += 1
                break
            else:
                X += 2
                break
        elif i == rootX:
            flag = 1
            break
        else:
            continue

print(X)
### BUGGY CODE ###

N = int(input())
A = input().split()
for i in range(N):
    count = A.count(str(i+1))
    print(count)

### FIXED CODE ###

import collections
N = int(input())
A = input().split()
count_dict = collections.Counter(A)
for i in range(N):
    count = count_dict[str(i+1)]
    print(count)
### BUGGY CODE ###

import copy
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=[copy.copy(a)]
for i in range(1,k+1):
    for j in range(n):
        mn=j-ans[i-1][j]
        mx=j+ans[i-1][j]
        if mn<0:
            mn=0
        if mx>n-1:
            mx=n-1
        ans.append([0]*n)
        for l in range(mn,mx+1):
            ans[i][l]+=1
L=[str(a) for a in ans[k]]
L=" ".join(L)
print(L)

### FIXED CODE ###

from numba import jit
N, K = map(int, input().split())
A = list(map(int, input().split()))

@jit
def solve(k,n,a):
    for _ in range(k):
        Y = [0]*(n+1)
        for i, x in enumerate(a):
            Y[max(0, i-x)] += 1
            Y[min(n, i+x+1)] -= 1
        for j in range(1, n):
            Y[j] += Y[j-1]
        if a == Y[:-1]:
            break
        a = Y[:-1]
    return a

ans=solve(K,N,A)
print(*ans)
### BUGGY CODE ###

N = int(input())
my_list = [None] * N
for i in range(N):
    s_i = input()
    my_dict = {}
    for j in range(10):
        if s_i[j] in my_dict:
            my_dict[s_i[j]] += 1
        else:
            my_dict[s_i[j]] = 1
    my_list[i] = my_dict
sum = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if my_list[i] == my_list[j]:
            sum += 1
print(sum)


### FIXED CODE ###

n = int(input())
dict = {}
ans = 0

for i in range(n):
    s = str(sorted(input()))
    if s in dict.keys():
        ans += dict[s]
        dict[s] += 1
    else:
        dict[s] = 1
print(ans)
### BUGGY CODE ###

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

list_A = []

for _ in range(q):
    i = int(input())
    list_A.append(i)

list_per = [k]*n

for i in list_A:
    i = i -1
    list_per = [x-1 for x in list_per]
    list_per[i] = list_per[i] + 1

for i in list_per:
    if i <=0:
        print("No")

    else:
        print("Yes")


### FIXED CODE ###

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

list_A = []

for _ in range(q):
    i = int(input())
    list_A.append(i)

list_per = [0]*n

for i in list_A:
    i = i - 1
    list_per[i] = list_per[i] + 1

for i in list_per:
    if k - q + i > 0:
        print("Yes")

    else:
        print("No")
### BUGGY CODE ###

n,k=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(n)]
x,y=[[xy[i][0],i] for i in range(n)],[[xy[i][1],i] for i in range(n)]
x.sort()
y.sort()
ans=10**18*4
for i1 in range(n):
    i1_sub=n-i1
    x_sub1=x[i1][0]
    for l1 in range(i1_sub,1,-1):
        x_sub2=x[i1+l1-1][0]
        for i2 in range(n):
            i2_sub=n-i2
            y_sub1=y[i2][0]
            for l2 in range(i2_sub,1,-1):
                y_sub2=y[i2+l2-1][0]
                z=[0]*n
                for i in range(n):
                    z[i]=(x_sub1<=xy[i][0]<=x_sub2 and y_sub1<=xy[i][1]<=y_sub2)
                if sum(z)>=k:
                    ans=min((x_sub2-x_sub1)*(y_sub2-y_sub1),ans)
                else:
                    break
print(ans)


### FIXED CODE ###

n,k=map(int,input().split())
x,y=[[0,0] for i in range(n)],[[0,0] for i in range(n)]
xy=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
    x_sub,y_sub=xy[i]
    x[i][0]=x_sub
    x[i][1]=i
    y[i][0]=y_sub
    y[i][1]=i
x.sort()
y.sort()
ans=(10**18)*5
for i1 in range(n):
    for l1 in range(n-i1,1,-1):
        for i2 in range(n):
            for l2 in range(n-i2,1,-1):
                x_sub1=x[i1][0]
                x_sub2=x[i1+l1-1][0]
                y_sub1=y[i2][0]
                y_sub2=y[i2+l2-1][0]
                z=[0]*n
                for i in range(n):
                    if x_sub1<=xy[i][0]<=x_sub2 and y_sub1<=xy[i][1]<=y_sub2:
                        z[i]=1
                if sum(z)>=k:
                    ans=min((x_sub2-x_sub1)*(y_sub2-y_sub1),ans)
                else:
                    break
print(ans)
### BUGGY CODE ###

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

def get_divisors(n):
    from math import ceil
    divisors = []
    for num in range(ceil(n**0.5), n+1):
        if n % num == 0:
            divisors.append(n//num)
            if n//num != n:
                divisors.append(num)
    divisors.sort(reverse=True)
    return divisors

total = sum(A)
divisors = get_divisors(total)
ans = -1
for d in divisors:
    R = [a%d for a in A]
    R.sort(reverse=True)
    pr = 0
    nr = -sum(R)
    for i, r in enumerate(R):
        pr += d-r
        nr += r
        if nr+pr >= 0:
            if pr <= K and nr+pr == 0:
                ans = d
            break
    if ans != -1:
        print(ans)
        break
else:
    print(1)


### FIXED CODE ###

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

# nの約数を求める。計算量O(sqrt(N))
def get_divisors(n):
    from math import sqrt, ceil
    from collections import deque
    divisors = deque([])
    for num in range(ceil(sqrt(n)), n+1):
        if n % num == 0:
            divisors.append(n//num)
            if n//num != n:
                divisors.appendleft(num)
    return list(divisors)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors

total = sum(A)
divisors = make_divisors(total)
ans = -1
for d in divisors:
    R = [a%d for a in A]
    R.sort(reverse=True)
    pr = 0
    nr = -sum(R)
    for i, r in enumerate(R):
        pr += d-r
        nr += r
        if nr+pr >= 0:
            if pr <= K and nr+pr == 0:
                ans = d
            break
    if ans != -1:
        print(ans)
        break
else:
    print(1)
### BUGGY CODE ###

k=int(input())
x=7
cnt=1
if k%2==0:
    print(-1)
else:
    while True:
        if x % k ==0:
            print(cnt)
            break
        elif cnt<10000000:
            x=(x+7*(10**cnt)%k)%k
            cnt+=1
        else:
            print(-1)
            break

### FIXED CODE ###

k=int(input())
x=7
cnt=1
if k%2==0:
    print(-1)
else:
    while True:
        if x%k ==0:
            print(cnt)
            break
        elif cnt<10000000:
            x=(x*10+7)%k
            cnt+=1
        else:
            print(-1)
            break
### BUGGY CODE ###

MAX = 5100000

MOD = 1000000007


def read_input():
    x, y = map(int, input().split(" "))
    return x, y


class BinomialCoefficients(object):
    def __init__(self, MAX=MAX, MOD=MOD):
        self.MOD = MOD
        self.fac = [1 for _ in range(MAX)]
        self.finv = [1 for _ in range(MAX)]
        self.inv = [1 for _ in range(MAX)]
        for i in range(2, MAX):
            self.fac[i] = self.fac[i - 1] * i % MOD
            self.inv[i] = MOD - self.inv[MOD % i] * (MOD // i) % MOD
            self.finv[i] = self.finv[i - 1] * self.inv[i] % MOD

    def calc(self, n, k):
        if n < k:
            return 0
        if n == 0 or k < 0:
            return 0
        return self.fac[n] * (self.finv[k] * self.finv[n - k] % self.MOD) % self.MOD


def ans(X, Y):
    a_3 = 2 * X - Y
    b_3 = 2 * Y - X
    if a_3 % 3 != 0 and b_3 % 3 != 0:
        return 0
    if a_3 < 0 or b_3 < 0:
        return 0
    a = a_3 // 3
    b = b_3 // 3

    c = BinomialCoefficients()
    return c.calc(a + b, a)


if __name__ == "__main__":
    X, Y = read_input()
    print(ans(X, Y))


### FIXED CODE ###

MAX = 5100000

MOD = 1000000007


def read_input():
    x, y = map(int, input().split(" "))
    return x, y


class BinomialCoefficients(object):
    def __init__(self, MAX=MAX, MOD=MOD):
        self.MOD = MOD
        self.fac = [1 for _ in range(MAX)]
        self.finv = [1 for _ in range(MAX)]
        self.inv = [1 for _ in range(MAX)]
        for i in range(2, MAX):
            self.fac[i] = self.fac[i - 1] * i % MOD
            self.inv[i] = MOD - self.inv[MOD % i] * (MOD // i) % MOD
            self.finv[i] = self.finv[i - 1] * self.inv[i] % MOD

    def calc(self, n, k):
        if n < k:
            return 0
        if n == 0 or k < 0:
            return 0
        return self.fac[n] * (self.finv[k] * self.finv[n - k] % self.MOD) % self.MOD


def ans(X, Y):
    a_3 = 2 * X - Y
    b_3 = 2 * Y - X
    if a_3 % 3 != 0 and b_3 % 3 != 0:
        return 0
    if a_3 < 0 or b_3 < 0:
        return 0
    a = a_3 // 3
    b = b_3 // 3

    c = BinomialCoefficients()
    return c.calc(a + b, a)


if __name__ == "__main__":
    X, Y = read_input()
    print(ans(X, Y))
### BUGGY CODE ###

# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

N=int(input())
a=list(map(int,input().split()))
calc=(lcm(a))  # 実行結果: 12

ans=0
for item in a:
    ans+=(calc)//item
    ans%=(10**9+7)

print(int((ans)%(10**9+7)))
    



### FIXED CODE ###

# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
import sys
input = sys.stdin.readline

import functools

def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)
def multiple(a, b):
    return a*b // euclid(a, b)
def lcm(nums):
        return functools.reduce(multiple, nums)


N=int(input())
a=list(map(int,input().split()))
calc=(lcm(a))  # 実行結果: 12


ans=0
for index,item in enumerate(a):
    ans+=(calc)//item

print(int((ans)%(10**9+7)))
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline

def main():
    n, k = map(int,input().split())
    h = list(map(int,input().split()))

    dp = [0]*n

    dp[1] = abs(h[1] - h[0])
    for i in range(2, n):
        dp[i] = dp[i-1] + abs(h[i] - h[i-1])
        for j in range(2, k+1):
            if i-j < 0:
                continue
            dp[i] = min(dp[i-j] + abs(h[i] - h[i-j]), dp[i])

    print(dp[-1])



if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

def main():
    n, k = map(int,input().split())
    h = list(map(int,input().split()))

    dp = [0]*n

    dp[1] = abs(h[1] - h[0])
    for i in range(2, n):
        dp[i] = dp[i-1] + abs(h[i] - h[i-1])
        for j in range(2, k+1):
            if i-j < 0:
                continue
            dp[i] = min(dp[i-j] + abs(h[i] - h[i-j]), dp[i])

    print(dp[-1])



if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys

def main():
    n = int(input())
    A = list(map(int, sys.stdin.readline().split()))

    ans = 1
    for i in range(n):
        ans *= A[i]

    if ans > 10 ** 18:
        print('-1')
    else:
        print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

def main():
    n = int(input())
    A = list(map(int, sys.stdin.readline().split()))

    ans = 1

    if 0 in A:
        print(0)
        sys.exit()

    for i in range(n):
        ans *= A[i]
        if ans > 10 ** 18:
            print('-1')
            sys.exit()

    print(ans)


if __name__ == '__main__':
    main()