Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, M, X = map(int,input().split())
A = list(map(int,input().split()))

count_low = 0
count_high = 0
for i in range(A):
  if A[i] > X:
    count_high +=1
  elif A[i] < X:
    count_low += 1
    
if count_low >= count_high:
  print(count_high)
elif count_low < count_high:
  print(count_low)


Fixed submission:
N, M, X = map(int,input().split())
A = list(map(int,input().split()))
a = len(A)

count_low = 0
count_high = 0
for i in range(a):
  if A[i] > X:
    count_high +=1
  elif A[i] < X:
    count_low += 1
    
if count_low >= count_high:
  print(count_high)
elif count_low < count_high:
  print(count_low)

Buggy python submission (verdict: Runtime Error):
N, M, X = int(input().split())
A = list(int(input().split()))

count_low = 0
count_high = 0
for i in range(A):
  if A[i] > X:
    count_high +=1
  else:
    count_low += 1
    
if count_low >= count_high:
  print(count_high)
else:
  print(count_low)

Fixed submission:
N, M, X = map(int,input().split())
A = list(map(int,input().split()))
a = len(A)

count_low = 0
count_high = 0
for i in range(a):
  if A[i] > X:
    count_high +=1
  elif A[i] < X:
    count_low += 1
    
if count_low >= count_high:
  print(count_high)
elif count_low < count_high:
  print(count_low)
Buggy python submission (verdict: Runtime Error):
S = list(input())
T = list(input())
s = []
t = []
for i in S:
  s.append(int(ord(i)))
for i in T:
  t.append(int(ord(i)))

s.sort(reverse = True)
t.sort(reverse = True)
for i in range(max(len(s),len(t))):
  if t[i] > s[i]:
    print("Yes")
    exit(0)
  elif s[i] != t[i]:
    break
  
if len(t) > len(s):
  for i in s:
    if i == len(s):
      print("Yes")
    elif i not in t:
      print("No")
      exit(0)
    else:
      t.remove(i)
else:
  print("No")
  exit(0)
print("No")



Fixed submission:
S = list(input())
T = list(input())
s = []
t = []
for i in S:
  s.append(int(ord(i)))
for i in T:
  t.append(int(ord(i)))

s.sort()
t.sort()
for i in range(max(len(s),len(t))):
  if i >= min(len(s),len(t)):
    break
  elif max(t) > s[i]:
    print("Yes")
    exit(0)
  elif s[i] not in t:
    break
  else:
    t.remove(s[i])
    s.remove(s[i])
    
  
if len(t) > len(s):
  for i in s:
    if i not in t:
      print("No")
      exit(0)
    else:
      t.remove(i)
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int,input().split())
A = list(map(int,input().split()))

a = list(set((A)))
check = len(a)
dff = check - K
if dff <= 0:
  print(0)
  exit(0)
ans_list = []

for i in range(check):
  ans = 0
  checker = a[i]
  for j in range(len(A)):
    if checker == A[j]:
      ans += 1
  ans_list.append(ans) 

ans_list.sort()

result = sum(ans_list[:dff])
print(result)

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

a = list(set((A)))
check = len(a)
dff = check - K
if dff <= 0:
  print(0)
  exit(0)
ans_list = [0]*check
A.sort()
index = 0
for i in range(len(A)):
  
  if i >= 1 and A[i] != A[i-1]:
    index += 1
  ans_list[index] += 1
ans_list.sort()
result = sum(ans_list[:dff])
print(result)
Buggy python submission (verdict: Runtime Error):
N = int(input()) 
S = [int(input()) for i in range(N)]
S.sort()
max_ans = sum(S)

if N == 1:
  if max_ans % 10 == 0:
    print(0)
    exit(0)
  else:
    print(max_ans)
    exot(0)
if max_ans % 10 == 0:
  i = 0
  while S[i] % 10 == 0:
    i += 1
    if i == N-1:
      print(0)
      exit(0)
  ans = max_ans - S[i]
  print(ans)
else:
  print(max_ans)

Fixed submission:
N = int(input()) 
S = [int(input()) for i in range(N)]
S.sort()
max_ans = sum(S)

if N == 1:
  if max_ans % 10 == 0:
    print(0)
    exit(0)
  else:
    print(max_ans)
    exit(0)
if max_ans % 10 == 0:
  i = 0
  while S[i] % 10 == 0:
    i += 1
    if i == N-1:
      print(0)
      exit(0)
  ans = max_ans - S[i]
  print(ans)
else:
  print(max_ans)

