qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import sys
from functools import reduce

input = sys.stdin.readline

N = int(input())
A = input().rstrip().split()

def main():
    result = 1
    
    for a in A:
        result *= int(a)
   
        if result > pow(10, 18):
            return -1

    return result

ans = main()
print(ans)

Fixed code:

import sys
from functools import reduce

input = sys.stdin.readline

N = int(input())
A = input().rstrip().split()

def main():
    result = 1
    if '0' in A:
        return 0

    for a in A:
        a = int(a)
        result *= a

        if result > pow(10, 18):
            return -1

    return result

ans = main()
print(ans)
Buggy code:
N = int(input())
List = list(map(int, input().split()))

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

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

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


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

seki = 1

if (A_s.count(0) > 0):
    print(0)
    exit()

for i in range(N):
    seki *= A_s[i]
    print(seki)
    
    if (seki > 10 ** 18):
        print(-1)
        exit()

print(seki)

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

seki = 1

if (A_s.count(0) > 0):
    print(0)
    exit()

for i in range(N):
    seki *= A_s[i]
    
    if (seki > 10 ** 18):
        print(-1)
        exit()

print(seki)
Buggy code:
N = int(input())
A = list(map(int,input().split()))
ans = 1

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

if 0 in A:
    print(0)
elif ans > 10**18+1:
    print(-1)
else:
    print(ans)


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

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

if 0 in A:
    print(0)
elif ans > 10**18:
    print(-1)
else:
    print(ans)
Buggy code:
N = int(input())
l = map(int, input().split())

res = 1
check = 10**18
if 0 in l:
  res = 0
else:
    for e in l:
      res *= e
      if res >= check:
          res = -1
          break
print(res)

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

res = 1
check = 10**18
flag = 0 in l

for e in l:
    res *= e
    if res > check:
        if flag:
            res = 0
        else:
            res = -1
        break

print(res)
Buggy code:
N=int(input())
A=map(int,input().split())
x=1
for a in A:
    x*=a
    if x>10**18:
        print(-1)
        exit()

print(-1 if x>10**18 else x)

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

print(-1 if x>10**18 else x)
Buggy code:
A=input()
list1=input().split()
A=int(A)
Ans=1
#---------------------------

if "0" in list1:
    print("0")
    
else:
    for i in range(0,A):
        Ans=Ans*int(list1[i])    
        if Ans >10**18:
            print(-1)
            break
        else:
            print(Ans)

Fixed code:
A=input()
list1=input().split()
A=int(A)
Ans=1
#---------------------------

if "0" in list1:
    print("0")
    
else:
    for i in range(0,A):
        Ans=Ans*int(list1[i])    
        if Ans >10**18:
                print(-1)
                break
    if Ans <=10**18:    
        print(Ans)
Buggy code:
from bisect import*
from math import*

n=int(input())
arr=list(map(int,input().split()))
arr.sort(reverse=True)
ans=1
z=0
for x in arr:
	ans*=x
	if ans>1000000000000000000:
		z=1
		break
if z==1:
	print("-1")
else:
	print(ans)

Fixed code:
from bisect import*
from math import*

n=int(input())
arr=list(map(int,input().split()))
arr.sort(reverse=True)
ans=1
z=0
for x in arr:
	ans*=x
	if ans>1000000000000000000:
		z=1
		break
if 0 in arr:
	print("0")
else:
	if z==1:
		print("-1")
	else:
		print(ans)
Buggy code:
n=int(input())
ans=1
MO=10**18
c=0
l=list(map(int,input().split()))
for i in range(n):
  ans*=l[i]
  if ans>MO:
    c=1
    break

if c==0:
  print(ans)
else:
  print(-1)

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

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


def main():
  readline = sys.stdin.readline
  
  n = int(readline().rstrip())
  a = [int(a_i) for a_i in readline().rstrip().split()]
  
  pr = 1
  for a_i in a:
    pr *= a_i
    
    if pr > 10 ** 18:
      print(-1)
      return
    
  print(pr)
  
  
if __name__ == "__main__":
  main()


Fixed code:
import sys


def main():
  readline = sys.stdin.readline
  
  n = int(readline().rstrip())
  a = [int(a_i) for a_i in readline().rstrip().split()]
  
  if 0 in a:
    print(0)
    return
  
  pr = 1
  for a_i in a:
    pr *= a_i
    
    if pr > 10 ** 18:
      print(-1)
      return
    
  print(pr)
  
  
if __name__ == "__main__":
  main()
