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

import math , sys 
from collections import deque

N = int( input() )
Cs = list( map( int , input().split() ))
Cs.sort(reverse=True)

conf=0
#d=deque()
i=0
while len(Cs)>0:
    tar=Cs.pop(0)
    #print(tar,Cs)
    if i==0:
        conf+=tar
        #d.append(tar)
        i+=1
    elif i==1:
        #conf+=d[0]
        #d.append(tar)
        Ds=deque([tar,tar])
        i+=1
    else:
        #print(Ds,d)
        c=max(Ds)
        conf+=c
        ind=Ds.index(c)
        #d.insert(ind,tar)
        Ds.insert(ind,tar)
        Ds[ind+1]=tar
        #print(Ds,d)
print(conf)

### FIXED CODE ###

import math , sys 
from collections import deque

N = int( input() )
Cs = list( map( int , input().split() ))
Cs.sort(reverse=True)

ans = Cs.pop(0)
i = 1
Q  = (N-2)//2
R = (N-2) % 2
ans += sum([Cs[i]*2 for i in range(Q)])
if R==1:
    ans+=Cs[Q]
print(ans)
### BUGGY CODE ###

K = int(input())
c = 1
nana = 7
if K%2 == 0:
    print("-1")
else:
    while True:
        if nana%K == 0:
            print(c)
            break
        else:
            nana = (nana%K*10 + 7)%K
            c += 1

### FIXED CODE ###

K = int(input())
c = 1
nana = 7
if K%2 == 0:
    print("-1")
else:
    n = 7%K
    while True:
        i = nana%K
        if i == 0:
            print(c)
            break
        elif c >= 10**6:
            print("-1")
            break
        else:
            nana = (10*i+n)%K
            c += 1
### BUGGY CODE ###

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

if N % K ==0:
  print(0)
  exit()
  
ans = N
num = N//K
for i in range(num+1):
  N = abs(N-K)
  ans =min(ans,N)
  
  
print(ans)

### FIXED CODE ###

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

if N % K ==0:
  print(0)
  exit()
  
if N < K:
  print(min(N,K-N))
  exit()

if N > K:
  print(min(N%K,K-(N%K)))
### BUGGY CODE ###

n = int(input())

x = 0
for i in range(n+1):
    if (i**0.5) == int(i**0.5):
        x = i

print(x)


### FIXED CODE ###

n = int(input())

print((int(n**0.5))**2)
### BUGGY CODE ###

import numpy as np
X, Y, Z, K = [int(i) for i in input().split()]

A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)

Anum = 0
Bnum = 0
Cnum = 0

AB=[]
for i in range(X):
    for j in range(Y):
        AB.append(A[i]+B[j])

AB = sorted(AB, reverse=True)
AB = AB[:min(X*Y,K)]

ABC=[]
for i in range(len(AB)):
    for j in range(Z):
        ABC.append(AB[i]+C[j])

ABC = sorted(ABC, reverse=True)

for i in range(K):
    print(ABC[i])


### FIXED CODE ###

X, Y, Z, K = [int(i) for i in input().split()]

A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)

Anum = 0
Bnum = 0
Cnum = 0

AB = []
for i in range(X):
    for j in range(Y):
        AB.append(A[i]+B[j])

AB = sorted(AB, reverse=True)
AB = AB[:min(X*Y,K)]

ABC = []
for i in range(len(AB)):
    for j in range(Z):
        ABC.append(AB[i]+C[j])

ABC = sorted(ABC, reverse=True) 

for i in range(K):
    print(int(ABC[i]))
### BUGGY CODE ###

X=int(input())
i=2
li=1
while X**(1/i)>=2:
  s=int(X**(1/i))
  li=max(li,s**i)
print(li)

### FIXED CODE ###

X=int(input())
ans=1
for i in range(2,10):
  for j in range(2,X):
    if j**i<=X:
      ans=max(ans,j**i)
    else:
      break
print(ans)
### BUGGY CODE ###

import copy

N = int(input())

A = []
for _ in range(N):
    A.append(int(input()))


_max = max(A)

for i in range(N):
    if A[i] == _max:
        _A = copy.deepcopy(A)
        del _A[i]
        print(max(_A))

    else:
        print(_max)
        

### FIXED CODE ###

import copy

N = int(input())

A = []
for _ in range(N):
    A.append(int(input()))


max1 = max(A)

max_i = A.index(max1)
max2 = max(A[:max_i] + A[max_i+1:])