Buggy python submission (verdict: Runtime Error):
N = int(input()) 
S = [int(input()) for i in range(N)]
S.sort()
max_ans = sum(S)

if max_ans % 10 == 0:
  i = 0
  while S[i] % 10 == 0:
    i += 1
    if i == N-1:
      print(0)
      exit(0)
  ans = max_ans - S[i]
  print(ans)
else:
  print(max_ans)

Fixed submission:
N = int(input()) 
S = [int(input()) for i in range(N)]
S.sort()
max_ans = sum(S)

if N == 1:
  if max_ans % 10 == 0:
    print(0)
    exit(0)
  else:
    print(max_ans)
    exit(0)
if max_ans % 10 == 0:
  i = 0
  while S[i] % 10 == 0:
    i += 1
    if i == N-1:
      print(0)
      exit(0)
  ans = max_ans - S[i]
  print(ans)
else:
  print(max_ans)
Buggy python submission (verdict: Runtime Error):
num_list = list(int(input().split()))
product = num_list[0] * num_list[1]
if product % 2 == 0:
  print("Even")
else:
  print("Odd")

Fixed submission:
num_list = list(map(int,input().split()))
product = num_list[0] * num_list[1]
if product % 2 == 0:
  print("Even")
else:
  print("Odd")
Buggy python submission (verdict: Runtime Error):
number = int(input())
num_list = list(map(int, input().split()))

count = 0
for i in num_list:
  if i % 2 == 0:
    count += 1
    # print(count)
  else:
    print(0)
    break

count_s = 0
if count == number:
  num_min = min(num_list)
  while num_min % 2 == 0:
    num_min = num_min / 2
    count_s += 1
  print(count_s)


Fixed submission:
text = input()
ans = text.count('1')
print(ans)

Buggy python submission (verdict: Runtime Error):
number = int(input())
num_list = list(map(int, input().split()))

count = 0
for i in num_list:
  if i % 2 == 0:
    count += 1
    # print(count)
  else:
    print(0)
    break

count_s = 0
if count == number:
  num_min = min(num_list)
  while True:
    num_min = num_min / 2
    count_s += 1
    if num_min == 1:
      print(count_s)
      break

Fixed submission:
text = input()
ans = text.count('1')
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
A = [int(i) for i in input().split()]
p = 1
p_hist = []
p_hist_index = [-1] * (N+1)
while p not in p_hist:
    p_hist_index[p] = len(p_hist)
    p_hist.append(p)
    p = A[p-1]
end_loop = p_hist[-1]
end_loop_idx = p_hist_index[end_loop]
start_loop = A[end_loop - 1]
start_loop_idx = p_hist_index[start_loop]
if K < start_loop_idx:
    print(p_hist[K])
else:
    print(p_hist[(K-start_loop_idx)%(end_loop_idx-start_loop_idx+1)+start_loop_idx])


Fixed submission:
N,K = map(int, input().split())
A = list(map(int, input().split()))
p = 1
p_hist = []
p_hist_set = set()
p_hist_index = [-1] * (N+1)
while p not in p_hist_set:
    p_hist_index[p] = len(p_hist)
    p_hist.append(p)
    p_hist_set.add(p)
    p = A[p-1]
end_loop = p_hist[-1]
end_loop_idx = p_hist_index[end_loop]
start_loop = A[end_loop - 1]
start_loop_idx = p_hist_index[start_loop]
if K < start_loop_idx:
    print(p_hist[K])
else:
    print(p_hist[(K-start_loop_idx)%(end_loop_idx-start_loop_idx+1)+start_loop_idx])

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
A = list(map(int, input().split()))
p = 1
p_hist = []
p_hist_index = [-1] * (N+1)
while p not in p_hist:
    p_hist_index[p] = len(p_hist)
    p_hist.append(p)
    p = A[p-1]
end_loop = p_hist[-1]
end_loop_idx = p_hist_index[end_loop]
start_loop = A[end_loop - 1]
start_loop_idx = p_hist_index[start_loop]
if K < start_loop_idx:
    print(p_hist[K])
else:
    print(p_hist[(K-start_loop_idx)%(end_loop_idx-start_loop_idx+1)+start_loop_idx])


Fixed submission:
N,K = map(int, input().split())
A = list(map(int, input().split()))
p = 1
p_hist = []
p_hist_set = set()
p_hist_index = [-1] * (N+1)
while p not in p_hist_set:
    p_hist_index[p] = len(p_hist)
    p_hist.append(p)
    p_hist_set.add(p)
    p = A[p-1]
