Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0]*len(A)

for _ in range(K):
  for i in range(N):
    l = max(0, i-A[i])
    r = min(N-1, i+A[i])
    B[l]+=1
    if r+1 < N:
      B[r+1]-=1
  A = np.cumsum(B)
  if min(A) == N:
    break
  B = [0]*len(A)
A = map(str, A)
print(' '.join(A))

Fixed submission:
import numpy as np
from numba import njit

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


@njit
def search(a):
  B = np.zeros_like(a)
  for i in range(N):
    l = max(0, i-a[i])
    r = min(N-1, i+a[i])
    B[l]+=1
    if r+1 < N:
      B[r+1]-=1
  B = np.cumsum(B)
  return B

for _ in range(K):
  A = search(A)
  if min(A) == N:
      break
A = map(str, A)
print(' '.join(A))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in A:
  ans*=i

print(ans if ans <= 10**18 else -1)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
  print(0)
  exit()
for i in A:
    if ans > 10**18:
        ans = -1
        break
    ans*=i

print(ans if ans <= 10**18 else -1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
last = A[-1]
count = last
root = 1
for i in range(N):
  if root <= A[i]:
    print(-1)
    break
  if i+1 == N and root-A[i] > A[i+1]:
    root = last + A[i]
  elif root-A[i] > (last + A[i+1]):
    root = (last + A[i+1]) + A[i]
  count+=root
  root = (root-A[i])*2
else:
  if count == 0 or root < last:
    count = -1
  print(count)

Fixed submission:
h1, m1, h2, m2, k = map(int, input().split())

h1*=60
h1+=m1
h2*=60
h2+=m2
if h1 > h2:
  h2+=60*24

begin = h2 - k

print(begin-h1)
Buggy python submission (verdict: Runtime Error):
from math import gcd
 
n=int(input())
mod = 10**9+7
 
d = dict()
zeros=0
for _ in range(n):
  a,b=map(int,input().split())
  if not any((a,b)):
    zeros+=1
    continue
  if all((a,b)):
    g = gcd(a,b)
  elif a:
    g = a
  else:
    g = b
  
  p = a//g,b//g
  d[p] = d.get(p,0)+1
 
ans = 1
done = set()
for (a,b),v in d.items():
  if (-b,a) in done or (b,-a) in done:
    continue
  done.add((a,b))
  w=d.get((-b,a),0)+d.get((b,-a),0)
  ans *= (pow(2,v,mod)+pow(2,w,mod)-1)
  ans %= mod
print((ans+zeros-1+mod)%mod)

Fixed submission:
N = int(input())

a = N%10

if a == 3:
  print('bon')
elif a == 0 or a == 1 or a == 6 or a == 8:
  print('pon')
else:
  print('hon')
Buggy python submission (verdict: Runtime Error):
import numpy as np
import itertools

N, M = map(int, input().split())
root = [list(map(int, input().split())) for _ in range(M)]

class Room:
  def __init__(self, num):
    self.num = num
    self.roots = []
    self.kyori = -1
    self.near = 0
    
  def add_root(self, to):
    self.roots.append(to)
  def set_kyori(self, num, kyori):
    if self.kyori == -1 or self.kyori > kyori:
      self.kyori = kyori
      self.near = num
      for r in self.roots:
        if r.num == num:
          continue
        r.set_kyori(self.num, self.kyori+1)

r_list = sorted(np.unique(np.array(list(itertools.chain.from_iterable(root)))))
rooms = {i:Room(i) for i in r_list}

for r in root:
  a, b = rooms[r[0]], rooms[r[1]]
  a.add_root(b)
  b.add_root(a)

rooms[1].set_kyori(0, 0)
for r in rooms.values():
  if r.kyori == -1:
    print('No')
    break
else:
  print('Yes')
  for r in list(rooms.values())[1:]:
    print(r.near) 
  
  

Fixed submission:
import numpy as np
import itertools
from collections import deque

N, M = map(int, input().split())
root = [list(map(int, input().split())) for _ in range(M)]

class Room:
  def __init__(self, num):
    self.num = num
    self.roots = []
    self.kyori = -1
    self.near = 0
    
  def add_root(self, to):
    self.roots.append(to)
  def set_kyori(self, num, kyori):
    self.kyori = kyori
    self.near = num

r_list = sorted(np.unique(np.array(list(itertools.chain.from_iterable(root)))))
rooms = {i:Room(i) for i in r_list}

for r in root:
  a, b = rooms[r[0]], rooms[r[1]]
  a.add_root(b)
  b.add_root(a)

kyori = 0
near = 0
rooms[1].set_kyori(near, kyori)
rooms[1].near = near
q = deque()
q.append(rooms[1])
while len(q) > 0:
  node = q.popleft()
  kyori+=1
  for r in node.roots:
    if r.kyori != -1:
      continue
    r.set_kyori(node.num, kyori)
    q.append(r)
  
rooms[1].set_kyori(0, 0)
for r in rooms.values():
  if r.kyori == -1:
    print('No')
    break
else:
  print('Yes')
  for r in list(rooms.values())[1:]:
    print(r.near)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
iwa = [list(map(int, input().split())) for _ in range(N)]

dev = 1000000007

all_s = 2**len(iwa)-1

bad = []
for i in range(len(iwa)):
  for j in range(i+1, len(iwa)):
    if iwa[i][0]*iwa[j][0]+iwa[i][1]*iwa[j][1] == 0:
      bad.append(2**i+2**j)
bad_s = 0
for i in range(1, all_s+1):
  for j in bad:
    # print(bin(i), bin(j), bin(i&j))
    if bin(i&j)==bin(j):
      bad_s+=1
      break
print((all_s-bad_s)%dev)

Fixed submission:
from math import gcd
 
n=int(input())
mod = 10**9+7
 
d = dict()
zeros=0
for _ in range(n):
  a,b=map(int,input().split())
  if not any((a,b)):
    zeros+=1
    continue
  if all((a,b)):
    g = gcd(a,b)*(a//abs(a))
  elif a:
    g = a
  else:
    g = b
  
  p = a//g,b//g
  d[p] = d.get(p,0)+1
 
ans = 1
done = set()
for (a,b),v in d.items():
  if (-b,a) in done or (b,-a) in done:
    continue
  done.add((a,b))
  w=d.get((-b,a),0)+d.get((b,-a),0)
  ans *= (pow(2,v,mod)+pow(2,w,mod)-1)
  ans %= mod
print((ans+zeros-1+mod)%mod)
Buggy python submission (verdict: Runtime Error):
N = input()
S = input()
ans = set()
num_count = [0]*10
i = 0
while i < len(S):
    s_num = int(S[i])
    if num_count[s_num] <= 3:
        num_count[s_num] += 1
        i += 1
    else:
        S.pop(i)
for i in range(len(S)-2):
    for j in range(i+1, len(S)-1):
        for k in range(j+1, len(S)):
            s = S[i]+S[j]+S[k]
            if s not in ans:
                ans.add(s)
print(len(ans))


Fixed submission:
N = input()
S = list(input())
count = 0
num_count = [False]*10
for i in range(len(S)-2):
    s_i = int(S[i])
    if num_count[s_i]:
        continue
    num_count[s_i] = True
    num_count_2 = [False]*10
    for j in range(i+1, len(S)-1):
        s_j = int(S[j])
        if num_count_2[s_j]:
            continue
        num_count_2[s_j] = True
        num_count_3 = [False] * 10
        for k in range(j+1, len(S)):
            s_k = int(S[k])
            if num_count_3[s_k]:
                continue
            num_count_3[s_k] = True
            count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
S = input()
ans = set()
for i in range(len(S)-2):
    for j in range(i+1, len(S)-1):
        for k in range(j+1, len(S)):
            s = S[i]+S[j]+S[k]
            if s not in ans:
                ans.add(s)
print(len(ans))


Fixed submission:
N = input()
S = list(input())
count = 0
num_count = [False]*10
for i in range(len(S)-2):
    s_i = int(S[i])
    if num_count[s_i]:
        continue
    num_count[s_i] = True
    num_count_2 = [False]*10
    for j in range(i+1, len(S)-1):
        s_j = int(S[j])
        if num_count_2[s_j]:
            continue
        num_count_2[s_j] = True
        num_count_3 = [False] * 10
        for k in range(j+1, len(S)):
            s_k = int(S[k])
            if num_count_3[s_k]:
                continue
            num_count_3[s_k] = True
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = 10**9
for i in range(1, 2**n, 2):
    if not i & 1 or k != sum([i >> j & 1 for j in range(n)]):
        continue
    pre = a[0]
    cost = 0
    for j in range(1, n):
        if i >> j & 1:
            tmp = max(pre - a[j] + 1, 0)
            pre = a[j] + tmp
            cost += tmp
    ans = min(ans, cost)
print(ans+'\n')


Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = 10**12
for i in range(1, 2**n, 2):
    if k != sum([i >> j & 1 for j in range(n)]):
        continue
    pre = a[0]
    cost = 0
    for j in range(1, n):
        if i >> j & 1:
            tmp = max(pre - a[j] + 1, 0)
            pre = a[j] + tmp
            cost += tmp
        else:
            pre = max(pre, a[j])
    ans = min(ans, cost)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

ans = 0
for a in range(1,N):
    for b in range(1,N):
        c = N - a * b
        if a * b + c == N and c > 0:
            ans += 1
            # print(a,b,c)
        elif a * b > N:
            break

print(ans)


Fixed submission:
N = int(input())

ans = 0
for a in range(1,N):
    for b in range(1,N):
        c = N - a * b
        if a * b + c == N and c > 0:
            ans += 1
            # print(a,b,c)
        elif a * b > N:
            break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X,K,D = map(int,input().split())

ans = 10**15 
for i in range(K):
    if X>=0:
        X-=D
        if abs(X) < abs(ans):
            ans = abs(X)
    else:
        X+=D
        if abs(X) < abs(ans):
            ans = abs(X)
print(ans)



Fixed submission:
X,K,D = map(int,input().split())

X = abs(X)

# Dだけ原点に向かって移動したとき，最も原点に近い座標
r = X%D
# rまでに要した移動回数
q = X//D

# rに到達後は残りの移動回数が偶数か奇数かで場合分け
# K回を超えている場合
if K <= q:
    print(X-D*K)
else:
    # 残り移動可能回数
    rem = K - q

    # 残り移動可能回数が偶数なら，その場所にとどまることできる
    if rem%2 == 0:
        print(r)
    # 奇数なら，絶対に負の側でゴールすることになる．よってr-Dの絶対値であるD-rが解
    else:
        print(D-r)
Buggy python submission (verdict: Runtime Error):
import copy
N,M,K = map(int,input().split())
A = [0]*N
B = [0]*M
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = 0
b = 0

tmp = 0
ans = 0
# for i in range(200000):
#     if A[a] < B[b]:
#         if tmp <= K:
#             tmp += A[a]
#             ans += 1
#             a += 1
#     elif A[a] > B[b]:
#         if tmp <= K:
#             tmp += B[b]
#             ans += 1
#             b += 1
#     if a > len(A)-1 or b > len(B)-1:
#         break
fa = False
fb = False

while len(A) > 0 or len(B) > 0:
    AA = copy.copy(A)
    BB = copy.copy(B)
    if len(AA) != 0:
        a = AA.pop(0)
        fa = True
    if len(BB) != 0:
        b = BB.pop(0)
        fb = True
    if fa and fb:
        if a<=b:
            tmp += a
            ans += 1
            A = AA
        else:
            tmp += b
            ans += 1
            B = BB
    else:
        if fa:
            tmp += a
            ans += 1
            A = AA
        if fb:
            tmp += b
            ans += 1
            B = BB

    if tmp > K:
        break
    fa = False
    fb = False
    
    print(tmp,A,B)
    
if len(A)==0 and len(B)==0:
    print(ans)
else:
    print(ans-1)


Fixed submission:
N,M,K = map(int,input().split())
A = [0]*N
B = [0]*M
A = list(map(int,input().split()))
B = list(map(int,input().split()))

b = []
b.append(0)
tmp = 0
for i in range(M):
    b.append(tmp+B[i])
    tmp = tmp+B[i]# M冊全部呼んだとする
a = [0]
for i in range(N):
    a.append(a[i]+A[i])
#print(b)
ans,j = 0,M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j] > K - a[i]:#Kを超えてたらこの冊数読むの諦める
        j -= 1
    ans = max(ans,i+j)#最大冊数を更新していく

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0]*N
A = list(map(int,input().split()))
Q = int(input())
B = [0]*Q
C = [0]*Q
for i in range(Q):
    B[i],C[i] = map(int,input().split())


