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

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

b = []

for i in range(len(a)):
    b.append(str(a[i]))
    b.reverse()

print(' '.join(b))


### FIXED CODE ###

from collections import deque

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

b = deque()

for i in range(len(a)):
    if i % 2 == 0:
        b.append(str(a[i]))
    else:
        b.appendleft(str(a[i]))
    last = i

if last % 2 == 0:
    b.reverse()

print(' '.join(b))
### BUGGY CODE ###

import math
def factoring(n,dict_count = {}):
    sup = math.floor(pow(n,1/2))
    n_new = n
    for i in range(2,sup + 1):
        if n % i == 0:
            n_new = n // i
            if i in dict_count:
                dict_count[i] += 1
            else:
                dict_count[i] = 1
            break
    if n == n_new:
        if n_new in dict_count:
            dict_count[n_new] += 1
        else:
            dict_count[n_new] = 1
        return sorted(list(dict_count.items()))
    return factoring(n_new,dict_count)

# 組み合わせ　n_C_r
import math
def comb(n,r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))

N,M = map(int,input().split())
if M == 1:
    print(1)
    exit()
ans = 1
for a,b in factoring(M):
    ans *= comb(b+N-1,b)
    ans %= 10**9 + 7
print(ans)

### FIXED CODE ###

# 素因数分解 ソート済みリスト (素因数,指数)
import math
def factoring(n,dict_count = {}):
    sup = math.floor(pow(n,1/2))
    n_new = n
    for i in range(2,sup + 1):
        if n % i == 0:
            n_new = n // i
            if i in dict_count:
                dict_count[i] += 1
            else:
                dict_count[i] = 1
            break
    if n == n_new:
        if n_new in dict_count:
            dict_count[n_new] += 1
        else:
            dict_count[n_new] = 1
        return sorted(list(dict_count.items()))
    return factoring(n_new,dict_count)

def comb(n,r):
    r = min(r,n-r)
    result = 1
    for i in range(n-r+1,n+1):
        result *= i
    for i in range(1,r+1):
        result //= i
    return result

N,M = map(int,input().split())
if M == 1:
    print(1)
    exit()
ans = 1
for a,b in factoring(M):
    ans *= comb(b+N-1,b)
    ans %= 10**9 + 7
print(ans)
### BUGGY CODE ###

n = int(input())
s = input()

check_list = [ [ 0 for i in range(n) ] for i in range(n) ]


ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        q = check_list[i][j]
        p = check_list[i][j]
        for k in range(min(j-i-q,n-1-j+1-q)):
            if s[i+q+k] == s[j+q+k]:
                p += 1
            else:
                break
        if p > q:
            for k in range(1,p):
                check_list[i+k][j+k] = p - k
        ans = max(ans,p)

print(ans)

### FIXED CODE ###

n = int(input())
s = input()

check_list = [ [ 0 for i in range(n) ] for i in range(n) ]


ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        if check_list[i][j] == 0:
            p = 0
            for k in range(min(j-i,n-1-j+1)):
                if s[i+k] == s[j+k]:
                    p += 1
                else:
                    break
            for k in range(1,p):
                check_list[i+k][j+k] = p - k
        ans = max(ans,p)

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

T = str(input())

for i in range(len(T)):
    if T[i] == '?':
        T = T[:i] + 'D' + T[i+1:]
print(T)

### FIXED CODE ###

T = str(input())
print(T.replace('?', 'D'))
### BUGGY CODE ###

anum,bnum,acc = map(int,input().split())
alist = list(map(int,input().split()))
blist = list(map(int,input().split()))


ans = 0;a = 0;b = 0
while sum(alist[:a+1]) <= acc:
    if a == anum:
        break
    a += 1

while sum(alist[:a]+blist[:b+1]) <= acc:
    if b == bnum:
        break
    b += 1

if a == 0 and b == 0:
    pass
else:
    ans = a+b
    for i in range(1,a):
        while sum(alist[:a-i]+blist[:b+1]) <= acc:
            if b == bnum:
                break
            b += 1
            if a + b > ans:
                ans = a + b