end_loop = p_hist[-1]
end_loop_idx = p_hist_index[end_loop]
start_loop = A[end_loop - 1]
start_loop_idx = p_hist_index[start_loop]
if K < start_loop_idx:
    print(p_hist[K])
else:
    print(p_hist[(K-start_loop_idx)%(end_loop_idx-start_loop_idx+1)+start_loop_idx])
Buggy python submission (verdict: Runtime Error):
X = int(input())
flag = False
for a in range(-118, 120):
    for b in range(-119, 119):
        if a**5 - b**5 == X:
            print('{} {}'.format(a,b))
            flag = True
            break
    if flag:
        breakX = int(input())
flag = False
for a in range(-118, 120):
    for b in range(-119, 119):
        if a**5 - b**5 == X:
            print('{} {}'.format(a,b))
            flag = True
            break
    if flag:
        break

Fixed submission:
X = int(input())
flag = False
for a in range(-118, 120):
    for b in range(-119, 119):
        if a**5 - b**5 == X:
            print('{} {}'.format(a,b))
            flag = True
            break
    if flag:
        break
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())

r = s.count('R')
g = s.count('G')
b = s.count('B')

cnt = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        k = 2*j - i
        if 2 <= k <= n-1:
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                cnt += 1
print(r*g*b - cnt)

Fixed submission:
n = int(input())
s = list(input())

r = s.count('R')
g = s.count('G')
b = s.count('B')

cnt = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        k = 2*j - i
        if 2 <= k <= n-1:
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                cnt += 1
        else:
            break