S = [0]*Q
for i in range(Q):
    for j in range(N):
        if A[j] == B[i]:
            A[j] = C[i]
    for k in range(N):
        S[i] += A[k] 

for i in range(Q):
    print(S[i])

Fixed submission:
N = int(input())
A = [0]*N
A = list(map(int,input().split()))
Q = int(input())
B = [0]*Q
C = [0]*Q
for i in range(Q):
    B[i],C[i] = map(int,input().split())


S = [0]*Q
# for i in range(Q):
#     for j in range(N):
#         if A[j] == B[i]:
#             A[j] = C[i]
#     for k in range(N):
#         S[i] += A[k] 
# for i in range(Q):
#     print(S[i])

cnt = [0] * 100005 # Aの数字の数を格納する，カウント配列
for i in A:
    cnt[i]+=1 

tot = sum(A)
for i in range(Q):
    #合計値の変動
    tot -= B[i]*cnt[B[i]]
    tot -= C[i]*cnt[C[i]]
    #カウント配列の変動
    cnt[C[i]] += cnt[B[i]]
    cnt[B[i]] = 0
    #合計値の変動
    tot += B[i]*cnt[B[i]]
    tot += C[i]*cnt[C[i]]
    print(tot)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in range(N):
    ans *= A[i]
    if ans > (10**18):
        ans = -1
        

