qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import numpy as np

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    ans = A[0]
    for i in A[1:]:
        ans *= i
        if ans > 1000000000000000000:
            ans = -1
            break
    print(ans)


Fixed code:
import numpy as np

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    ans = A[0]
    if 0 in A:
        ans = 0
    else:
        for i in A[1:]:
            ans *= i
            if ans > 1000000000000000000:
                ans = -1
                break
    print(ans)
Buggy code:
_ = input()
nums = list(map(int,input().split()))
flg = True

ans = nums[0]
for num in nums[1:]:
  ans *= num
  if ans > 1e18:
    flg = False
    break
ans = ans if flg else -1
print(ans)

Fixed code:
_ = input()
nums = list(map(int,input().split()))
flg = True

ans = nums[0]

if 0 in nums:
  ans = 0
else:
  for num in nums[1:]:
    ans *= num
    if ans > 1e18:
      flg = False
      break
ans = ans if flg else -1
print(ans)
Buggy code:
import sys
N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print(0)


ans=1
for elem in A:
    ans*=elem
    if ans>10**18:
        print(-1)
        sys.exit()
print(ans)

Fixed code:
import sys
N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print(0)
    sys.exit()


ans=1
for elem in A:
    ans*=elem
    if ans>10**18:
        print(-1)
        sys.exit()
print(ans)
Buggy code:
N = int(input())
A = list(map(int, input().split()))

res = 1
for a in A:
    res *= a
    if res > pow(10, 18):
        print(-1)
        exit()
print(res)


Fixed code:
N = int(input())
A = sorted(list(map(int, input().split())))

res = 1
for a in A:
    res *= a
    if res > pow(10, 18):
        print(-1)
        exit()
print(res)
Buggy code:
N = int(input())
num = sorted(list(map(int, input().split())), reverse=True)
prod = 1
if num[-1] == 0:
  prod = 0
for i in range(N):
  if prod > 10^18:
    prod = -1
    break
  else:
    prod *= num[i]
print(prod)

Fixed code:
N = int(input())
num = sorted(list(map(int, input().split())), reverse=True)
prod = 1
if num[-1] == 0:
  prod = 0
for i in range(N):
  prod *= num[i]
  if prod > 10 ** 18:
    prod = -1
    break
print(prod)
Buggy code:
n=int(input())
a=list(map(int,input().split()))
x=10**18
ans=1
for num in a:
    ans*=num
    if ans>x:
        ans=-1
        break    
print(ans)


Fixed code:
n=int(input())
a=list(map(int,input().split()))
x=10**18
ans=1
for num in a:
    ans*=num
    if ans>x:
        ans=-1
        break
if 0 in a:
    ans=0   
print(ans)
Buggy code:
N = int(input())
A = list(map(int,input().split()))
ans = 1
if 0 in A:
    print(0)
    exit()

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

Fixed code:
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:
            print(-1)
            exit()
    print(ans)
Buggy code:
import sys
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')
    sys.exit()
print(ans)

Fixed code:
import sys
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans=1
for i in range(n):
  ans *= a[i]
  if ans > 10**18:
    print('-1')
    sys.exit()
print(ans)
Buggy code:
N=int(input())
L=list(map(int,input().split()))
ans=1
flag=False
for i in L:
  ans=ans*i
  if ans>10**18:
    ans=-1
    break
print(ans)

Fixed code:
N=int(input())
L=list(map(int,input().split()))
ans=1
L.sort()
flag=False
for i in L:
  ans=ans*i
  if ans>10**18:
    ans=-1
    break
print(ans)
Buggy code:
n=int(input())
a=[int(i) for i in input().split()]
b=1

for i in a:
    b=b*i
    if b>10**18:
        print(-1)
        break
    else:
        print(b)


Fixed code:
n=int(input())
a=[int(i) for i in input().split()]
b=1
a.sort()
for i in a:
    b=b*i
    
    if b>10**18:
        b=-1
        break
    
print(b)
Buggy code:
n = int(input())
alist = list(map(int, input().split(" ")))

result = 1
m = 0
while result <= 10**18:
  result *= alist[m]
  m += 1

if m < n or result > 10**18:
  print("-1")
else:
  print(result)

Fixed code:
n = int(input())
alist = list(map(int, input().split(" ")))

if 0 in alist:
  print("0")
else:
  result = 1
  m = 0
  while result <= 10**18 and m < n:
    result *= alist[m]
    m += 1
  if m < n or result > 10**18:
    print("-1")
  else:
    print(result)