print(ans)


### FIXED CODE ###

anum,bnum,acc = map(int,input().split())
alist = list(map(int,input().split()))
blist = list(map(int,input().split()))

asum = [0]
bsum = [0]
ans = 0
for i in range(anum):
    asum.append(asum[i]+alist[i])
for i in range(bnum):
    bsum.append(bsum[i]+blist[i])

b = bnum
for a in range(anum+1):
    if asum[a] > acc:
        break
    while asum[a] + bsum[b] > acc:
        b -=1
    ans = max(ans,a+b)

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

n, m = map(int, input().split())
cand_path = [tuple(map(int, input().split())) for _ in range(m)]

ans = 'IMPOSSIBLE'

for i in range(2, n):
  path = [1, n]
  path.insert(1, i)
  if len([True for x in zip(path, path[1:]) if x in cand_path])==2:
    ans = 'POSSIBLE'
    break
    
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
all_cand = [tuple(map(int, input().split())) for _ in range(m)]

start_path_end = set([path[1] for path in all_cand if path[0]==1])
end_path_start = set([path[0] for path in all_cand if path[1]==n])

print('POSSIBLE' if start_path_end&end_path_start else 'IMPOSSIBLE')
### BUGGY CODE ###

import math
import copy

N = int(input())
As = input().split()
A = [0 for i in range(N)]
for i in range(N):
  A[i] = int(As[i])

# count number of each label appearing
labels = {}
for i,A_i in enumerate(A):
  if A_i in labels:
    labels[A_i] += 1
  else:
    labels[A_i] = 1

answer = [-1 for i in range(N)]
spoiler = {}
for k in range(N):
  if A[k] in spoiler:
    answer[k] = spoiler[A[k]]
  else:
    labels[A[k]] -= 1
    appnums = list(labels.values())
    answer[k] = 0
    for appnum in appnums:
      if appnum>1: answer[k] += int(appnum*(appnum-1)/2)
    spoiler[A[k]] = answer[k]
    labels[A[k]] += 1

for k in range(N):
  print(answer[k])


### FIXED CODE ###

import math
import copy
import numpy as np

N = int(input())
As = input().split()
A = [0 for i in range(N)]
for i in range(N):
  A[i] = int(As[i])

# relabel A's elements
A_unique = list(set(A))
num_unique = len(A_unique)
to_unique = {}
for i,a in enumerate(A_unique):
  to_unique[a] = i
for i in range(N):
  A[i] = to_unique[A[i]]

# count number of each label appearing
counts = [0 for i in range(num_unique)]
for _,A_i in enumerate(A):
  counts[A_i] += 1
answer_total = 0
for count in counts:
  answer_total += int(count*(count-1)/2)

spoiler = [-1 for i in range(num_unique)]
for k in range(N):
  if spoiler[A[k]]<0:
    answer_k = answer_total - (counts[A[k]]-1)
    spoiler[A[k]] = answer_k
  else:
    answer_k = spoiler[A[k]]
  print(answer_k)
### BUGGY CODE ###

n = int(input())
l = []
for i in range(n):
    l.append(int(input()))
for i in range(n):
    print(max(l[:i]+l[i+1:]))

### FIXED CODE ###

n = int(input())
l = []
for i in range(n):
    l.append(int(input()))
l2 = sorted(l)
a1 = l2[-1]
a2 = l2[-2]
for i in l:
    if i == a1:
        print(a2)
    else:
        print(a1)
### BUGGY CODE ###

S = list(input())
N = len(S)
num = 0
cnt = [0]*2019
cnt[0] = 1
#T[i]: i+1文字目以降を数とみなしたときの数
for i in range(N-1, -1, -1):
    num = (num + int(S[i]) * 10 ** (N- i -1)) % 2019
    cnt[num] += 1

ans = 0
for c in cnt:
    ans += c * (c-1) // 2
print(ans)

### FIXED CODE ###

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d %= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
### BUGGY CODE ###

L = int(input())
A = [int(input()) for _ in range(L)]