print(ans)





Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = 1

if 0 in A:
    print('0')
else:
    for i in range(N):
        ans *= A[i]
        if ans > (10**18):
            ans = -1
            break
            
            

    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in range(N):
    ans *= A[i]
    if ans > (10**18):
        ans = -1
        

print(ans)





Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = 1

if 0 in A:
    print('0')
else:
    for i in range(N):
        ans *= A[i]
        if ans > (10**18):
            ans = -1
            break
            
            

    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
def gcd (*numbers):
    return reduce(math.gcd,numbers)

K = int(input())
ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += gcd(a,b,c)
print(ans)

Fixed submission:
import math
from functools import reduce
def gcd (*numbers):
    return reduce(math.gcd,numbers)

K = int(input())
ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += gcd(a,b,c)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

#for i in range(N+1):
    

def L(i):
    if i == 0:
        return 2
    if i == 1:
        return 1
    else:
        return L(i-1) + L(i-2)

print(L(N))

Fixed submission:
# import functools
N = int(input())

#for i in range(N+1):
# @functools.lru_cache()
# def L(i):
#     if i == 0:
#         return 2
#     if i == 1:
#         return 1
#     else:
#         return L(i-1) + L(i-2)
# print(L(N))


#上はfunctoolを使うもの下がいい

LL = [2,1] # リュカ数保存するリスト