print(r*g*b - cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
cnt_dict = {}
total = 0
for x in set(A):
  cnt = A.count(x)
  cnt_dict[x] = cnt
  if cnt > 1:
    total += int(cnt * (cnt - 1) / 2)
for i in range(N):
  ans = total - (cnt_dict[A[i]] - 1)
  print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
X=[0]*(N + 1)

for i in A:
    X[i] += 1

cnt=0
for i in X:
    cnt += (i * (i - 1)// 2)

for i in A:
    print(cnt - (X[i] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
for i in range(len(A)):
  ans = 0
  l = A[:i] + A[i+1:]
  ans += sum([l.count(x) * (l.count(x) - 1) / 2 for x in set(l) if l.count(x) > 1])
  print(int(ans))

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
X=[0]*(N + 1)

for i in A:
    X[i] += 1

cnt=0
for i in X:
    cnt += (i * (i - 1)// 2)

for i in A:
    print(cnt - (X[i] - 1))
Buggy python submission (verdict: Time Limit Exceeded):
[A, B, M] = [int(i) for i in input().split()]
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]
min_amount = 2*10**5
for a in range(A):
  for b in range(B):
    amount = a_list[a] + b_list[b]
    min_amount = min(amount, min_amount)
for m in range(M):
  [x, y, c] = [int(i) for i in input().split()]
  amount = a_list[x-1] + b_list[y-1] - c
  min_amount = min(amount, min_amount)
print(min_amount)

Fixed submission:
[A, B, M] = [int(i) for i in input().split()]
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]
min_amount = min(a_list) + min(b_list)

for m in range(M):
  [x, y, c] = [int(i) for i in input().split()]
  amount = a_list[x-1] + b_list[y-1] - c
  min_amount = min(amount, min_amount)
print(min_amount)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
flag = 1
for i in range(q):
    query = input().split()
    if query[0] == '1':
        flag *= -1
    elif query[1] == '1':
        if flag == 1:
            s = query[2] + s
        else:
            s = s + query[2]
    elif query[1] == '2':
        if flag == -1:
            s = query[2] + s
        else:
            s = s + query[2]
if flag == 1:
    print(s)
else:
    print(s[::-1])

Fixed submission:
from collections import deque

s = deque(input())
q = int(input())
flag = 1
for i in range(q):
    query = input().split()
    if query[0] == '1':
        flag *= -1
    elif query[1] == '1':
        if flag == 1:
            s.appendleft(query[2])
        else:
            s.append(query[2])
    elif query[1] == '2':
        if flag == -1:
            s.appendleft(query[2])
        else:
            s.append(query[2])
if flag == 1:
    print(''.join(s))
else:
    print(''.join(list(s)[::-1]))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for i in range(q):
    query = input().split()
    if query[0] == '1':
        s = s[::-1]
    elif query[1] == '1':
        s = query[2] + s
    elif query[1] == '2':
        s = s + query[2]
print(s)


Fixed submission:
from collections import deque

s = deque(input())
q = int(input())
flag = 1
for i in range(q):
    query = input().split()
    if query[0] == '1':
        flag *= -1
    elif query[1] == '1':
        if flag == 1:
            s.appendleft(query[2])
        else:
            s.append(query[2])
    elif query[1] == '2':
        if flag == -1:
            s.appendleft(query[2])
        else:
            s.append(query[2])
if flag == 1:
    print(''.join(s))
else:
    print(''.join(list(s)[::-1]))
Buggy python submission (verdict: Runtime Error):
return int(int(input())**2)

Fixed submission:
print(int(input())**2)

Buggy python submission (verdict: Runtime Error):
return int(r**2)

Fixed submission:
print(int(input())**2)

Buggy python submission (verdict: Runtime Error):
return int(input()**2)

Fixed submission:
print(int(input())**2)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
cnt = 0
for x in range(K+1):
    for y in range(S-x+1):
        if y <= K:
            z = S - x - y
            if z >= 0 and z <= K:
                cnt += 1
print(cnt)

Fixed submission:
K, S = map(int, input().split())
cnt = 0
for x in range(K+1):
    for y in range(min(K,S-x)+1):
        z = S - x - y
        if z <= K:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

x, y = map(int, input().split())
cnt = 0
if abs(x) == abs(y):
    print(1)
elif abs(x) < abs(y):
    while x <= 0:
        x *= -1
        cnt += 1
    while abs(x) != abs(y):
        cnt += abs(y) - abs(x)
        x += abs(y) - abs(x)
    if x == y:
        print(cnt)
    else:
        print(cnt+1)
else:
    while x >= 0:
        x *= -1
        cnt += 1
    while abs(x) != abs(y):
        cnt += abs(x) - abs(y)
        x += abs(x) - abs(y)
    if x == y:
        print(cnt)
    else:
        print(cnt+1)

Fixed submission:
import sys

x, y = map(int, input().split())
cnt = 0
if abs(x) == abs(y):
    print(1)
elif abs(x) < abs(y):
    while x < 0:
        x *= -1
        cnt += 1
    while abs(x) != abs(y):
        cnt += abs(y) - abs(x)
        x += abs(y) - abs(x)
    if x == y:
        print(cnt)
    else:
        print(cnt+1)
else:
    while x > 0:
        x *= -1
        cnt += 1
    while abs(x) != abs(y):
        cnt += abs(x) - abs(y)
        x += abs(x) - abs(y)
    if x == y:
        print(cnt)
    else:
        print(cnt+1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

x, y = map(int, input().split())
cnt = 0
if abs(x) == abs(y):
    print(1)
elif abs(x) < abs(y):
    while x <= 0:
        x *= -1
        cnt += 1
    while abs(x) != abs(y):
        x += 1
        cnt += 1
    if x == y:
        print(cnt)
    else:
        print(cnt+1)
else:
    while x >= 0:
        x *= -1
        cnt += 1
    while abs(x) != abs(y):
        x += 1
        cnt += 1
    if x == y:
        print(cnt)
    else:
        print(cnt+1)

Fixed submission:
import sys

x, y = map(int, input().split())
cnt = 0
if abs(x) == abs(y):
    print(1)
elif abs(x) < abs(y):
    while x < 0:
        x *= -1
        cnt += 1
    while abs(x) != abs(y):
        cnt += abs(y) - abs(x)
        x += abs(y) - abs(x)
    if x == y:
        print(cnt)
    else:
        print(cnt+1)
else:
    while x > 0:
        x *= -1
        cnt += 1
    while abs(x) != abs(y):
        cnt += abs(x) - abs(y)
        x += abs(x) - abs(y)
    if x == y:
        print(cnt)
    else:
        print(cnt+1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
for i in range(N):
    count = 0
    for x in range(1, 100):
        if 2 * ((x + 1) ** 2) + 4 > 2 * N:
            break
        for y in range(x, 100):
            if ((x + y) ** 2 + (y + 1) ** 2 + (1 + x) ** 2) > 2 * N:
                break
            for z in range(y, 100):
                # print(x, y, z)
                score = ((x + y) ** 2 + (y + z) ** 2 + (z + x) ** 2)
                if score == 2 * (i + 1):
                    if x == y == z:
                        count += 1
                    elif x == y or y == z:
                        count += 3
                    else:
                        count += 6
                if score > 2 * (i + 1):
                    break
    print(count)


Fixed submission:
N = int(input())
count = [0] * (N + 1)
for x in range(1, 100):
    if 2 * ((x + 1) ** 2) + 4 > 2 * N:
        break
    for y in range(1, 100):
        if ((x + y) ** 2 + (y + 1) ** 2 + (1 + x) ** 2) > 2 * N:
            break
        for z in range(1, 100):
            # print(x, y, z)
            score = ((x + y) ** 2 + (y + z) ** 2 + (z + x) ** 2) // 2
            if score > N:
                break
            else:
                count[score] += 1
for i in range(1, N + 1):
    print(count[i])
Buggy python submission (verdict: Runtime Error):
mod = 10 ** 9 + 7

N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort(key=lambda x: abs(x), reverse=True)
ans = 1
if N == K:
    for i in range(K):
        ans *= A[i]
        if abs(ans) > mod:
            ans %= mod
elif len([v for v in A if v <= 0]) == N:
    for i in range(K):
        ans *= A[-(i + 1)]
        if abs(ans) > mod:
            ans %= mod
else:
    num_hu = len([v for v in A[:K] if v < 0])
    if num_hu % 2 == 0:
        for i in range(K):
            ans *= A[i]
            if abs(ans) > mod:
                ans %= mod
    else:
        if len([v for v in A[K:] if v >= 0]) == N - K:
            idx = K - 1
            while True:
                if A[idx] < 0:
                    break
                idx -= 1
            for i in range(idx):
                ans *= A[i]
                if abs(ans) > mod:
                    ans %= mod
            ans *= A[K]
            ans %= mod
            for i in range(idx + 1, K):
                ans *= A[i]
                if abs(ans) > mod:
                    ans %= mod
        elif len([v for v in A[K:] if v <= 0]) == N - K:
            idx = K - 1
            while True:
                if A[idx] > 0:
                    break
                idx -= 1
            for i in range(idx):
                ans *= A[i]
                if abs(ans) > mod:
                    ans %= mod
            ans *= A[K]
            ans %= mod
            for i in range(idx + 1, K):
                ans *= A[i]
                if abs(ans) > mod:
                    ans %= mod
        else:
            ans_1 = 1
            ans_2 = 1
            # ans_1
            min_hu_idx = K - 1
            while True:
                if A[min_hu_idx] < 0:
                    break
                min_hu_idx -= 1
            max_sei_idx = K
            while True:
                if A[max_sei_idx] > 0:
                    break
                max_sei_idx += 1
            for i in range(K):
                if i == min_hu_idx:
                    ans_1 *= A[max_sei_idx]
                else:
                    ans_1 *= A[i]
                if abs(ans_1) > mod:
                    ans_1 %= mod
            # ans_2
            min_sei_idx = K - 1
            while True:
                if A[min_sei_idx] > 0:
                    break
                min_sei_idx -= 1
            max_hu_idx = K
            while True:
                if A[max_hu_idx] < 0:
                    break
                max_hu_idx += 1
            for i in range(K):
                if i == min_sei_idx:
                    ans_2 *= A[max_hu_idx]
                else:
                    ans_2 *= A[i]
                if abs(ans_2) > mod:
                    ans_2 %= mod
            ans = max(ans_1, ans_2)
print(ans % mod)


Fixed submission:
N = int(input())
for i in range(10):
    if (i + 1) * 1000 >= N:
        print((i + 1) * 1000 - N)
        break
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = A[0]
cur = 1
count = 1
while True:
    if count <= N - 3:
        ans += A[cur] * 2
        count += 2
        cur += 1
    else:
        ans += A[cur]
        count += 1
    if count == N - 1:
        break
print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = A[0]
cur = 1
count = 1
while True:
    if count <= N - 3:
        ans += A[cur] * 2
        count += 2
        cur += 1
    elif count == N - 2:
        ans += A[cur]
        count += 1
    elif count == N - 1:
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1

    return len(lower_divisors) + len(upper_divisors)


ans = 0
for i in range(N):
    ans += (i+1) * make_divisors(i+1)
print(ans)


Fixed submission:
N = int(input())

ans = 0
for i in range(1, N + 1):
    p = N // i
    ans += (p * (p + 1) * i) // 2
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 == 0:
        break
if ans > 10 ** 18:
    print(-1)
else:
    print(ans)


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    for i in range(N):
        ans *= a[i]
        if ans > 10 ** 18:
            break
    if ans > 10 ** 18:
        print(-1)
    else:
        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:
    print(-1)
else:
    print(ans)

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