for i in range(N):
    if A[i] == max1:
        print(max2)

    else:
        print(max1)
### BUGGY CODE ###

abc = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
s = input()
x = [[float("inf") for i in range(26)] for j in range(len(s))]
for k in range(2):
    for i in range(len(s)-1,-1,-1):
        if i == 0:
            ib = len(s)-1
        else:
            ib = i-1
        for j in range(26):
            if j == ord(s[i])-97:
                x[ib][j] = i
            else:
                x[ib][j] = x[i][j]
t = input()
i = len(s)-1
count = 0
for j in range(len(t)):
    nxt = x[i][ord(t[j])-97]
    if nxt == float("inf"):
        print(-1)
        exit()
    elif nxt <= i:
        count += 1
        i = nxt
    else:
        i = nxt
print(len(s)*(count-1)+i+1)

### FIXED CODE ###

s = input()
ns = len(s)
x = {}
for i in range(len(s)):
    if s[i] in x:
        x[s[i]] += [i]
    else:
        x[s[i]] = [i]
t = input()
i = len(s)-1
count = 0
import bisect
for j in range(len(t)):
    if t[j] in x:
        ni = bisect.bisect_right(x[t[j]],i)
        if ni == len(x[t[j]]):
            i = x[t[j]][0]
            count += 1
        else:
            i = x[t[j]][ni]
    else:
        print(-1)
        exit()
    
print(len(s)*(count-1)+i+1)
### BUGGY CODE ###

import numpy as np

MOD = 10**9 + 7
s = input()
count = np.zeros(13, dtype = int)
count[0] = 1
for i in range(len(s)):
    new = np.zeros(13, dtype = int)
    for m in range(13):
        new[(m * 10) % 13] = count[m]
    count = np.copy(new)
    if s[i] != "?":
        div = int(s[i])
        count = np.concatenate([count[-div:], count[:-div]], 0)
    else:
        new = np.copy(count)
        for div in range(1, 10):
            new += np.concatenate([count[-div:], count[:-div]], 0)
        count = np.copy(new)
    count %= MOD
print(count[5])

### FIXED CODE ###

from copy import copy

MOD = 10**9 + 7
s = input()
count = [0 for _ in range(13)]
count[0] = 1
for i in range(len(s)):
    new = [0 for _ in range(13)]
    for m in range(13):
        new[(m * 10) % 13] = count[m]
    count = new
    if s[i] != "?":
        div = int(s[i])
        count = count[-div:] +  count[:-div]
    else:
        new = [0 for _ in range(13)]
        pre = sum(count[:3])
        SUM = sum(count) % MOD
        for j in range(13):
            pre += count[(j+3) % 13]
            pre -= count[j % 13]
            new[j] = (SUM - pre) % MOD
        count = new
print(count[5])
### BUGGY CODE ###

N = int(input())
A = tuple(map(int, input().split(" ")))
d = {i: (sum(A[:i]), sum(A[i:])) for i in range(N)}

print(min(abs(value[0] - value[1]) for key, value in d.items()))


### FIXED CODE ###

N = int(input())
A = tuple(map(int, input().split(" ")))

S = sum(A)
ans = S
s = 0
for i in range(N):
    s += A[i]
    ans = min(ans, abs(s - (S - s)))
print(ans)
### BUGGY CODE ###

n,p=map(int,input().split())
S=input()
ans=0
if p==5:
    for i in range(n):
        if int(S[i])==5 or int(S[i])==0:
            ans+=i+1
elif p==2:
    for i in range(n):
        if int(S[i])%2==0:
            ans+=i+1
else:
    kouho=[0]*p
    s=0
    for i in range(n):
        s+=int(S[-(i+1)])*(10**i)
        a=s%p
        kouho[a]+=1
    for j in range(p):
        z=kouho[j]
        ans+=z*(z-1)//2
    ans+=kouho[0]
print(ans)

### FIXED CODE ###

from collections import defaultdict
n,p=map(int,input().split())
S=input()
ans=0
if p==5:
    for i in range(n):
        if int(S[i])==5 or int(S[i])==0:
            ans+=i+1
elif p==2:
    for i in range(n):
        if int(S[i])%2==0:
            ans+=i+1
else:
    kouho=defaultdict(int)
    s=0
    ruijo=1
    for i in range(n):
        ruijo%=p
        s+=int(S[-(i+1)])*(ruijo)
        a=s%p
        kouho[a]+=1
        ruijo*=10
    for j in range(p):
        z=kouho[j]
        ans+=z*(z-1)//2
    ans+=kouho[0]