for i in range(2,N+1):
    LL.append(LL[i-1] + LL[i-2])

print(LL[N])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
power = 1
for i in range(1,N+1):
    power *= i

power = power % (10**9+7)
print(power)

Fixed submission:
N = int(input())
power = 1
C = 10**9+7
for i in range(1,N+1):
    power *= i
    power %= C

# power = power % (10**9+7)
print(power)
Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int, input().split())
count = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z == S:
                count += 1
            
print(count)


Fixed submission:
K,S = map(int, input().split())
count = 0
# 計算量大きすぎる
# for x in range(K+1):
#     for y in range(K+1):
#         for z in range(K+1):
#             if x+y+z == S:
#                 count += 1

for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if 0 <= z <= K:
            count += 1
            
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

s = input().split()
A = []
for i in range(N):
  A.append(int(s[i]))
  
result = 0
for i in range(N-1):
  if i == 0 or i%2 == 1:
    m = max(A)
    result += m
    A.remove(m)
  else:
    result += m
    
print(result)

Fixed submission:
N = int(input())

s = input().split()
A = []
for i in range(N):
  A.append(int(s[i]))
  
result = 0
A.sort(reverse=True)
result += A[0]
A.pop(0)
if N % 2 == 0:
  result += sum(A[:(int(N/2)-1)])*2
else:
  result += (sum(A[:(int((N-1)/2)-1)])*2 + A[int((N-1)/2)-1])
    
print(result)
Buggy python submission (verdict: Runtime Error):
import math

s = input().split()

A = int(s[0])
B = float(s[1])

seisu = math.floor(B)
daiiti = math.floor(B*10)/10 - seisu
daini = B - seisu - daiiti

big = A*seisu
small = A*(int(daiiti*10))
if small >= 10:
  small = int(str(small)[:-1])
else:
  small = 0
too_small = A*(int(daini*100))
if too_small >= 100:
  too_small = int(str(small)[:-2])
else:
  too_small = 0

print(big+small+too_small)

Fixed submission:
s = input().split()

A = int(s[0])
B = int(s[1].replace(".", ""))
m = A*B

if m>=100:
  result = int(str(m)[:-2])
else:
  result = 0
  
print(result)

Buggy python submission (verdict: Runtime Error):
import math