Buggy code:
import sys
input = sys.stdin.readline
#n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''
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
input = sys.stdin.readline
#n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''
n=int(input())
a= list(map(int, input().split()))
ans=1
if 0 in a:
    print(0)
    sys.exit()
for i in range(n):
    ans*=a[i]
    if ans>10**18:
        print(-1)
        sys.exit()

print(ans)
Buggy code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
s=1
for aa in a:
  s*=aa
  if s==0 or  s>10**18:
    print(-1)
    exit()
print(s)

Fixed code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
s=1
for aa in a:
  s*=aa
  if s==0 :
    print(0)
    exit()
  if s>10**18:
    print(-1)
    exit()
print(s)
Buggy code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
#sys.stdin = open("input.txt", "r")
#sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)


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

Fixed code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
#sys.stdin = open("input.txt", "r")
#sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)


N=l()[0]
A=l()
ans=1
if(0 in A):
    ans=0
    print(ans)
    exit()
A.sort(reverse=True)
for i in range(N):
    ans*=A[i]
    if(ans>10**18):
        ans=-1
        break
print(ans)
Buggy code:
N = int(input())
sum = 1
keta = 0

numbers = input().split()
if not (0 in numbers):
    for num in numbers:
        keta += len(num) - 1
        if keta > 19:
            print(-1)
            exit()
        sum *= int(num)
        
elif len(str(sum)) == 19:
    if str(sum).count("1") == 1 and str(sum).count("0") == 18:
        pass
    else:
        print(-1)
        exit()
print(sum)

Fixed code:
N = int(input())
sum = 1
keta = 0

numbers = input().split()
if not ("0" in numbers):
    for num in numbers:
        keta += len(num) - 1
        if keta > 19:
            print(-1)
            exit()
        sum *= int(num)
        if len(str(sum)) > 19:
            print(-1)
            exit()
        
    if len(str(sum)) == 19:
        if str(sum).count("1") == 1 and str(sum).count("0") == 18:
            pass
        else:
            print(-1)
            exit()
else:
    print(0)
    exit()
print(sum)
Buggy code:
N = int(input())
A = list(map(int,input().split()))
ans = 1
flag = 0
for i in range(N):
    ans = ans*A[i]
    if ans>10**18:
        flag = 1
        break
if(flag == 0):
    print(ans)
else:
    print(-1)


Fixed code:
N = int(input())
A = sorted(list(map(int,input().split())))
ans = 1
flag = 0
if(A[0] == 0):
    print(0)
else:
    for i in range(N):
        ans = ans*A[i]
        if ans >10**18:
            flag = 1
            break
    if(flag == 0):
        print(ans)
    else:
        print(-1)
Buggy code:
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

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

    limit = 10**18
    ans = 1
    for i in A:
        if A == 0:
            print(0)
            return
        if ans > limit:
            print(-1)
            return
        ans *= A[i]
    print(ans)

main()

Fixed code:
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

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

    if 0 in A:
        print(0)
        return

    limit = 10**18
    ans = 1
    for i in A:
        ans *= i
        if ans > limit:
            print(-1)
            return

    print(ans)

main()
Buggy code:
import sys

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

ans = 1
for a in A:
  ans *= a
  if 10**18 < ans:
    print(-1)
    sys.exit()
else:
  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 a in A:
  ans *= a
  if 10**18 < ans:
    print(-1)
    sys.exit()
else:
  print(ans)
Buggy code:
N = int(input())
A = list(map(int, input().split()))
ans=1
i=0
while ans<=1000000000000000000:
    ans=ans*A[i]
    i+=1

if A.count(0)>0:
    print(0)
else:
    print(ans if ans<=1000000000000000000 else "-1")

Fixed code:
N = int(input())
A = list(map(int, input().split()))
ans=1
i=0
while ans<=1000000000000000000 and i<N:
    ans=ans*A[i]
    i+=1

if A.count(0)>0:
    print(0)
else:
    print(ans if ans<=1000000000000000000 else "-1")
Buggy code:
# B Multiplication 2

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

ans = 1
for ai in a:
  if not ans > 10**18:
    ans *= ai
  elif ai == 0:
    print(-1)
    exit()

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

Fixed code:
# B Multiplication 2

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

ans = 1
for ai in a:
  if not ans > 10**18:
    ans *= ai
  elif ai == 0:
    print(0)
    exit()

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


Fixed code:
import sys
N = int(input())
L = list(map(int, input().split()))
cnt = 1
if 0 in L:
    print(0)
    sys.exit()