print(ans)
### BUGGY CODE ###

def resolve():
    number=1
    for i in range(1,int(input())+1):
        number*=i
    print(number%(10**9+7))
resolve()

### FIXED CODE ###

import math
print(math.factorial(int(input()))%(10**9+7))
### BUGGY CODE ###

D = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split()))for _ in range(D)]

SELECT = []
for i in range(D):
    SELECT.append(int(input())-1)

M = int(input())
d = []
q = []
for _ in range(M):
    td, tq = map(int,input().split())
    d.append(td-1)
    q.append(tq-1)

L_ALL = [[0]*26 for _ in range(D)]
L = [0]*26
ans = 0
for i in range(D):
    ans += S[i][SELECT[i]]
    L[SELECT[i]]=i+1
    if i != 0:
        L_ALL[i] = L_ALL[i-1][:]
    L_ALL[i][SELECT[i]] = i+1
    for j in range(26):
        ans -= C[j]*(i+1-L[j])

for i in range(M):
    day = d[i]
    before = SELECT[day]
    after = q[i]
    ans -= S[day][before]
    ans += S[day][after]
    SELECT[day] = q[i]

    if day == 0:
        tmp = 0
    else:
        tmp = L_ALL[day-1][before]
    j = day
    while 0<=j<D and L_ALL[j][before]==day+1:
        L_ALL[j][before] = tmp
        ans -= C[before]*(day+1-tmp)
        j += 1

    if day == 0:
        tmp = 0
    else:
        tmp = L_ALL[day-1][after]
    j = day
    while 0<=j<D and L_ALL[j][after]==tmp:
        L_ALL[j][after]=day+1
        ans += C[after] * (day+1-tmp)
        j += 1

    print(ans)

### FIXED CODE ###

def main():
    D = int(input())
    C = list(map(int,input().split()))
    S = [list(map(int,input().split()))for _ in range(D)]

    SELECT = []
    for i in range(D):
        SELECT.append(int(input())-1)

    M = int(input())
    d = []
    q = []
    for _ in range(M):
        td, tq = map(int,input().split())
        d.append(td-1)
        q.append(tq-1)

    L_ALL = [[0]*26 for _ in range(D)]
    L = [0]*26
    ans = 0
    for i in range(D):
        ans += S[i][SELECT[i]]
        L[SELECT[i]]=i+1
        if i != 0:
            L_ALL[i] = L_ALL[i-1][:]
        L_ALL[i][SELECT[i]] = i+1
        for j in range(26):
            ans -= C[j]*(i+1-L[j])

    for i in range(M):
        day = d[i]
        before = SELECT[day]
        after = q[i]
        ans -= S[day][before]
        ans += S[day][after]
        SELECT[day] = q[i]

        if day == 0:
            tmp = 0
        else:
            tmp = L_ALL[day-1][before]
        j = day
        while 0<=j<D and L_ALL[j][before]==day+1:
            L_ALL[j][before] = tmp
            ans -= C[before]*(day+1-tmp)
            j += 1

        if day == 0:
            tmp = 0
        else:
            tmp = L_ALL[day-1][after]
        j = day
        while 0<=j<D and L_ALL[j][after]==tmp:
            L_ALL[j][after]=day+1
            ans += C[after] * (day+1-tmp)
            j += 1

        print(ans)

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

n = 10**5
e = [True]*(n+1)
e[0] = False
e[1] = False
for i in range(2, int(n**0.5)+1):
    if not e[i]:
        continue
    for j in range(i*2, n+1, i):
        e[j] = False