s = input().split()

A = int(s[0])
B = int(float(s[1])*100)

result = A*B
result = int(str(result)[:-2])
print(result)

Fixed submission:
s = input().split()

A = int(s[0])
B = int(s[1].replace(".", ""))
m = A*B

if m>=100:
  result = int(str(m)[:-2])
else:
  result = 0
  
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

N = int(s.split()[0])
M = int(s.split()[1])

H = input().split()

tenbo = list(range(1,N+1))

for i in range(M):
  road = input().split()
  A = int(road[0])
  B = int(road[1])
  HA = int(H[A-1])
  HB = int(H[B-1])
  if HA >= HB and B in tenbo:
    tenbo.remove(B)
  if HA <= HB and A in tenbo:
    tenbo.remove(A)
    
print(len(tenbo))

Fixed submission:
s = input()

N = int(s.split()[0])
M = int(s.split()[1])

H = input().split()

tenbo = list(range(1,N+1))
bad_tenbo = []

for i in range(M):
  road = input().split()
  A = int(road[0])
  B = int(road[1])
  HA = int(H[A-1])
  HB = int(H[B-1])
  if HA > HB:
    bad_tenbo.append(B)
  elif HA == HB:
    bad_tenbo.append(A)
    bad_tenbo.append(B)
  elif HA < HB:
    bad_tenbo.append(A)
    
result = list(set(tenbo) - set(bad_tenbo))
    
print(len(result))
Buggy python submission (verdict: Time Limit Exceeded):
s = input().split()

A = int(s[0])
B = int(s[1])
N = int(s[2])

result = 0

start = N - (N // B) * B

for x in range(start, N+1):
  y = (A*x)//B - A*(x//B)
  if y > result:
    result = y
    
print(result)  

Fixed submission:
s = input().split()

A = int(s[0])
B = int(s[1])
N = int(s[2])

result = 0

n = (N // B) * B - 1
if (n < 0):
  n = 0

a = (A*N)//B - A*(N//B)
b = (A*n)//B - A*(n//B)
"""
for x in range(N+1):
  y = (A*x)//B - A*(x//B)
  if y > result:
    result = y
"""
    
if (a > b):
  result = a
else:
  result = b
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
s = input().split()

A = int(s[0])
B = int(s[1])
N = int(s[2])

result = 0

for x in range(N+1):
  y = (A*x)//B - A*(x//B)
  if y > result:
    result = y
    
print(result) 

Fixed submission:
s = input().split()

A = int(s[0])
B = int(s[1])
N = int(s[2])

result = 0

n = (N // B) * B - 1
if (n < 0):
  n = 0

a = (A*N)//B - A*(N//B)
b = (A*n)//B - A*(n//B)
"""
for x in range(N+1):
  y = (A*x)//B - A*(x//B)
  if y > result:
    result = y
"""
    
if (a > b):
  result = a
else:
  result = b
print(result)
Buggy python submission (verdict: Runtime Error):
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())

    alf = [chr(ord('a') + i) for i in range(26)]

    maxdigit = 1

    while N > 26 ** maxdigit:
        maxdigit += 1

    c = 26 ** (maxdigit - 1)

    res = ''

    for d in range(1,maxdigit+1):
        if d == maxdigit:
            res += alf[N-1]
            break
        for i in range(26):
            if N < c * (i+1):
                res += alf[i-1]
                N -= c * i
                c //= 26
                break

    print(res)



main()


Fixed submission:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())

    alf = [chr(ord('a') + i) for i in range(26)]

    maxdigit = 1
    pre = 0

    while N - pre > 26 ** maxdigit:
        pre += 26 ** maxdigit
        maxdigit += 1


    # print(maxdigit,pre)

    N -= pre

    res = ''

    for d in range(1,maxdigit+1):
        for i in range(26):
            if N <= 26 ** (maxdigit - d) * (i + 1):
                res += alf[i]
                N -= 26 ** (maxdigit - d) * i
                break

    print(res)



main()
Buggy python submission (verdict: Time Limit Exceeded):
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

    INF = 10 ** 18

    res = 1

    for i in range(N):
        res *= A[i]

    if res > INF:
        res = -1

    print(res)



main()


Fixed submission:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)
# from numba import njit


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

    Aset = set(A)

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

    A.sort(reverse=True)

    res = 1
    INF = 10 ** 18

    for i in range(N):
        res *= A[i]
        if res > INF:
            res = -1
            break

    print(res)



main()