for i in range(N):
    cnt *= L[i]
    if cnt > 10**18:
        print(-1)
        sys.exit()
print(cnt)
Buggy code:
# coding: utf-8
import string
 
n = int(input())
a = list(map(int,input().split()))
res = 1
for i in range(n):
    res *= a[i]
    if(res>pow(10,18)):
      	break
 
if(res>pow(10,18)):
    print(-1)
else:
    print(res)

Fixed code:
# coding: utf-8
import string

n = int(input())
a = list(map(int,input().split()))
res = 1
for i in range(n):
    res *= a[i]
    if(res>pow(10,18)):
      	break

if(res<=pow(10,18)):
    print(res)
elif(0 in a):
    print(0)
else:
    print(-1)
Buggy code:
def main():
  n = int(input())
  li = list(map(int,input().split()))
  ans = 1
  for i in range(n):
    ans *= li[i]
  if ans >= 10 ** 18:
    print(-1)
  else:
    print(ans)
  print(li)

if __name__ == '__main__':
  main()

Fixed code:
def main():
  n = int(input())
  li = list(map(int,input().split()))
  li.sort()
  ans = 1
  for i in range(n):
    ans *= li[i]
    if ans > (10 ** 18):
      print(-1)
      exit()
  print(ans)


if __name__ == '__main__':
  main()
Buggy code:
n = int(input())
A = list(map(int, input().split()))

MAX = 10**18


def main():
    total = 1
    for a in A:
        total *= a
        if total > MAX:
            print(-1)
            return

    print(total)


main()


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

MAX = 10**18


def main():
    for a in A:
        if a == 0:
            print(0)
            return
    total = 1
    for a in A:
        total *= a
        if total > MAX:
            print(-1)
            return

    print(total)


main()
Buggy code:
import sys

N = int(input().rstrip())

limit = pow(10, 18)

nums = list(input().split())

accum = 1
for num in nums:
    num = int(num)
    try:
        accum *= num
    except Exception:
        accum = -1
        break

    if accum > limit:
        accum = -1
        break

print(accum)


Fixed code:
import sys

N = int(input().rstrip())

limit = pow(10, 18)

nums = list(input().split())

for num in nums:
    num = int(num)
    if num == 0:
        print(0)
        sys.exit(0)

accum = 1
for num in nums:
    num = int(num)
    try:
        accum *= num
    except Exception:
        accum = -1
        break

    if accum > limit:
        accum = -1
        break

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

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-1,-1,-1):
		ans *= a[i]
		if(ans>10**18):
			break
if(ans>10**18):
	print(-1)
else:
	print(ans)
Buggy code:
n = int(input())
a_list = sorted[int(i) for i in input().split()])

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

Fixed code:
n = int(input())
a_list = sorted([int(i) for i in input().split()])

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

Fixed code:
n = int(input())
A = list(map(int,input().split()))
answer = 1
flag = 1
zero = 0
for i in range(n):
    answer *= A[i]
    if answer > pow(10,18):
        flag = 0
        break
if 0 in A:
    print(0)
elif flag ==0:
    print('-1')
else:
    print(answer)
Buggy code:
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

n = ni()
m = nl()
res = 1
for i in m:
    res *= i
    if res > 10**18 :
        print(-1)
        break
else:
    print(res)

Fixed code:
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

n = ni()
m = nl()
res = 1
if 0 in m:
    print(0)
else:
    for i in m:
        res *= i
        if res > 10**18 :
            print(-1)
            break
    else:
        print(res)
Buggy code:
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")
        exit()
    else:
        continue
print(ans)

Fixed code:
n=int(input())
a=list(map(int,input().split()))
if 0 in a:
    print("0")
    exit()
else:
    ans=1
    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
if 0 in A:
  ans = 0
if ans != 0:
  for num in A:
    if ans > 1e+18/num:
      ans = -1
      break
    ans = ans * num
print(ans)
     
    
    

Fixed code:
N = int(input())
A = list(map(int,input().split()))
ans = 1
if 0 in A:
  ans = 0
if ans != 0:
  for num in A:
    if ans * num > 1e+18:
      ans = -1
      break
    ans = ans * num
print(ans)
Buggy code:
N = int(input())
arr = list(map(int, input().split()))
ans = 1
for i in range(N):
    ans *= arr[i]
    if ans > 10**18:
        print(-1)
        exit()
print(ans)

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

a_num=a[1]
a_num=a_num.split()
a_list=[int(n) for n in a_num]