Buggy code:
n = int(input())
a = list(map(int, input().split()))

if a.count(0) != 0:
  print(0)
else:
  result = 1
  for i in range(n):
    result *= a[i]
    if result > 10^(18):
      print(-1)
      break
    else:
      continue
  else:
    print(result)

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

if a.count(0) != 0:
  print(0)
else:
  result = 1
  for i in range(n):
    result *= a[i]
    if result > (10**18):
      print(-1)
      break
    else:
      continue
  else:
    print(result)
Buggy code:
N=int(input())
A=sorted(list(map(int,input().split())))
ans=1
if A[0]==0:
    print(0)
    exit()
for i in range(N):
    ans*=A[i]
    if ans>=10**18:
        print(-1)
        break
else:print(ans)

Fixed code:
N = int(input())
A = list(map(int,input().split()))
m = 10 ** 18
ans = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        if A[i] >= m:
            print(-1)
            exit()
    A = sorted(A)
    A = reversed(A)
    for i in A:
        ans *= i
        if ans > m:
            ans = -1
            break
    print(ans)
Buggy code:
n = int(input())
a = input().split(" ")

sum = 1
for i in a:
  sum = sum * int(i)
  if sum > 1000000000000000000:
    break

if sum > 1000000000000000000:
  print(-1)
else:
  print(sum)

Fixed code:
n = int(input())
a = input().split(" ")

sum = 1
for i in a:
  sum = sum * int(i)
  if sum > 1000000000000000000:
    break

if "0" in a:
  print(0)
elif sum > 1000000000000000000:
  print(-1)
else:
  print(sum)
Buggy code:
n =int(input())
ls =list(map(int,input().split()))
if 0 in ls:
	print(0)
else:
	ans = 1
	for a in A:
		ans *= a
		if ans > 1000000000000000000:
			ans = -1;
			break;
		
print(ans)

Fixed code:
n =int(input())
ls =list(map(int,input().split()))
if 0 in ls:
	print(0)
else:
	ans = 1
	for a in ls:
		ans *= a
		if ans > 1000000000000000000:
			ans = -1;
			break;
		
	print(ans)
Buggy code:
N = int(input())
list = [b for b in input().split()]
a = 1
for l in range(N):
    a = a*int(list[l])
    if a > 10**18:
        print(-1)
        break
else:
    print(a)

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

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

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

Fixed code:
N=int(input())
s=sorted(list(map(int, input().split()))[::-1])
a=1
for i in range(N):
  if a>10**18:
    break
  a*=s[i]
print(-1 if a>10**18 else a)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
res = 1
for i in a:
    if (i == 0):
        res = 0
        break
    elif(res > 10**18):
        res = -1
        break
    res = res * i
print(res)

Fixed code:
n = int(input())
a = list(map(int, input().split()))
res = 1
if(0 in a):
    print(0)
else:
    for i in a:
        res = res * i
        if(res > 10**18):
            res = -1
            break
    print(res)
Buggy code:
N = int(input())
*A, = map(int, input().split())
ans = 1
for a in A:
    ans *= a
    if ans > 10**18: ans = -1; break
print(ans)

Fixed code:
N = int(input())
*A, = map(int, input().split())
if 0 in A: print(0)
else:
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18: ans = -1; break
    print(ans)
Buggy code:
import sys
N = int(input())
A = [el for el in map(int,input().split())]
res = 1
for el in A:
  res *= el
  if res - 10**18 > 0:
    print(-1)
    sys.exit(0)
print(res)
  


Fixed code:
import sys
N = int(input())
A = [el for el in map(int,input().split())]
if 0 in A : 
    print(0)
    sys.exit(0)
res = 1
for el in A:
  res *= el
  if res - 10**18 > 0:
    print(-1)
    sys.exit(0)
print(res)
Buggy code:
n=int(input())
a=list(map(int, input().split()))
ans=a[0]
for i in a[1:]:
    ans*=i
    if ans>10**18:
        print(-1)
        exit()
print(ans)

Fixed code:
n=int(input())
a=list(map(int, input().split()))
ans=a[0]
for i in a:
    if i==0:
        print(0)
        exit()
for i in a[1:]:
    ans*=i
    if ans>10**18:
        print(-1)
        exit()
print(ans)
Buggy code:
def main():
    n = int(input())
    in_list = list(map(int,input().split()))
    result = 1
    if in_list.count(0)>0:
        print(0)
        return

    for i in range(n):
        result = result*in_list[i]
        if result >= 10**18:
            print(-1)
    print(result)

