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

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

MultipliedNum=1
index=0

for i in Alist:
    MultipliedNum*=i
    

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

### FIXED CODE ###

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

MultipliedNum=1
index=0

if min(Alist)==0:
    print(0)
    index=1

else:
    for i in Alist:
        MultipliedNum*=i

        if MultipliedNum>10**18:
            print(-1)
            index=1
            break
            
if index==0:
    print(MultipliedNum)
### BUGGY CODE ###

N = int(input())
s = []
count=0

for i in range(N):
  s.append("".join(sorted(input())))
  
duplicate_list =sorted(set(s), key=s.index)

for i in range (len(duplicate_list)):
  for j in range (s.count(duplicate_list[i])):
    count += j

print(count)

### FIXED CODE ###

from collections import defaultdict

N = int(input())
s = defaultdict(lambda:0)
count=0

for i in range(N):
  a = "".join(sorted(input()))
  s[a] +=1
  
  if s[a] >1:
    count += s[a]-1
print(count)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

mod = 10**9+7

n = int(input())
g = [[] for _ in range(n)]

for _ in range(n-1):
    a,b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

depth = [-1]*n
ko = [[] for _ in range(n)]
ko_all = [0 for _ in range(n)]


def dfs(v,d):
    depth[v] = d
    for w in g[v]:
        if depth[w] == -1:
            ko[v].append(w)
            dfs(w,d+1)
            ko_all[v] += ko_all[w]+1

dfs(0,0)

cnt = 0

for i in range(n):
    tmp = 2**(n-1)-1-(2**(n-1-ko_all[i])-1)
    tmp %=mod
    for w in ko[i]:
        tmp -= 2**(ko_all[w]+1)-1
        tmp %= mod
    cnt += tmp
    cnt %= mod


def inv(a,mod):
    r = [1,0,a]
    w = [0,1,mod]
    while w[2]!=1:
        q = r[2]//w[2]
        r_new = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = w
        w = r_new
    x,y = w[0],w[1]    # a*x+y*mod = 1
    return (mod+x%mod)%mod

print(inv(2**n,mod)*cnt %mod)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

mod = 10**9+7

n = int(input())
g = [[] for _ in range(n)]

pow2 = [0 for _ in range(n+1)]
pow2[0] = 1
for i in range(n):
    pow2[i+1] = pow2[i]*2 %mod

for _ in range(n-1):
    a,b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

depth = [-1]*n
ko_all = [0 for _ in range(n)]
ko_only =[0 for _ in range(n)]

def dfs(v,d):
    depth[v] = d
    for w in g[v]:
        if depth[w] == -1:
            dfs(w,d+1)
            ko_all[v] += ko_all[w]+1
            ko_only[v] += pow2[ko_all[w]+1]-1

dfs(0,0)

cnt = 0

for i in range(n):
    tmp = pow2[n-1]-1-(pow2[n-1-ko_all[i]]-1) - ko_only[i]
    tmp %=mod
    cnt += tmp
    cnt %= mod

def inv(a,mod):
    r = [1,0,a]
    w = [0,1,mod]
    while w[2]!=1:
        q = r[2]//w[2]
        r_new = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = w
        w = r_new
    x,y = w[0],w[1]    # a*x+y*mod = 1
    return (mod+x%mod)%mod

print(inv(pow2[n],mod)*cnt %mod)
### BUGGY CODE ###

import numpy as np

s = input()
mod = 10**9+7

dp = np.zeros((len(s)+1, 13))
dp[0][0] = 1

for i in range(len(s)):
  c = -1 if s[i] == '?' else int(s[i])
  for j in range(10):
    if (c != -1 and c != j):
      continue
    for k in range(13):
      dp[i+1][(k * 10 + j) % 13] += dp[i][k]

  for j in range(13):
    dp[i+1][j] %= mod    
  
print(int(dp[len(s)][5]))



### FIXED CODE ###

s = input()
mod = 10**9+7

dp = [[0 for j in range(13)] for i in range(len(s)+1)]
dp[0][0] = 1
for i in range(len(s)):
  c = -1 if s[i] == '?' else int(s[i])
  for j in range(10):
    if (c != -1 and c != j):
      continue
    for k in range(13):
      dp[i+1][(k * 10 + j) % 13] += dp[i][k]
      dp[i+1][(k * 10 + j) % 13] %= mod
		
  for j in range(13):
    dp[i+1][j] %= mod    
  