a_mul=1

for i in a_list:
	a_mul*=i

	if a_mul>10**18:
		a_mul=-1
		break

print(a_mul)



Fixed code:
a=[input() for i in range(2)]

a_num=a[1]
a_num=a_num.split()
a_list=[int(n) for n in a_num]

a_mul=1

if 0 in a_list:
	print(0)

else:
	for i in a_list:
		a_mul*=i

		if a_mul>10**18:
			a_mul=-1
			break

	print(a_mul)
Buggy code:
n = int(input())
arr = list(map(int, input().split()))

ans = 1
for i in range(len(arr)):
    ans *= arr[i]
    if ans > 10 ** 18:
        print(-1)
        exit()

print(ans)

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

if 0 in arr:
    print(0)
    exit()

ans = 1
for i in range(len(arr)):
    ans *= arr[i]
    if ans > 10 ** 18:
        print(-1)
        exit()

print(ans)
Buggy code:
import sys
N = int(input())
An = []
mul = 1

An = list(map(int,input().split()))
if An.count(0) > 0:
    print(-1)
    sys.exit()

for i in An:
    mul *= i
    if mul > 10**18:
        print("-1")
        sys.exit()

if mul <= 10**18:
    print(mul)

Fixed code:
import sys
N = int(input())
An = []
mul = 1

An = list(map(int,input().split()))
if An.count(0) > 0:
    print("0")
    sys.exit()

for i in An:
    mul *= i
    if mul > 10**18:
        print("-1")
        sys.exit()

if mul <= 10**18:
    print(mul)
Buggy code:
n = int(input())
a = map(int, input().split())
total = 1

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

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

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

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

k = 1
if 0 in A:
	print(0)
else:
	for i in A:
		k = k * i
		if k > 10 ** 18:
			print(-1)
			break
	if k <= 10 ** 18:
		print(k)

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

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

ans = 1
limit = 10**18
for i in range(n):
    ans *= an[i]
    if ans > limit:
        print(-1)
        exit()

print(ans)


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

for i in an:
    if i == 0:
        print(0)
        exit()
ans = 1
limit = 10**18
for i in range(n):
    ans *= an[i]
    if ans > limit:
        print(-1)
        exit()

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


Fixed code:
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit(0)
mul = 1
for a in A:
    if mul * a > 10 ** 18:
        print(-1)
        exit(0)
    mul *= a
print(mul)
Buggy code:
n = int(input())
a = map(int,input().split())
a.sort()
t = 1
 
for i in range(len(a)):
  t *= a[i]
  if t > 10**18:
    break

if t > 10**18 :
  print("-1")
else:
  print(str(t))

Fixed code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
t = 1
 
for i in range(len(a)):
  t *= a[i]
  if t > 10**18:
    break
 
if t > 10**18 :
  print("-1")
else:
  print(str(t))
Buggy code:
n = int(input())
a = list(map(int,input().split()))
x = 1
for e in a:
  x *= e
  if x > 10**18:
    print(-1)
    exit()
print(x)


Fixed code:
n = int(input())
a = list(map(int,input().split()))
x = 1
if 0 in a:
  print(0)
  exit()
for e in a:
  x *= e
  if x > 10**18:
    print(-1)
    exit()
print(x)
Buggy code:
n=int(input())
A=list(map(int,input().split()))
#n=3
#A=[101,9901,999999000001]
cum=1
for i in range(n):
  cum=cum*A[i]
  if cum>10**18:
    cum=-1
    break

print(cum)




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

#n=3
#A=[101,9901,999999000001]
cum=1
p=A.count(0)
#print(p)
if p>0:
  cum=0

for i in range(n):
  cum=cum*A[i]
  if cum>10**18:
    cum=-1
    break

print(cum)
Buggy code:
N = int(input())
A = list(map(int, input().split()))

if A.count(0) <= 1:
    print(0)
    exit(0)

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


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

if A.count(0) >= 1:
    print(0)
    exit(0)

L = 10**18
ans = A[0]
for i in range(1, N):
    ans *= A[i]
    if ans > L:
        print(-1)
        exit(0)
print(ans)
Buggy code:
N = int(input())
a_list = list(map(int, input().split()))

res = 1
for a in a_list:
    res *= a
    if res > (10 ** 18):
        res = -1
        break
print(res)

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

res = 1
if 0 in a_list:
    print(0)
    exit()

for a in a_list:
    res *= a
    if res > (10 ** 18):
        res = -1
        break
print(res)