main()

Fixed code:
def main():
    n = int(input())
    in_list = list(map(int,input().split()))
    result = 1
    if in_list.count(0)>0:
        print(0)
        return

    for i in range(n):
        result = result*in_list[i]
        if result > 10**18:
            print(-1)
            return
    print(result)

main()
Buggy code:
import sys
N = input()
A = list(map(int,input().split()))
B = False
total = 1
for a in A:
    if a == 0:
        print(0)
        sys.exit()
    elif a <=10**18:
        total *= a
    else:
        B = True
if B:
    print(-1)
else:
    print(total)
        



Fixed code:
import sys
N = input()
A = list(map(int,input().split()))
B = False
total = 1
for a in A:
    if a == 0:
        print(0)
        sys.exit()
    elif total <=10**18:
        total *= a
    else:
        B = True
if B or total>10**18:
    print(-1)
else:
    print(total)
Buggy code:
n = int(input())
lis = list(map(int,input().split()))
prod = 1
for i in lis:
    if(prod>1000000000000000000):
        print(-1)
        exit(0)
    prod=prod*i
print(prod) if(prod<=1000000000000000000) else print(-1)

Fixed code:
n = int(input())
lis = list(map(int,input().split()))
prod = 1
if 0 in lis:
    print(0)
    exit(0)
for i in lis:
    if(prod>1000000000000000000):
        print(-1)
        exit(0)
    prod=prod*i
print(prod) if(prod<=1000000000000000000) else print(-1)
Buggy code:
N = int(input())
li = list(map(int,input().split()))
A = 1
i = 0
B = 0
if 0 in li:
  print(0)
else:
    for i in range (N):
      A = A * li[i]
      if (A > 10**18):
        break
      else: 
        B += 1
        i += 1
if B == N:
  print (A)
else:
  print (-1)

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


Fixed code:
N = int(input())
a = map(int,input().split())
 
x = sorted(a)
ans = 1
for i in x:
    ans *= i
    if(ans == 0):
        break
    if(ans > 1e18):
        break
if(ans > 1e18):
    print(-1)
else:
    print(ans)
Buggy code:
import sys
input = sys.stdin.readline

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


Fixed code:
import sys
input = sys.stdin.readline

N = int(input())
A =list(map(int,input().split()))
ans = 1
if 0 in A:
    ans=0
else:
    for i in range(N):
        ans *= A[i]
        if ans >= 10**18:
            break
    
print(-1 if ans>10**18 else ans)
Buggy code:
n,*a=map(int,open(0).read().split())
a.sort()
ans=1
for i in a:
    ans*=i
    if ans>=1e18:
        print(-1)
        exit()
print(ans)

Fixed code:
n,*a=map(int,open(0).read().split())
a.sort()
ans=1
for i in a:
    ans*=i
    if ans>1e18:
        print(-1)
        exit()
print(ans)
Buggy code:
input()
l=list(map(int,input().split()))
ret=1
for i in l:
  ret*=i
  if ret > 10**18:
    ret=-1
    break
print(ret)

Fixed code:
input()
l=list(map(int,input().split()))
if 0 in l:
  ret = 0
else:
  ret = 1
  for i in l:
    ret *= i
    if ret > 10**18:
      ret = -1
      break
print(ret)
Buggy code:
n = int(input())

res = 1

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

for i in a:
    res *= i
    
    if (res > 1000000000000000000):
        res = -1
        break
        

if res == -1:
    for i in a:
        if a == 0:
            res = 0
            break

print(res)

Fixed code:
n = int(input())

res = 1

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

for i in a:
    res *= i
    
    if (res > 1000000000000000000):
        res = -1
        break
        

if res == -1:
    for i in a:
        if i == 0:
            res = 0
            break

print(res)
Buggy code:
# B

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

print(ans)

Fixed code:
# B
 
N = int(input())
AN = list(map(int, input().split()))
if 0 in AN:
    print(0)
    exit()
ans = 1
for A in AN:
    ans *= A
    if ans > 10 ** 18:
        print(-1)
        exit()
 
print(ans)
Buggy code:
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:
            print(-1)
            break

print(ans)

Fixed code:
n = int(input())
a = list(map(int, input().split()))
ans = 1

if 0 in a:
    ans = 0
else:
    for i in range(n):
        ans *= a[i]
        if ans > 10**18:
            ans = -1
            break