q = int(input())
for _ in range(q):
    l, r = map(int, input().split())

    ans = 0
    for i in range(l, r+1, 2):
        if e[i] and e[(i+1)//2]:
            ans += 1
    print(ans)


### FIXED CODE ###

n = 10**5
e = [True]*(n+1)
e[0] = False
e[1] = False
for i in range(2, int(n**0.5)+1):
    if not e[i]:
        continue
    for j in range(i*2, n+1, i):
        e[j] = False

c = [0]*(n+2)
for i in range(3, n+1, 2):
    if e[i] and e[(i+1)//2]:
        c[i] += 1

for i in range(3, n+1):
    c[i] += c[i-1]

q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(c[r]-c[l-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from collections import deque

h, w = map(int, input().split())
ch, cw = map(int, input().split())
gh, gw = map(int, input().split())

s = []
for i in range(h):
   s.append(input().rstrip('\n'))

INF = 10 ** 10
d = [INF] * (h*w)

stack = deque([[ch-1, cw-1, 0]])
stack_append = stack.append
stack_popleft = stack.popleft

nex = []
for i in range(-2, 3):
    for j in range(-2, 3):
        if (i, j) in [(-1,0),(1,0),(0,-1),(0,1),(0,0)]:
            continue
        else:
            nex.append((i,j))

while stack:
    curh, curw, cnt = stack_popleft()
    if d[curh * w + curw] <= cnt:
        continue
    else:
        d[curh * w + curw] = cnt
    for dh, dw in ((-1,0), (1,0), (0,1), (0,-1)):
        nh = curh + dh
        nw = curw + dw
        if nh >= 0 and nh < h and nw >= 0 and nw < w and s[nh][nw] == '.':
            stack_append([nh, nw, cnt])
    for dh, dw in nex:
        nh = curh + dh
        nw = curw + dw
        if nh >= 0 and nh < h and nw >= 0 and nw < w and s[nh][nw] == '.':
            stack_append([nh, nw, cnt+1])

# for item in d:
#     print(item)
gh -= 1
gw -= 1

if d[gh*w + gw] == INF:
    print(-1)
else:
    print(d[gh*w + gw])

### FIXED CODE ###

import sys
input = sys.stdin.readline

import heapq

INF = 10 ** 10

def dijkstra(n, G, s):
    dist = [INF] * n
    dist[s] = 0
    h = []
    heapq.heappush(h, (0, s))

    while h:
        # 使っていない頂点のうち、現時点で最も距離の近いものを選びvとする
        d, v = heapq.heappop(h)
        if dist[v] < d:
            continue
        # vから到達可能な頂点について、距離が短くなれば更新
        for end, cost in G[v]:
            if dist[end] > dist[v] + cost:
                dist[end] = dist[v] + cost
                heapq.heappush(h, (dist[end], end))
    return dist


H, W = map(int, input().split())
N = H * W
ch, cw = map(lambda x:int(x)-1, input().split())
gh, gw = map(lambda x:int(x)-1, input().split())

s = []
es = tuple([] for i in range(N))

for h in range(H):
   s.append(input().rstrip('\n'))

for h in range(H):
    for w in range(W):
        if s[h][w] != '.':
            continue
        a = h*W+w
        esappend = es[a].append
        for dh in (-2, -1, 0, 1, 2):
            for dw in (-2, -1, 0, 1, 2):
                if dh == 0 and dw == 0:
                    continue
                nh = h + dh
                nw = w + dw
                if 0 <= nh and nh < H and 0 <= nw and nw < W and s[nh][nw] == '.':
                    b = nh*W+nw
                    if (dh, dw) in [(-1,0),(1,0),(0,-1),(0,1)]:
                        esappend((b, 0))
                    else:
                        esappend((b, 1))

dist = dijkstra(N, es, ch*W+cw)
if dist[gh*W+gw] == INF:
    print(-1)
else:
    print(dist[gh*W+gw])
### BUGGY CODE ###

import sys
inf = float('inf')

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N, Ma, Mb = map(int, input().split())
    a_w = []
    b_w = []
    costs = []

    for i in range(N):
        a, b, c = map(int, input().split())
        a_w.append(a)
        b_w.append(b)
        costs.append(c)

    dp = [[[inf]*(10*N + 1) for j in range(10*N + 1)]
            for k in range(2)]

    dp[0][0][0] = 0
    dp[1][0][0] = 0

    for i in range(N):
        for a in range(10*N + 1):
            for b in range(10*N + 1):
                dp[1][a][b] = dp[0][a][b]
                if a - a_w[i] >= 0 and b - b_w[i] >= 0:
                    dp[1][a][b] = min(dp[1][a][b],
                                      dp[0][a - a_w[i]][b - b_w[i]] + costs[i])
        
        for k in range(10*N + 1):
            dp[0][k] = dp[1][k][:]

    min_cost = inf

    for a in range(1, 10*N + 1):
        for b in range(1, 10*N + 1):
            if a * Mb == b * Ma:
                min_cost = min(min_cost, dp[1][a][b])

    if min_cost == inf:
        ans = -1
    else:
        ans = min_cost

    print(ans)


if __name__ == '__main__':
    solve()

### FIXED CODE ###

import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N, Ma, Mb = map(int, input().split())
    a_w = []
    b_w = []
    costs = []

    for i in range(N):
        a, b, c = map(int, input().split())
        a_w.append(a)
        b_w.append(b)
        costs.append(c)

    dp = [[[-1]*(10*N + 1) for j in range(10*N + 1)]
            for k in range(2)]

    dp[0][0][0] = 0
    dp[1][0][0] = 0

    for i in range(N):
        for a in range(10*N + 1):
            for b in range(10*N + 1):
                if a - a_w[i] >= 0 and b - b_w[i] >= 0:
                    if dp[0][a - a_w[i]][b - b_w[i]] >= 0:
                        if dp[1][a][b] == -1:
                            dp[1][a][b]= dp[0][a - a_w[i]][b - b_w[i]] + costs[i]
                        else:
                            min_ = min(dp[1][a][b],
                                       dp[0][a - a_w[i]][b - b_w[i]] + costs[i])
                            dp[1][a][b] = min_
        
        for k in range(10*N + 1):
            dp[0][k] = dp[1][k][:]

        # for i in range(10*N + 1):
            # print(*dp[0][i], file=sys.stderr)


    min_cost = float('inf')

    for a in range(10*N + 1):
        for b in range(10*N + 1):
            if a != 0 and b != 0:
                if a * Mb == b * Ma and dp[1][a][b] > 0:
                    min_cost = min(min_cost, dp[1][a][b])

    if min_cost == float('inf'):
        ans = -1
    else:
        ans = min_cost

    print(ans)


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

n = int(input())
unsorted_blocks = []
for i in range(n):
    w_str, s_str, v_str = input().split(" ")
    w, s, v = int(w_str), int(s_str), int(v_str)
    unsorted_blocks.append({"w": w, "s": s, "v": v})

blocks = sorted(unsorted_blocks, key=lambda block: block["s"]) 

def dp(blocks, max_s):
    max_val = 0
    for i in range(len(blocks)):
        taken =  blocks[i]

        # klo constraint nya
        new_max_s = 0
        if max_s is None:
            new_max_s = taken["s"]
        else:
            new_max_s = min(max_s-taken["w"], taken["s"])

        # ini constraint nya
        if new_max_s < 0:
            continue

        # remaining blocks, taruh sini, biar ga diitung kalau jelas ga mungkin
        remaining_blocks = [blocks[x] for x in range(len(blocks)) if x != i and blocks[x]["w"] <= new_max_s]

        # ini nilai tambahan
        taken_val = taken["v"]
        new_val = taken_val + dp(remaining_blocks, new_max_s)
        if new_val > max_val:
            max_val = new_val

    return max_val

print(dp(blocks, None))

### FIXED CODE ###

import numpy as np
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
N = int(input())
WSV = list(tuple(map(int, input().split())) for _ in range(N))
WSV.sort(key=lambda x: x[0] + x[1])
U = 2 * 10 ** 4 + 100
dp = np.zeros(U, dtype=np.int64)
for w, s, v in WSV:
    dp[w:w+s+1] = np.maximum(dp[w:w+s+1], dp[:s+1] + v)
print(dp.max())
### BUGGY CODE ###

"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd
import sys
#input = sys.stdin.readline

import copy
"""
N=int(input())
P=list(map(int,input().split()))
for i in range(N):
    P[i]-=1
A=[30000*i for i in range(1,N+1)]
B=list(reversed(A))


lst=set([P[0]])
for i in range(1,N):
    for m in lst:
        B[m]-=1
    lst.add(P[i])

print(" ".join([str(i) for i in A]))
print(" ".join([str(i) for i in B]))


### FIXED CODE ###

"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd
import sys
#input = sys.stdin.readline

import copy
"""
N=int(input())
P=list(map(int,input().split()))
for i in range(N):
    P[i]-=1
A=[30000*i for i in range(1,N+1)]
B=list(reversed(A))
ruiA=[]
ruiB=[]


#lst=set(P[1:])
count=1
for i in range(0,N)[::-1]:
    B[P[i]]-=count
    """for m in lst:
        B[m]-=1
    lst.add(P[i])"""
    count+=1

print(" ".join([str(i) for i in A]))
print(" ".join([str(i) for i in B]))
### BUGGY CODE ###

def prime(n):
    primes = [0, 1] * (n // 2 + 1)
    if n % 2 == 0:
        primes.pop()
    primes[1] = 0
    primes[2] = 1
    for p in range(3, n + 1, 2):
        if primes[p]:
            for q in range(p * p, n + 1, 2 * p):
                primes[q] = 0
    return primes
pp=prime(10**3)
p=[]
for i in range(2,1001):
  if pp[i]:
    p.append(i)
n=int(input())
a=list(map(int,input().split()))
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x

g=a[0]
for i in a[1:]:
  g=gcd(g,i)
if g==1:
  mm=[0 for i in range(10**6+1)]
  f=True
  for i in a:
    if mm[i] and i!=1:
      f=False
      break
    mm[i]=1
    for j in range(168):
      if i%p[j]==0 and i!=p[j]:
        if mm[p[j]]:
          f=False
          break
        mm[p[j]]=1
        t=i//p[j]
        if mm[t] and t!=p[j]:
          f=False
          break
        mm[t]=1
    if not f:
      break
  if f:
    print("pairwise coprime")
  else:
    print("setwise coprime")
else:
  print("not coprime")
      

### FIXED CODE ###

def prime(n):
    primes = [0, 1] * (n // 2 + 1)
    if n % 2 == 0:
        primes.pop()
    primes[1] = 0
    primes[2] = 1
    for p in range(3, n + 1, 2):
        if primes[p]:
            for q in range(p * p, n + 1, 2 * p):
                primes[q] = 0
    return primes
pp=prime(10**3)
p=[]
for i in range(2,1001):
  if pp[i]:
    p.append(i)
n=int(input())
a=list(map(int,input().split()))
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x

g=a[0]
for i in a[1:]:
  g=gcd(g,i)
if g==1:
  mm=[0 for i in range(10**6+1)]
  f=True
  for i in a:
    if mm[i] and i!=1:
      f=False
      break
    mm[i]=1
    si=i**0.5
    for j in range(168):
      if p[j]>si:
        break
      if i%p[j]==0 and i!=p[j]:
        if mm[p[j]]:
          f=False
          break
        mm[p[j]]=1
        t=i//p[j]
        if mm[t] and t!=p[j]:
          f=False
          break
        mm[t]=1
    if not f:
      break
  if f:
    print("pairwise coprime")
  else:
    print("setwise coprime")
else:
  print("not coprime")
### BUGGY CODE ###


def main():
    import sys
    import math
    def input():
        return sys.stdin.readline()[:-1]
    N=int(input())
    A=list(map(int,input().split()))
    c=1
    for x in A:
        c=c*x
    
    if c>10**18:
        print(-1)
        sys.exit()

    print(c)
if __name__ == '__main__':
    main()


### FIXED CODE ###


def main():
    import sys
    import math
    def input():
        return sys.stdin.readline()[:-1]
    N=int(input())
    A=list(map(int,input().split()))
    c=1
    if 0 in A:
        print(0)
        sys.exit()
        
    for x in A:     
        c=c*x
        if c>10**18:
            print(-1)
            sys.exit()

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

#abc066d
mod=10**9+7
def combi(n,r,mod):
 return fact[n]*pow(fact[r],mod-2,mod)*pow(fact[n-r],mod-2,mod)
fact=[1]
for i in range(1,10**6):
 fact.append(i*fact[-1]%mod)

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

N=int(raw_input())
A=map(int,raw_input().split())
c=[-1]*N
for i in range(N+1):
 if c[A[i]-1]!=-1:
  break
 c[A[i]-1]=i
j=c[A[i]-1]
i=N-i
for k in range(1,N+2):
 res=comb(N+1,k,mod)
 if k-1<=i+j:
  res-=comb(i+j,k-1,mod)
 print res%mod


### FIXED CODE ###

#abc066d
mod=10**9+7
fact=[1]*(10**5+2)
for n in range(1,10**5+2):
 fact[n]=n*fact[n-1]%mod

def com(n,k,m):
 return fact[n]*pow(fact[k],m-2,m)*pow(fact[n-k],m-2,m)%m

N=int(raw_input())
A=map(int,raw_input().split())
c=[-1]*N
for i in range(N+1):
 if c[A[i]-1]!=-1:
  break
 c[A[i]-1]=i
j=c[A[i]-1]
i=N-i
for k in range(1,N+2):
 res=com(N+1,k,mod)
 if k-1<=i+j:
  res-=com(i+j,k-1,mod)
 print res%mod