def cost(k, a):
    if a % 2:
        a = 1
    elif a >= 2:
        a = 2

    if k == 0 or k == 4:
        return a

    if k == 1 or k == 3:
        return 2 - a

    return 1 - a % 2

dp = [[10**18] * 5 for _ in range(L + 1)]
dp[0][0] = 0

for i, a in enumerate(A, start=1):
    for j in range(5):
        for k in range(j, 5):
            b = dp[i - 1][j] + cost(k, a)
            if dp[i][k] > b:
                dp[i][k] = b

ans = min(dp[L])
print(ans)

### FIXED CODE ###

L = int(input())
B = [int(input()) for _ in range(L)]

A = []
for b in B:
    if b % 2:
        A.append(1)
    else:
        A.append(0 if b == 0 else 2)

dpLBack = [10**10] * (L + 1)
dpLBack[0] = 0
cnt = 0
for i, a in enumerate(A, start=1):
    cnt += B[i - 1]
    dpLBack[i] = min(dpLBack[i - 1] + 2 - a, cnt)

dpL = [10**10] * (L + 1)
dpL[0] = 0
cnt = 0
for i, a in enumerate(A, start=1):
    cnt += B[i - 1]
    dpL[i] = min(dpL[i - 1] + (a != 1), dpLBack[i - 1] + (a == 0), cnt)

dpRBack = [10**10] * (L + 1)
dpRBack[0] = 0
cnt = 0
for i, a in enumerate(A[:: -1], start=1):
    cnt += B[-i]
    dpRBack[i] = min(dpRBack[i - 1] + 2 - a, cnt)

dpR = [10**10] * (L + 1)
dpR[0] = 0
cnt = 0
for i, a in enumerate(A[:: -1], start=1):
    cnt += B[-i]
    dpR[i] = min(dpR[i - 1] + (a != 1), dpRBack[i - 1] + (a == 0), cnt)

dpR = dpR[:: -1]
dpRBack = dpRBack[::-1]

ans = min(dpL[L], dpR[0])
for mid in range(L + 1):
    ans = min(ans, dpL[mid] + dpRBack[mid], dpLBack[mid] + dpR[mid], dpLBack[mid] + dpRBack[mid])

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

n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
  f = True
  for j in a[i:]+a[:i]:
    if f:
      ans[i] += j
      f = False
    else:
      ans[i] -= j
      f = True
print(*ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
ans[0] = sum(a[::2]) - sum(a[1::2])
for i in range(1,n):
  ans[i] = a[i-1] * 2 - ans[i-1]
print(*ans)
### BUGGY CODE ###

n=int(input())
ls=sorted(["".join(sorted(list(input()))) for i in range(n)])
ls_set=sorted(list(set(ls)))

count=0
for i in ls_set:
    c=ls.count(i)
    count+=c*(c-1)/2
    ls=ls[c:]
print(int(count))

### FIXED CODE ###

n=int(input())
ls=sorted(["".join(sorted(list(input()))) for i in range(n)])

count=0
c=0
prev=ls[0]
for i,name in enumerate(ls):
    if name!=prev:
        count+=c*(c-1)/2
        c=0
        prev=name
    if i==n-1:
        if name==prev:
            c+=1
        count+=c*(c-1)/2
        c=0
        prev=name
    c+=1

print(int(count))
### BUGGY CODE ###

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

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

for i in range(M):
    A.sort()
    b, c = map(int, input().split())
    for j in range(b):
        if A[j] < c:
            A[j] = c

ans = sum(A)
print(ans)

### FIXED CODE ###

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

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

count = 0
BC = []
for i in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))

A.sort()
BC.sort(reverse=True, key=lambda x: x[1])

count = 0
CArr = []
for b, c in BC:
    if count >= N:
        break
    for i in range(b):
        CArr.append(c)
        count += 1
        if count >= N:
            break

for i in range(len(CArr)):
    if A[i] < CArr[i]:
        A[i] = CArr[i]

ans = sum(A)
print(ans)
### BUGGY CODE ###