print(int(dp[len(s)][5]))
### BUGGY CODE ###

from collections import Counter

n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
d = [x[:] for x in a]
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        l = []
        for k in range(n):
            dist = d[i][k] + d[k][j]
            l.append(dist)
            d[i][j] = min(d[i][j], dist)
        for m in Counter(l).most_common():
            if m[1] >= 3:
                ans -= m[0]
for i in range(n):
    if a[i] != d[i]:
        print(-1)
        exit()
an = 0
for i in range(n):
    an += sum(a[i])
print(an // 2 + ans)

### FIXED CODE ###

from collections import Counter

n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
d = [x[:] for x in a]
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        l = []
        s = d[i][j]
        for k in range(n):
            if k == i or k == j:
                continue
            dist = d[i][k] + d[k][j]
            if dist == s:
                ans -= s
                break
            d[i][j] = min(d[i][j], dist)
for i in range(n):
    if a[i] != d[i]:
        print(-1)
        exit()
an = 0
for i in range(n):
    an += sum(a[i])
print(an // 2 + ans)
### BUGGY CODE ###

n = int(input())
s = input()
result = 0

for i in range(0, n-2):
  si = s[i]
  for j in range(i+1, n-1):
    sj = s[j]
    if sj==si:
      continue
    for k in range(j+1, n):
      sk = s[k]
      if sk==si or sk==sj:
        continue
      if j-i != k-j:
        result += 1

print(result)

### FIXED CODE ###

import math

n = int(input())
s = input()
ex = 0

for i in range(n-2):
  for x in range(1, int(math.ceil((n-i)/2))):
    if s[i] != s[i+x] and s[i] != s[i+2*x] and s[i+x] != s[i+2*x]:
      ex += 1

print(s.count("R") * s.count("G") * s.count("B")-ex)
### BUGGY CODE ###

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

import operator
from functools import reduce
if reduce(operator.mul, values) > 10**18:
  print(-1)
else:
  print(reduce(operator.mul, values))

### FIXED CODE ###

n = int(input())
values =list(map(int, input().split()))
a=1
t = 10**18
for i in range(n):
  if values[i] == 0:
    a = 0
    break
  if a > t:
    continue
  else:
    a=a*values[i]
 
if a <= t:
  print(a)
else:
  print(-1)
### BUGGY CODE ###

from functools import reduce
N = int(input())
A = [int(input()) for i in range(N)]
for i, num in enumerate(A):
    AA = A[:]
    AA.pop(i)
    print(max(AA))

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
A_max = max(A)
AA = A[:]
AA.remove(A_max)
A_max_2nd = max(AA)
for num in A:
    if num != A_max:
        print(A_max)
    else:
        print(A_max_2nd)
### BUGGY CODE ###

import bisect

n = int(input())
l = sorted([int(li) for li in input().split()])

sum = 0
for i in range(n)[::-1]:
    for j in range(i)[::-1]:
        k = bisect.bisect_right(l[:j],l[i]-l[j])
        sum += j-k

print(sum)


### FIXED CODE ###

import bisect

n = int(input())
l = sorted([int(li) for li in input().split()])

sum = 0
for i in range(n-1,-1,-1):
    for j in range(i-1,-1,-1):
        k = bisect.bisect_right(l,l[i]-l[j])
        sum += j-k if j>k else 0

print(sum)
### BUGGY CODE ###

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

import fractions
lcm = 1
for ai in set(a):
    lcm = ai * lcm // fractions.gcd(ai, lcm)

ans = 0
for ai in a:
    ans += (lcm // ai)

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

### FIXED CODE ###

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

import fractions
lcm = 1
prevlcm = 1
ans = 0
for i in range(n):
    ai = a[i]
    lcm = ai * lcm // fractions.gcd(ai, lcm)
    if prevlcm == lcm:
        ans = ans + (lcm // ai)
    else:
        ans = ans * (lcm // prevlcm) + (lcm // ai)
    #print(i, lcm, ans)
    prevlcm = lcm

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

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

### FIXED CODE ###

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

n = int(input())
a = list(map(int,input().split()))
b =[]
for i in range(1,n+1):
 if (n%2)==(i%2):
    b.insert(0,a[i-1])
 else:
    b.append(a[i-1])
print(' '.join(map(str,b)))

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
o =a[::2]
e =a[1::2]
if len(a)%2==0:
    ans = e[::-1]+o
elif len(a)==1:
    ans = a
else:
    ans = o[::-1]+e
print(' '.join(map(str,ans)))
### BUGGY CODE ###

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

ans = 0
accum = []
ids = []
for i, a in enumerate(A):
  ids.append(i+1)
  accum = list(map(lambda x:x+a, accum))
  accum.append(a)
  ans += sum([1 if s%K == idx else 0 for s, idx in zip(accum, ids[::-1])])

print(ans)  

### FIXED CODE ###

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

ans = 0
accum = [0]
d = {0 : 1}

for i, a in enumerate(A):
  accum.append((accum[-1] + a - 1)%K)
  if i >= K - 1:
    d[accum[i-K+1]] -= 1
  
  if accum[-1] in d:
    ans += d[accum[-1]]
    d[accum[-1]] += 1
  
  else:
    d[accum[-1]] = 1

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

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

counter = 1
for i in range(1,n):
    if [x for x in P[0:i] if P[i]>x ] == []:
        counter +=1

print(counter)

### FIXED CODE ###

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

minimum = float('inf')
ans = 0
for p in P:
    if p <=minimum:
        minimum = p
        ans += 1
print(ans)
### BUGGY CODE ###

S=input()
N=len(S)
Sinfo=''
for i in range(0,N):
    if S[i]=='?':
        Sinfo+='0'
    else:
        Sinfo+=S[i]
first=int(Sinfo)%13
count=0
hatenadata=[]
for i in range(0,N):
    if S[i]=='?':
        count+=1
        hatenadata.append(i)

r=[[(i*10**(j-1))%13 for i in range(0,10)] for j in range(1,7)]

dp=[[0 for i in range(0,13)] for i in range(0,count+1)]

for i in range(0,13):
    if first==i:
        dp[0][i]=1

for i in range(1,count+1):
    digit=N-hatenadata[i-1]
    for j in range(0,13):
        dp[i][j]=sum(dp[i-1][(j-r[(digit-1)%6][k])%13] for k in range(0,10))


print(dp[count][5]%(10**9+7))

### FIXED CODE ###

S=input()
N=len(S)
count=0
hatenadata=[]
Sinfo=[]
for i in range(0,N):
    if S[i]=='?':
        Sinfo.append('0')
        count+=1
        hatenadata.append(i)
    else:
        Sinfo.append(S[i])
X=''.join(Sinfo)
first=int(X)%13

dp=[[0 for i in range(0,13)] for i in range(0,count+1)]

for i in range(0,13):
    if first==i:
        dp[0][i]=1

for i in range(1,count+1):
    digit=N-hatenadata[i-1]
    for j in range(0,13):
        dp[i][j]=sum(dp[i-1][(j-k*10**((digit-1)%6))%13] for k in range(0,10))%(10**9+7)

print(dp[count][5]%(10**9+7))
### BUGGY CODE ###

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

list_size = int(input())
num_list = [int(i) for i in input().split()]

for i in range(0, list_size):

	num_list2 = []
	for idx, num in enumerate(num_list):
		
		if idx != i:
			num_list2.append(num)
	
	# 昇順ソート
	num_list2.sort()
	# 中央値の計算
	ans = num_list2[int((len(num_list2) + 1) / 2) - 1]
	print(ans)

### FIXED CODE ###

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

list_size = int(input())
num_list = [int(i) for i in input().split()]
# 昇順ソート
num_list2 = sorted(num_list)
# 中央値候補
center_left = num_list2[int(list_size / 2) - 1]
center_right = num_list2[int(list_size / 2)]

for i in range(list_size):
	# 除く値が左寄り(小さい)なら右、右寄り(大きい)なら左
	if num_list[i] <= center_left:
		print(center_right)
	else:
		print(center_left)
### BUGGY CODE ###

import sys
#import numpy as np
import bisect
sys.setrecursionlimit(10 ** 7)

# TLE
# PyPy3 (2.4.0) 2112 ms

N, Q = map(int, input().split())
STX = []
for _ in range(N):
    s, t, x = map(int, input().split())
    STX.append((s, t, x))

PEOPLE = []
for i in range(Q):
    d = int(input())
    PEOPLE.append((d, i))

ans = [-1] * Q

STX.sort(key=lambda x: x[2])

for s, t, x in STX:
    if len(PEOPLE) == 0:
        break

    i = bisect.bisect_left(PEOPLE, (s - x, -1))
    j = bisect.bisect_left(PEOPLE, (t - x, -1))

    if i == j:
        continue

    use = [PEOPLE[x][1] for x in range(i, j)]

    for k in use:
        ans[k] = x

    del PEOPLE[i:j]
    #PEOPLE = [PEOPLE[x] for x in range(len(PEOPLE)) if not(i <= x < j)]


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


### FIXED CODE ###

#D in [S_i-X_i,T_i-X_i) → Xiで止まる
import sys
input = sys.stdin.readline
from heapq import heappop,heappush
from collections import defaultdict

N,Q = map(int,input().split())
task = []

STX = [[int(x) for x in input().split()] for _ in range(N)]
for s,t,x in STX:
  task.append((t-x,0,x)) # xで止まらなくなる
  task.append((s-x,1,x)) # xで止まる

for i in range(Q):
  d = int(input())
  task.append((d,2,i)) # 止まる位置を答える
answer = [-1]*Q

task.sort()

# 引っかかってる場所の管理
se = set()
se_hp = [] # heapで最小値を先頭に保つ

# 小さい時刻から順に見ていく
for a,b,c in task:
  if not b: # b == 0
    se.remove(c)
  elif b&1: # b == 1
    se.add(c)
    heappush(se_hp,c)
  else: # b == 2
    while se_hp and se_hp[0] not in se:
      heappop(se_hp)
    answer[c] = se_hp[0] if se_hp else -1

print('\n'.join(map(str,answer)))
### BUGGY CODE ###

import math
def combinations_count(n, r):
    if n - r < 0:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

a = input()

d = {}

for ai in a:
    if ai in d:
        d[ai] += 1
    else:
        d[ai] = 1

ans = combinations_count(len(a), 2) + 1

for k in d:
    ans -= combinations_count(d[k], 2)
print(ans)


### FIXED CODE ###

import math

a = input()

d = {}

for ai in a:
    if ai in d:
        d[ai] += 1
    else:
        d[ai] = 1

ans = len(a) * (len(a) -1) // 2 + 1

for k in d:
    ans -= d[k] * (d[k] -1) // 2
print(ans)
### BUGGY CODE ###

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

#for i in range(N):
#    A[i][i] = float("INF")

f = 0
r = [[1] * N for i in range(N)]

for k in range(N):
    for i in range(N):
        for j in range(N):
            if A[i][j] > A[i][k] + A[k][j]:
                f = 1
            elif A[i][j] == A[i][k] + A[k][j] and i != k and j != k:
                r[i][j] = 0

if f == 1:
    print("-1")
else:
    #print(r)
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            ans += A[i][j] * r[i][j]

    print(ans)

### FIXED CODE ###

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

#for i in range(N):
#    A[i][i] = float("INF")

f = 0
r = [[1] * N for i in range(N)]

for k in range(N):
    for i in range(N):
        for j in range(N):
            if A[i][j] > A[i][k] + A[k][j]:
                f = 1
            elif A[i][j] == A[i][k] + A[k][j] and i != k and j != k:
                r[i][j] = 0

if f == 1:
    print("-1")
else:
    #print(r)
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            ans += A[i][j] * r[i][j]

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

from itertools import combinations
from collections import deque


def find_index_by_value(a, val):
    for i, items in enumerate(a):
        if val in items:
            return i
    return -1

def count_unreachable(a):
    if len(a) == 0:
        return 0
    ans = 0
    ls = list(map(len, a))
    for l1, l2 in combinations(ls, 2):
        ans += l1 * l2
    return ans


n, m = map(int, input().split())
edges = []
node_group = [{n} for n in range(1, n + 1)]

for _ in range(m):
    a, b = map(int, input().split())
    edges.append((a, b))

ans = deque()
ans.append(n * (n - 1) // 2)

for _ in range(m - 1):
    a, b = edges.pop()
    ia = find_index_by_value(node_group, a)
    ib = find_index_by_value(node_group, b)
    if ia != ib:
        node_group[ia] |= node_group[ib]
        node_group.pop(ib)
    c = count_unreachable(node_group)
    ans.appendleft(c)

for _ in range(len(ans)):
    print(ans.popleft())




### FIXED CODE ###

def find_index_by_value(a, val):
    for i, items in enumerate(a):
        if val in items:
            return i
    return -1


def num_reachable(n):
    return n * (n - 1) // 2


n, m = map(int, input().split())
edges = []

for _ in range(m):
    a, b = map(int, input().split())
    edges.append((a, b))

size = [1 for _ in range(n + 1)]
group = [i for i in range(n + 1)]


def find_group(x):
    c = []
    p = x
    while True:
        pp = group[p]
        if pp == p:
            break
        else:
            c.append(p)
            p = pp
    for i in c:
        group[i] = pp
    return pp

# find_group = lambda x: x if x == group[x] else find_group(group[x])

ans = []
not_reachable = n * (n - 1) // 2
reachable_node = []
ans.append(not_reachable)

count = not_reachable
reachable = 0
for _ in range(m - 1):
    a, b = edges.pop()
    if count > 0:
        ra = find_group(a)
        rb = find_group(b)
        if rb != ra:
            s_ra = size[ra]
            s_rb = size[rb]
            new_size = s_ra + s_rb
            reachable += num_reachable(new_size) - num_reachable(s_ra) - num_reachable(s_rb)
            size[ra] = new_size
            group[rb] = ra
        count = not_reachable - reachable
    ans.append(count)

for _ in range(len(ans)):
    print(ans.pop())
### BUGGY CODE ###

"""
E.
"""
from functools import reduce
from collections import deque


def prod(x, y):
    return x * y % MOD

    
N, K = map(int, input().split())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)
abs_a_list = sorted(a_list, key=abs, reverse=True)
MOD = 10**9 + 7

if K%2 == 1:
    flg = True
    for a in a_list:
        if a >= 0:
            flg = False
            break
    if flg:
        print(reduce(prod, a_list[:K])%MOD)
        exit()

# ans2
S = []
for _ in range(K//2):
    if a_list[0]*a_list[1] >= a_list[-1]*a_list[-2]:
        S.append(a_list.pop(0))
        S.append(a_list.pop(0))
    else:
        S.append(a_list.pop(-1))
        S.append(a_list.pop(-1))
if K%2 == 1:
    S.append(a_list.pop(0))

ans = reduce(prod, S)
print(ans)

### FIXED CODE ###

"""
E.
"""
from functools import reduce
from collections import deque


def prod(x, y):
    return x * y % MOD

    
N, K = map(int, input().split())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)
# abs_a_list = sorted(a_list, key=abs, reverse=True)
MOD = 10**9 + 7

if K%2 == 1:
    flg = True
    for a in a_list:
        if a >= 0:
            flg = False
            break
    if flg:
        print(reduce(prod, a_list[:K]))
        exit()

S = []
a_list = deque(a_list)
i = 0
while i < K:
    if len(a_list)>=2:
        if a_list[0]*a_list[1] > a_list[-1]*a_list[-2]:
            S.append(a_list.popleft())
            i += 1
        elif a_list[0]*a_list[1] <= a_list[-1]*a_list[-2] and i <= K-2:
            S.append(a_list.pop())
            S.append(a_list.pop())
            i += 2
        else:
            S.append(a_list.popleft())
            i += 1
    else:
        S.append(a_list.popleft())
        i += 1
        
ans = reduce(prod, S)
print(ans)
### BUGGY CODE ###

from sys import exit
import copy
# import numpy as np
from collections import deque

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

cnt = 0

a_sum = [0]
b_sum = [0]

a_sum.extend(a)
b_sum.extend(b)


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

for i in range(1, m+1):
    b_sum[i] += b_sum[i-1]


for i in range(n+1):
    for j in range(m+1):
        if a_sum[i] + b_sum[j] <= k:
            cnt = max(cnt, i + j)
        else:
            break
print(cnt)


### FIXED CODE ###

from sys import exit
import copy
# import numpy as np
from collections import deque

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

cnt = 0


a.insert(0, 0)
b.insert(0, 0)


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

for i in range(1, m+1):
    b[i] += b[i-1]

tmp = m
for i in range(n+1):
    for j in range(tmp, -1, -1):
        if a[i] + b[j] <= k:
            cnt = max(cnt, i + j)
            tmp = j
            break


print(cnt)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

# C - Lower
n = int(input())
h = list(map(int, input().split()))
ans = 0

for i in range(n):
	count = 0
	
	for j in range(i, n - 1):
		if h[j] >= h[j + 1]:
			count += 1
		else:
			break
	
	ans = max(ans, count)
#	print('スタート:' + str(i), count)

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

# C - Lower
n = int(input())
h = list(map(int, input().split()))
count = 0
ans = 0

for i in range(n - 1):
	if h[i] >= h[i + 1]:
		count += 1
	else:
		count = 0

	ans = max(ans, count)

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

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

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

if ans > 1e18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

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

for i in range(n):
    if(a[i] == 0):
        print(0)
        exit()

ans = 1
for i in range(n):
    ans = ans * a[i]
    if(ans > 1e18):
        print(-1)
        exit()

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

from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
import numpy as np

H, W, ch, cw, gh, gw, *S = open(0).read().split()
H, W, ch, cw, gh, gw = [int(_) - 1 for _ in [H, W, ch, cw, gh, gw]]
H += 1
W += 1

X = []
Y = []
D = []
for i in range(H * W):
    h, w = divmod(i, W)
    if S[h][w] == '#':
        continue
    if w + 1 < W and S[h][w + 1] == '.':
        X += [i]
        Y += [i + 1]
        D += [0]
    if h + 1 < H and S[h + 1][w] == '.':
        X += [i]
        Y += [i + W]
        D += [0]
    for dh in range(-2, 3):
        for dw in range(-2, 3):
            if (dh, dw) in [(0, 0), (1, 0), (0, 1)]:
                continue
            if 0 <= h + dh < H and 0 <= w + dw < W and S[h + dh][w +
                                                                 dw] == '.':
                X += [i]
                Y += [i + dw + W * dh]
                D += [1]
dist = dijkstra(
    csr_matrix((D, (X, Y)), (H * W, H * W)), indices=ch * W + cw, directed=0)
ans = dist[gh * W + gw]
if ans == np.inf:
    ans = -1
else:
    ans = int(ans)
print(ans)


### FIXED CODE ###

import collections, itertools
H, W, ch, cw, dh, dw, *S = open(0).read().split()
H, W, ch, cw, dh, dw = [int(_) + 1 for _ in [H, W, ch, cw, dh, dw]]
H += 3
W += 3
S = ['#' * W] + ['#' * W] + ['##' + s + '##'
                             for s in S] + ['#' * W] + ['#' * W]
Dist = [[None] * W for _ in range(H)]
Q = collections.deque([(0, ch, cw)])
while Q:
    d, ox, oy = Q.popleft()
    if Dist[ox][oy] is not None:
        continue
    stack = [[ox, oy]]
    warp = set()
    while stack:
        x, y = stack.pop()
        if (x, y) == (dh, dw):
            print(d)
            exit()
        Dist[x][y] = d
        for dx, dy in [[-1, 0], [1, 0], [0, -1], [0, 1]]:
            nx, ny = x + dx, y + dy
            if Dist[nx][ny] is None:
                if S[nx][ny] == '.':
                    stack += [[nx, ny]]
                else:
                    warp.add((x, y))
    for x, y in warp:
        for dx, dy in itertools.product(range(-2, 3), repeat=2):
            nx, ny = x + dx, y + dy
            if Dist[nx][ny] is None and S[nx][ny] == '.':
                Q += [(d + 1, nx, ny)]
print(-1)