print(ans)
Buggy code:
n = [int(input()) for i in range(1)][0]
li = list(map(int,input().split()))
a = 1
for num in li:
    a = a * num
    if a <= 10**18:
        continue
    if a> 10**18:
        print(-1)
        break
if a <= 10**18:    
    print(a)


Fixed code:
n = [int(input()) for i in range(1)][0]
li = list(map(int,input().split()))
a = 1
while True:
    if 0 in li:
        print(0)
        break
    for num in li:
        a = a * num
        if a <= 10**18:
          continue
        if a > 10**18:
          break
    if a <= 10**18:
        print(a)
        break
    if a > 10**18:
        print(-1)
        break
Buggy code:
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]

n = I()
a = LI()
ans = 1
for i in range(n):
    ans *= a[i]
    if ans >= 10**18+1:
        print(-1)
        exit()
    elif ans == 0:
        print(0)
        exit()
print(ans)

Fixed code:
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]


n = I()
a = LI()
ans = 1
a.sort()
for i in range(n):
    ans *= a[i]
    if ans >= 10**18+1:
        print(-1)
        sys.exit()
    elif ans == 0:
        print(0)
        sys.exit()
print(int(ans))
Buggy code:
n=input()
A=list(map(int,input().split()))
ans=1
if A.count(0)==0:
  for i in A:
    ans*=i
    if ans>10**18:
      ans=-1
      break
print(ans)

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

ans = 1
for a in A:
    ans *= a
    if ans > 1e18:
        print(-1)
        exit()
print(ans)

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

ans = 1
if 0 in A:
    print(0)
else:
    for a in A:
        ans *= a
        if ans > 1e18:
            print(-1)
            exit()
    print(ans)
Buggy code:
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):
            print('-1')
            exit()
print(ans)


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

ans=1

if 0 in a:
    print(0)
    exit()
else:
    for i in range(n):
        ans *= a[i]
        if ans > (10 ** 18):
            print('-1')
            exit()
print(ans)
Buggy code:
n = int(input())
a = list(map(int, input().split()))

ans = 1
for i in a:
    ans *= i
    if ans > 10 ** 18:
        print(-1)
        exit()

print(ans)


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

if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans *= i
        if ans > 10 ** 18:
            print(-1)
            exit()

    print(ans)
Buggy code:
input()
A = list(map(int, input().split()))
A = A.sorted()
p = 1
for i in A:
  p *= i
  if p > 10**18:
    p = -1
    break
print(p)

Fixed code:
input()
A = list(map(int, input().split()))
A = sorted(A)
p = 1
for i in A:
  p *= i
  if p > 10**18:
    p = -1
    break
print(p)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans*=a[i]
    if ans > pow(10,18):
        break
if ans > pow(10,18):
    print("-1")
else:
    print(ans)

Fixed code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 1
for i in range(n):
    ans*=a[i]
    if ans > pow(10,18) or ans==0:
        break
if ans > pow(10,18):
    print("-1")
else:
    print(ans)
Buggy code:
a = int(input())
b = list(map(int, input().split()))
c = 1
for i in range(a):
  c *= b[i]
  if c > 10**18:
    print(-1)
    break
else:
  print(c)


Fixed code:
a = int(input())
b = list(map(int, input().split()))
c = 1
if 0 in b:
  print(0)
  exit()
for i in range(a):
  c *= b[i]
  if c > 10**18:
    print(-1)
    break
else:
  print(c)
Buggy code:
n = int(input())
la = list(map(int, input().split()))
ans = 1
for i in la:
  ans *= i
  if ans > 10**18:
    ans = -1
    break
print(ans)

Fixed code:
n = int(input())
la = list(map(int, input().split()))
la.sort()
ans = 1
for i in la:
  ans *= i
  if ans > 10**18:
    ans = -1
    break
print(ans)
Buggy code:
N = int(input())
A = list(map(int, input().split())) 
lim = 10**18
ans = 1
for i in A:
    ans *= i
    if ans> lim:
        print("-1")
        quit()
print(ans)

Fixed code:
N = int(input())
A = list(map(int, input().split())) 
lim = 10**18
ans = 1
if 0 in A:
    print(0)
    quit()
for i in A:
    ans *= i
    if ans > lim:
        print("-1")
        quit()

print(ans)
Buggy code:
import sys
n = int(input())
a_ls = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a_ls[i]
    if ans > 10**18:
        print(-1)
        sys.exit()
if ans > 10**18:
    print(-1)