import heapq
def SME(start,end):
    if end > N : end = N
    count = 0
    for i,x in enumerate(Whole[start:end]):
        heapq.heappush(A,[x,i])
    for j in range(start,end):
        a = heapq.heappop(A)
        if None not in ANS[a[1]:a[1]+L] : continue
        for i in range(L):
            idx = a[1] + i
            try :
                if ANS[idx] : continue
                else :
                    ANS[idx] = a[0]
                    count += 1
            except IndexError : continue
        if count > N * parameter : break
    for i in range(L):
        if ANS[i] : continue
        else : ANS[i] = min(Whole[:i+1])
    i = L
    while i < N :
        if None not in ANS[i:i+10] :
            i += 5
            continue
        if ANS[i] : continue
        else: ANS[i] = min(Whole[i+1-L:i+1])
        i+=1
    return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
parameter = 0.999
ANS = [None]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

N = int(input())
A = [int(x) for x in input().split()]
A.sort()
Al=list(set(A))
Al.sort(reverse = True)
HW = []
for i in Al:
  n = A.count(i)
  for j in range(min(n//2,2)):
    HW.append(i)
  if len(HW)>=2:
    break
HW = HW + [0,0]
print(HW[0]*HW[1])

### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse = True)
HW = []
i = 1
while i<N:
  if A[i]==A[i-1]:
    n = A.count(A[i])
    HW += [A[i]]*(min(n//2,2))
    i = i + n -1
  else:
    i = i + 1
  if len(HW)>=2:
    break
if len(HW)<2:
  print(0)
else:
  print(HW[0]*HW[1])
### BUGGY CODE ###

import sys

N = int(sys.stdin.readline())
print(sum(n + 1 for n in range(N - 1)))


### FIXED CODE ###

import sys

N = int(sys.stdin.readline())
print(int((N - 1) * N // 2))
### BUGGY CODE ###

from itertools import permutations

N,M,R=map(int,input().split())
r=[int(x) for x in input().split()]

INF=10**20
d=[[INF for x in range(N)] for y in range(N)]

for i in range(M):
  a,b,c=map(int,input().split())
  d[a-1][b-1]=c
  d[b-1][a-1]=c

for i in range(N):
  for j in range(N):
    for k in range(N):
      if d[j][i]+d[i][k] < d[j][k]:
        d[j][k]=d[j][i]+d[i][k]

ans=INF
for root in permutations(r):
  cnt=0
  for i in range(len(root)-1):
    cnt+=d[root[i]-1][root[i+1]-1]
    if cnt>ans:
      break
  ans=min(ans,cnt)
print(ans)


### FIXED CODE ###

from itertools import permutations

N,M,R=map(int,input().split())
r=[int(x) for x in input().split()]

INF=float('inf')
d=[[INF for x in range(N)] for y in range(N)]

for i in range(M):
  a,b,c=map(int,input().split())
  d[a-1][b-1]=c
  d[b-1][a-1]=c

for i in range(N):
  for j in range(N):
    for k in range(N):
      if d[j][i]+d[i][k] < d[j][k]:
        d[j][k]=d[j][i]+d[i][k]

ans=INF
for root in permutations(r):
  cnt=0
  for i in range(R-1):
    cnt+=d[root[i]-1][root[i+1]-1]
    if cnt>ans:
      break
  ans=min(ans,cnt)
print(ans)
### BUGGY CODE ###

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

def floor(x):
    out = (A * x)//B - A * (x//B)
    return out

max = 0
for i in range(N//2, N + 1):
    if(floor(i) > max):
        max = floor(i)


print(max)



### FIXED CODE ###

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

def floor(x):
    out = (A * x)//B - A * (x//B)
    return out

max = 0
#for i in range(N//2, N + 1):
    #if(floor(i) > max):
        #max = floor(i)

if(N < (B-1)):
    max = floor(N)
else:
    max = floor(B-1)

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

#from collections import defaultdict 
import copy
A,B = map(int, input().split())

num = min(A,B)
tmps = {}
p = 2
while p <= num:
    if A % p == 0 and B % p == 0:
        tmps[p] = True
    p += 1

#print(tmps)
d = copy.deepcopy(tmps)
for k in tmps.keys():
    if d.get(k, False):
        aaa = copy.deepcopy(d)
        for n in d.keys():
            if k == n:
                continue
            if n > k and n % k == 0:
                aaa.pop(n)
        d = aaa

print(len(d.keys())+1)


### FIXED CODE ###

#from collections import defaultdict 
import copy
import math
A,B = map(int, input().split())

num = min(A,B)
tmps = {}
p = 2
for p in range(2, math.ceil(num**0.5)+1):

    if A % p == 0 and B % p == 0:
        tmps[p] = True

    if A % (num//p) == 0 and B % (num//p) == 0:
        tmps[num//p] = True

    p += 1

if num != 1 and  A % num == 0 and B % num == 0:
    tmps[num] = True


d = copy.deepcopy(tmps)
for k in tmps.keys():

    if d.get(k, False):
        aaa = copy.deepcopy(d)
        for n in d.keys():
            if k == n:
                continue
            if n > k and n % k == 0:
                aaa.pop(n)
        d = aaa

print(len(d.keys())+1)
### BUGGY CODE ###

N = int(input())
S = str(input())
import itertools

l = list(S)
ans = 0
for a,b,c in itertools.combinations_with_replacement(range(N), 3):
  if (l[a]!=l[b]) and (l[b]!=l[c]) and (l[c]!=l[a]) and (b-a!=c-b):
    ans += 1
        
print(ans)


### FIXED CODE ###

N = int(input())
S = str(input())

l = list(S)
ans = l.count('R')*l.count('G')*l.count('B')
for i in range(N-2):
  a = l[i]
  for j in range(1, (N+1-i)//2):
    b, c = l[i+j], l[i+2*j]
    if (a!=b) and (b!=c) and (c!=a):
      ans -= 1
        
print(ans)
### BUGGY CODE ###

import numpy as np
def f(X,A):
    temp_f = np.array([X^A[i] for i in range(len(A))])
    return np.sum(temp_f)
def calc_max_f(A,K):
    temp_max_f = np.array([f(k,A) for k in range(0,K+1)])
    return np.max(temp_max_f)
N,K = (int(x) for x in input().split())
A = [int(x) for x in input().split()]
print(calc_max_f(A,K))

### FIXED CODE ###

import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))
"""
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
max_A = max(A)
bit = bin(K)
if max_A > K:
    bit = bin(max_A)"""
max_f = 0
#for d in range(1,len(bit))[::-1]:
for d in range(41,-2,-1):
    #d=d-2
    if (d != -1 and not (K & 1 << d)):
        continue
    f=0
    #for e in range(2,len(bit))[::-1]:
    for e in range(41,-1,-1):
        #e=e-2
        mask = 1<<e
        num=0
        for a in A:
            if a&mask:
                num+=1
        n_num = N - num
        if e>d:
            if K&mask:
                f += mask*n_num
            else:
                f += mask*num
        elif e==d:
            f += mask*num
        else:
            f += mask*max(n_num,num)
    max_f = max(f,max_f)
print(max_f)
### BUGGY CODE ###

n = int(input())
s = input()
l = n//2
ans = 0

for i in range(1,l+1)[::-1]:
    for j in range(n-i*2+1):
        if s[j:i+j] in s[i+j:]:
            ans = i
            break
    else:
        continue
    break
print(ans)

### FIXED CODE ###

n = int(input())
s = input()
high = n//2
low = 1
ans = 0

while low <= high:
    t = set()
    i = (high+low)//2
    for j in range(n-i*2+1):
        t.add(s[j:i+j])
        if s[i+j:j+2*i] in t:
            if ans < i:
                ans = i
                low = i+1
                break
    if ans < i:
        high = i-1
print(ans)
### BUGGY CODE ###

h,w=map(int,input().split())
data=[list(input()) for i in range(h)]
yoko=[[0]*w for i in range(h)]
for i in range(h):
	j=0
	while j <w:
		if data[i][j]=='#':
			j+=1
		else:
			start=j
			while j<w-1:
				j+=1
				if data[i][j]=='#':
					for k in range(start,j):
						yoko[i][k]=j-start-1
					j+=1
					break
			else:
				j+=1
				for k in range(start,j):
					yoko[i][k]=j-start-1
				j+=1
# for i in range(h):
# 	print(yoko[i])

for j in range(w):
	i=0
	while i <h:
		if data[i][j]=='#':
			i+=1
		else:
			start=i
			while i<h-1:
				i+=1
				if data[i][j]=='#':
					for k in range(start,i):
						yoko[k][j]+=i-start-1
					i+=1
					break
			else:
				i+=1
				for k in range(start,i):
					yoko[k][j]+=i-start-1
				i+=1

# print(yoko)
for i in range(h):
	# print(yoko[i])
	yoko[i]=max(yoko[i])
print(max(yoko)+1)







### FIXED CODE ###

h,w=map(int,input().split())
data=[list(input()) for i in range(h)]
yoko=[[0]*w for i in range(h)]
for i in range(h):
	j=0
	while j <w:
		if data[i][j]=='#':
			j+=1
		else:
			start=j
			while j<w-1:
				j+=1
				if data[i][j]=='#':
					for k in range(start,j):
						yoko[i][k]=j-start-1
					j+=1
					break
			else:
				j+=1
				for k in range(start,j):
					yoko[i][k]=j-start-1
				j+=1
# for i in range(h):
# 	print(yoko[i])

for j in range(w):
	i=0
	while i <h:
		if data[i][j]=='#':
			i+=1
		else:
			start=i
			while i<h-1:
				i+=1
				if data[i][j]=='#':
					for k in range(start,i):
						yoko[k][j]+=i-start-1
					i+=1
					break
			else:
				i+=1
				for k in range(start,i):
					yoko[k][j]+=i-start-1
				i+=1

# print(yoko)
for i in range(h):
	# print(yoko[i])
	yoko[i]=max(yoko[i])
print(max(yoko)+1)
### BUGGY CODE ###

def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    ans = 1
    for i in inlis:
        ans *= i
        #print(ans)
    if ans > 10 ** 18:
        ans = -1
    print(ans)
    



if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    from sys import stdin
    input = stdin.readline
    n = int(input())
    inlis = list(map(int, input().split()))
    if 0 in inlis:
        ans = 0
    else:
        ans = 1
        for i in inlis:
            ans *= i
            #print(ans)
            if ans > 10 ** 18:
                ans = -1
                break
    print(ans)
    
 
 
 
if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
an = [int(num) for num in input().split()]

answer = an[0]
check = 10**18
for i in range(1,len(an)) :
  answer *= an[i]

if answer <= check:
  print(answer)
else :
  print(-1)

### FIXED CODE ###

import sys

n = int(input())
an = [int(num) for num in input().split()]

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

answer = 1
check = 10**18
for i in range(len(an)) :
  answer *= an[i]
  if answer > check:
    print(-1)
    sys.exit()

print(answer)
### BUGGY CODE ###

n, q = map(int, input().split())
tl = [list() for _ in range(n)]
ab = []
ans = [0] * n

for i in range(n-1):
    a, b = map(int, input().split())
    ab.append((a, b))

ab.sort(reverse=True)

for a, b in ab:
    a -= 1
    b -= 1
    tl[a].append(b)
    tl[a].extend(tl[b])

for i in range(q):
    p, x = map(int, input().split())
    ans[p-1] += x
    for num in tl[p-1]:
        ans[num] += x

print(" ".join(map(str, ans)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
 
n, q = map(int, input().split())
tl = [list() for _ in range(n)]
xl = [0] * n
ans = [0] * n
 
for i in range(n-1):
    a, b = map(int, input().split())
    tl[a-1].append(b-1)
    tl[b-1].append(a-1)
 
for i in range(q):
    p, x = map(int, input().split())
    xl[p-1] += x

def rec(p, parent, x):
    x += xl[p]
    ans[p] = x
    for num in tl[p]:
        if num == parent: continue
        rec(num, p, x)

rec(0, -1, 0)
 
print(*ans)