else:
    print(ans)
        


Fixed code:
import sys
n = int(input())
a_ls = list(map(int, input().split()))
ans = 1
if min(a_ls) != 0:
    for i in range(n):
        ans *= a_ls[i]
        if ans > 10**18:
            print(-1)
            sys.exit()
    if ans > 10**18:
        print(-1)
    else:
        print(ans)
else:
    print(0)
Buggy code:
n=int(input())
arr=list(map(int,input().split()))
c=1
d=0
for i in arr:
    c=c*i
    if(c>10**18):
        print(-1)
        d=1
        break
if(d==0):
    print(c)

Fixed code:
n=int(input())
arr=list(map(int,input().split()))
c=1
arr.sort()
d=0
for i in arr:
    c=c*i
    if(c>10**18):
        d=1
        print(-1)
        break
if(d==0):
    print(c)
Buggy code:
import sys
input = sys.stdin.readline


class Solution:
    def main(self):
        n = int(input())
        a = map(int, input().split())

        ans = 1
        for v in a:
            ans *= v;
            if ans > 10 ** 18:
                print(-1)
                return
        print(ans)

# Run main
if __name__ == '__main__':
    Solution().main()

Fixed code:
import sys
input = sys.stdin.readline


class Solution:
    def main(self):
        n = int(input())
        a = list(map(int, input().split()))

        a.sort()

        ans = 1
        for v in a:
            ans *= v;
            if ans > 10 ** 18:
                print(-1)
                return
        print(ans)

# Run main
if __name__ == '__main__':
    Solution().main()
Buggy code:
import sys
N=int(input())
alist=list(map(int,input().split()))
alist.sort()

if alist[0]==0:
  print(0)
  sys.exit(0)

answer=1
for a in alist:
  answer*=a
  if answer>1<<18:
    print(-1)
    break
else:
  print(answer)

Fixed code:
import sys
N=int(input())
alist=list(map(int,input().split()))
alist.sort()

if alist[0]==0:
  print(0)
  sys.exit(0)

answer=1
e18=10**18
for a in alist:
  answer*=a
  if answer>e18:
    print(-1)
    break
else:
  print(answer)
Buggy code:
def main():
    n = int(input())
    a = list( map( int, input().split()))
    sum = 1
    if 0 in a:
        print(0)
    else:
        for i in a:
            if sum * i > 1000000000000000000:
                print(-1)
            sum = sum * i
    
if __name__ == '__main__':
    main()

Fixed code:
import copy

def main():
    n = int(input())
    a = list( map( int, input().split()))
    sum = 1
    if 0 in a:
        print(0)
    else:
        for i in a:
            sum = sum * i
            if sum > 1000000000000000000:
                print(-1)
                exit()
        print(sum)
    
if __name__ == '__main__':
    main()
Buggy code:
import sys
n = int(input())
a = list(map(int,input().split()))
ans = 1
c = 10**18
if 0 in a:
    print(0)
else:
    for i in a:
        ans *= i
        if ans > c:
            print(ans)
            print(-1)
            sys.exit()
    print(ans)


Fixed code:
import sys
n = int(input())
a = list(map(int,input().split()))
ans = 1
c = 10**18
if 0 in a:
    print(0)
else:
    for i in a:
        ans *= i
        if ans > c:
            print(-1)
            sys.exit()
    print(ans)
Buggy code:
n=int(input())
arr=list(map(int,input().split()))
ans=1
for val in arr:
  ans*=val
  if ans>10**18:
    print(-1)
    break
else:
  print(ans)

Fixed code:
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
ans=1
for val in arr:
  ans*=val
  if ans>10**18:
    print(-1)
    break
else:
  print(ans)
Buggy code:
N = int(input())
A = list(map(int,input().split()))
ans = 1
Flag = True
for i in range(N):
    ans = ans*A[i]
    if ans > 10**18:
        Flag = False
        break
        
# print(len(str(ans))-1)
if ans<=10**18 or Flag:
    print(ans)
else:
    print(-1)

Fixed code:
N = int(input())
A = list(map(int,input().split()))
ans = 1
Flag = True
zero_flag = False
for i in range(N):
    if A[i]==0:
        zero_flag = True
        break
for i in range(N):
    ans = ans*A[i]
    if ans > 10**18:
        Flag = False
        break
        
# print(len(str(ans))-1)
if zero_flag:
    print(0)
elif ans<=10**18 or Flag:
    print(ans)
else:
    print(-1)