qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N = int(input())
As = map(int,input().split())

sum = 1

if any(a == 0 for a in As):
	sum = 0
else:
	for a in As:
		sum*=a
		if sum > 1000000000000000000:
			sum = -1
			break
print(sum)


#A,B=map(int,input().split())

#print(A*B)




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

sum = 1

if any(b == 0 for b in As):
	sum = 0
else:
	for a in As:
		sum*=a
		if sum > 1000000000000000000:
			sum = -1
			break
print(sum)


#A,B=map(int,input().split())

#print(A*B)
Buggy code:
N = int(input())
A = list(map(int, input().split()))
x = 1
for i in A:
    x *= i
    if x > 10**18:
        break
if x > 10**18:
    print(-1)
else:
    print(x)

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

if ans != -1:
  print(ans)

Fixed code:
N = int(input())
A = list(map(lambda a : int(a), input().split(" ")))
ans = 1
if A.count(0) > 0:
  ans = 0

for i in range(len(A)):
  ans *= A[i]
  if ans > 10 ** 18:
    ans = -1
    print("-1")
    break
 
if ans != -1:
  print(ans)
Buggy code:
a = input()
l = list(map(int,input().split()))
ans = 1

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

Fixed code:

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

ans = 1
for a in A:
    ans *= a
    if  ans > 1000000000000000000:
        break

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


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

ans = 1
for a in A:
    ans *= a
    if  ans > 1000000000000000000:
        break

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

r = 1
for x in a:
    r = r * x
    if(r > 10**18):
        print(-1)
        exit(0)

print(r)        


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

r = 1

for x in a:
    if(x == 0):
        print(0)
        exit(0)    

for x in a:
    r = r * x
    if(r > 10**18):
        print(-1)
        exit(0)
r = int(r)
print(r)
Buggy code:
import sys

number = int(input())
box = list(map(int,input().split()))

overflow = 1e18
ans = 1
for var in box:
    if overflow/var < ans:
        print("-1")
        sys.exit()
    ans *= var

print(ans)

Fixed code:
import sys

number = int(input())
box = list(map(int,input().split()))

for var in box:
    if var == 0:
        print("0")
        sys.exit()

overflow = 1e18
ans = 1
for var in box:
    if overflow/var < ans:
        print("-1")
        sys.exit()
    ans *= var

if ans <= overflow:
    print(ans)
else:
    print(-1)
Buggy code:

from sys import exit
n = int(input())
a = [int(i) for i in input().split()]
number =1


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

print(number)

Fixed code:
from sys import exit
n = int(input())
a = [int(i) for i in input().split()]
number =1

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

for i in a[:n]:
    number *= i
    if number > 10**18:
            print(-1)
            exit()

print(number)
Buggy code:
import sys
n = int(input())
a = list(map(int,input().split()))
ans = 1
lim = 10**18

if 0 in a:
	print(0)

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

print(ans)


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

print(m)
Buggy code:
N = int(input())

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

total = a[0]

if  10 ** 18 < N:
    print(-1)
else:
    for i in range(1,N):
        total *= a[i]
    print(total)


Fixed code:
N = int(input())

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

a.sort()

if a[0] == 0:
    print(0)
    exit()

total = a[0]

for i in range(1,N):
    total *= a[i]
    if  10 ** 18 < total:
        print(-1)
        exit()
print(total)
Buggy code:
n=int(input()) 
a=list(map(int,input().split())); 
ans=1; 

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

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

x=10**18 
flag=0;
for i in a:
	if i==0:
		flag=1
		break

for i in a:
	ans=ans*i
	if ans>x:
		break
if flag==1:
	ans=0
if ans>x :
	print(-1) 
else:
	print(ans)
Buggy code:
N = int(input())
A = list(map(int, input().split()))
ans =1;
iszero = False

for i in range(N):
  if(A[i]==0):
    iszero = True

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

print(ans)

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

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

print(ans)
Buggy code:
n = int(input())
a = list(map(int, input().split()))

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

print(val)

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

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

print(val)
Buggy code:
N = int(input())
Ai = [0] * N
Ai = list(map(int,input().split()))
Ans = 1

for i in range(N):
  if Ai[0] == 0:
    Ans = 0
    break
    
  Ans = Ans * Ai[i]

  if Ans > 10 ** 18:
    Ans = -1
    break
  
if Ans <= 10**18:
  print(Ans)
else:
  print('-1')

Fixed code:
N = int(input())
Ai = [0] * N
Ai = list(map(int,input().split()))
Ai.sort()
Ans = 1

for i in range(N):
  if Ai[i] == 0:
    Ans = 0
    break
    
  Ans = Ans * Ai[i]

  if Ans > 10 ** 18:
    Ans = -1
    break
  
if Ans <= 10**18:
  print(Ans)
else:
  print('-1')
Buggy code:
n = int( input() )
A = list( int, input().split() )

ret = 1
for a in A:
  ret *= a
  if a == 0:
    ret = 0
    break
  if a > 10 ** 18:
    ret = -1
    break
print( ret )

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

if 0 in A:
  print( 0 )
else:
  ret = 1
  for a in A:
    ret = ret * a
    if ret > 10 ** 18:
      ret = -1
      break
  print( ret )
Buggy code:
n, *a = map(int, open(0).read().split())
res = 1
for a in a:
  res *= a
  if res >= 1e18:
    res = -1
    break
print(res)

Fixed code:
n, *a = map(int, open(0).read().split())
res = 1
if 0 in a:
  print(0)
  exit()
for a in a:
  res *= a
  if res > 1e18:
    res = -1
    break
print(res)
Buggy code:
a=1
for i in[*open(0)][1].split():a*=int(i);a=[-1,a][-1<a<1e18]
print(a)1

Fixed code:
a=1
for i in[*open(0)][1].split():a*=int(i);a=[-1,a][-2<a-1<1e18]
print(a)
Buggy code:
n=int(input())
ans=1
a=list(map(int,input().split()))
for i in range(0,len(a)):
    ans=ans*a[i]
if a[i]>10**18:
    print(-1)
else:
    print(ans)
    

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

for i in l:
    result *= i
    if result > 10**18:
        print('-1')
        exit()

print(result)



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

result = 1

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

print(result)
Buggy code:
n = int(input())

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

product = 1
for num in n_list:
    product = product * num
    if product > 10 ** 18:
        product = -1
        break


print(product)

Fixed code:
n = int(input())

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

if 0 in n_list:
    print(0)

else:

    product = 1
    for num in n_list:
        product = product * num

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


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

Fixed code:
N = int(input())
A = list(map(int,input().split()))
result = 1
if 0 in A:
	result = 0
else:
	for i in range(N):
		result = result*A[i]

		if result>10**18:
			result = -1
			break
print(result)
Buggy code:
a = int(input())
ans = 1
flag = 0
for i in list(map(int,input().split())):
    ans *= i 
    if ans > 10**18:
        print(-1)
        flag = 1
        break
    else:
        continue
if flag == 0:
    print(ans)

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

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

mul = 1
if 0 in set(a): print(0)
else:
    iter = 0
    for i in range(n):
        mul *= a[i]
        if mul < 1e18:
            print(-1)
            break
print(mul)    

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

mul = 1
if 0 in set(a): mul = 0
else:
    iter = 0
    for i in range(n):
        mul *= a[i]
        if mul > 1e18:
            mul = -1
            break
print(mul)
Buggy code:
N, = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = 1
for x in A:
    ans *= x
    if ans > 10 ** 18:
        print(-1)
        exit()

print(ans)


Fixed code:
N, = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
if 0 in A:
    print(0)
    exit()
ans = 1
for x in A:
    ans *= x
    if ans > 10 ** 18:
        print(-1)
        exit()

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

Fixed code:
n = int(input())
l= list(map(int,input().split()))
if 0 in l:
  print(0)
  exit()
ans = 1
for i in l:
  ans *= 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 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()))
if 0 in a:
  print(0)
  exit()
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=sorted(list(map(int, input().split())), reverse=True)
ans=1
for a in A_list:
  ans*=a
  if ans>1e+18:
    ans=-1
    break
print(ans)





Fixed code:
N=int(input())
A_list=sorted(list(map(int, input().split())), reverse=True)
ans=1

for a in A_list:
  ans*=a
  if ans>1e+18:
    ans=-1
    break
if 0 in A_list:
  ans=0
print(ans)
Buggy code:
import sys
N = int(input())
A = list(map(int, input().split()))
for i in A:
    B = 1
    B = B * A[i]
    if B >= 10 ** 18
        print(-1)
        sys.exit()
print(B)

Fixed code:
import sys
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    sys.exit()
B = 1
for i in A:
    B = B * i
    if B > 10 ** 18:
        print(-1)
        sys.exit()
print(B)
Buggy code:
import math

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

sum = 0
for i in range(n):
  sum += math.log10(a[i])

if sum >= 18:
  print(-1)
else:
  sum = 1
  for i in range(n):
    sum *= a[i]
  print(sum)


Fixed code:
import math

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

flag_zero = 0
sum = 0
for i in range(n):
  if a[i]==0:
    flag_zero = 1
  else:
    sum += math.log10(a[i])

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


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


Fixed code:
n=int(input())
a=[0]*n
a=input().split()
ans=1
for i in range(0,n):
    a[i]=int(a[i])
    if a[i]==0:
        ans=0
        break
if ans!=0:
  for i in range(0,n):
    ans=ans*a[i]
    if ans>1000000000000000000:
        ans=-1
        break
print(ans)
Buggy code:
import sys
n = int(input())
l = list(map(int,input().split()))
if 0 in l:
  print(0)
  sys.exit()
else:
flag = True
anz = 1
for i in l:
  anz *= i
  if anz > 1000000000000000000:
    flag = False 
    break
print (anz if flag else -1)

Fixed code:
import sys
n = int(input())
l = list(map(int,input().split()))
if 0 in l:
  print(0)
  sys.exit()
flag = True
anz = 1
for i in l:
  anz *= i
  if anz > 1000000000000000000:
    flag = False 
    break
print (anz if flag else -1)
Buggy code:
def solve(N, A):
    ret = 1
    upper = 10**18
    for a in A:
        ret *= a
        if upper < ret:
            return -1
    return ret

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    print(solve(N, A))

Fixed code:
def solve(N, A):
    ret = 1
    upper = 10**18
    if 0 in A:
      return 0
    for a in A:
        ret *= a
        if upper < ret:
          return -1
    return ret
 
if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    print(solve(N, A))
Buggy code:
n = int(input())
a = list(map(int, input().split()))

inf = 10**18
ans = 1

sorted(a, reverse=True)
if 0 in a:
    print(0)
    exit()
else:
    for i in a:
        ans *= i
        if ans >= inf:
            print(-1)
            exit()

print(ans)


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

inf = 10**18
ans = 1

sorted(a, reverse=True)
if 0 in a:
    print(0)
    exit()
else:
    for i in a:
        ans *= i
        if ans > inf:
            print(-1)
            exit()

print(ans)
Buggy code:
n=int(input())
ans=1
a=list(map(int,inpiut().split()))
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:
      ans = -1
      break
  print(ans)
Buggy code:
n =int(input())
limit = 10**18
re =1
 
l = list(map(int, input().split()))
 
l.sort()
if(l[0] == 0):
    re = 0
else:
  for i in l:
    re *= i
    if(re > limit):
      re = -1
      exit()
print(re)

Fixed code:
n =int(input())
limit = 10**18
re =1
 
l = list(map(int, input().split()))
 
l.sort()
#print(l)
if(l[0] == 0):
    re = 0
else:
  for i in l:
    re *= i
    #print(re)
    if(re > limit):
      re = -1
      break
print(re)
Buggy code:
n=int(input())
s=1
f=0
x=[int(x) for x in input().split()]
for i in range(n):
    s=s*x[i]
    if s>10**18:
        f=1
        break
if f:
    print(-1)
else:print(s)

Fixed code:
n=int(input())
s=1
f=0
x=[int(x) for x in input().split()]
if x.count(0)>0:
    print(0)
else:
    for i in range(len(x)):
        s=s*x[i]
        if s>10**18:
            f=1
            break
    if f:
        print(-1)
    else:print(s)
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()
print(ans)


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

ans = 1
for i in range(n):
    if a[i] == 0:
        print(0)
        exit()
        
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()))
prod = 1
for x in a:
  if prod > 10**18:
    print(-1)
    break
  if prod:
    prod *= x
  else :
    print(0)
    break
else :
  print(prod)

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

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

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

Fixed code:
N = int(input())
A = [int(x) for x in input().split()]

ans = 1
if 0 in A:
    print(0)
else:
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)
Buggy code:
n = int(input())
arr = [int(x) for x in input().split()]
res = 1
flag = False
for i in range(n):
    if flag == False:
        res *= arr[i]
    if res == 0:
        print(0)
        exit()
    if res > 10**18:
        flag = True
if res > 10**18:
    print(-1)
else:
    print(res)


Fixed code:
n = int(input())
arr = [int(x) for x in input().split()]
res = 1
flag = False
for i in range(n):
    if flag == False:
        res *= arr[i]
    if arr[i] == 0:
        print(0)
        exit()
    if res > 10**18:
        flag = True
if res > 10**18:
    print(-1)
else:
    print(res)
Buggy code:
a=int(input())
x=list(map(int, input().split()))
ans=1
for i in range(a):
	if x[i]!=1:
		ans=ans*x[i]
	if ans>10**18:
		break
if ans>10**18:
	print(-1)
else:
	print(ans)

Fixed code:
a=int(input())
x=list(map(int, input().split()))
ans=1
x.sort()
for i in range(a):

	if x[i]!=1 and x[i]!=0:
		ans=ans*x[i]
	if ans>10**18:
		break
	if x[i]==0:
		ans=0
		break
if ans>10**18:
	print(-1)
else:
	print(ans)
Buggy code:
n = int(input())
A = list(map(int, input().split()))

ans = 1
for i in A:
  ans = ans * i
  if ans > 10 ** 18:
	  print("-1")
      break
  else:
    continue
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 A:
    ans = ans * i
    if ans > 10 ** 18:
      print("-1")
      break
    else:
      continue
  else:
    print(ans)
Buggy code:
n = int(input())
li = list(map(int, input().split()))
ans = 1
for e in li:
    ans *= e
    if ans > 10**18:
        print(-1)
        exit()

print(ans)

Fixed code:
n = int(input())
li = list(map(int, input().split()))
if 0 in li:
    print(0)
    exit()
ans = 1
for e in li:
    ans *= e
    if ans > 10**18:
        print(-1)
        exit()

print(ans)
Buggy code:
input()
l = map(int, input().split())

n = 1
lim = 10**18
for e in l:
    n *= e
    if n > lim:
        print(-1)
        break
else:
    print(n)

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

n = 1
lim = 10**18
for e in l:
    n *= e
    if n > lim:
        print(0 if 0 in l else -1)
        break
else:
    print(n)
Buggy code:
import sys

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

cur = 1
for x in a:
    cur *= a
    if cur > 10 ** 18:
        print(-1)
        sys.exit()
print(cur)


Fixed code:
import sys

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

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

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

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

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

ans = 1
t = 1e18
if 0 in a:
    print(0)
    exit(0)

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

prin(ans)


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

ans = 1
t = 1e18
if 0 in a:
    print(0)
    exit(0)

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

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

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

if 0 in a:
    print(0)
else:
    m=1
    for i in a:
        m*=i
        if 10**18 < m:
            print(-1)
        break
    else:
        print(m)
        




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

if 0 in a:
    print(0)
else:
    m=1
    for i in a:
        m*=i
        if 10**18 < m:
            print(-1)
            break
    else:
        print(m)
Buggy code:
def multiply(num_list):
  # if res > 10^18: return -1
  MAX = pow(10,18)
  res = 1
  for i in num_list:
    res *= i
    if res == 0:
      return 0
    if res > MAX:
      return -1
  return res

input()
num_list = list(map(int,input().split()))
print(multiply(num_list))

Fixed code:
def multiply(num_list):
  # if "0" in list, return 0
  if 0 in num_list:
    return 0
  
  # if res > 10^18: return -1
  MAX = pow(10,18)
  res = 1
  for i in num_list:
    res *= i
    if res == 0:
      return 0
    if res > MAX:
      return -1
  return res

input()
num_list = list(map(int,input().split()))
print(multiply(num_list))
Buggy code:
# -*- coding: utf-8 -*-

def main():

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

    ans = 1

    for i in A:
        ans *= i
        if ans > 10 ** 18:
            ans = -1
            break

    print(ans)


if __name__ == "__main__":
    main()

Fixed code:
# -*- coding: utf-8 -*-

def main():

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

    ans = 1

    if 0 not in A:
        for i in A:
            ans *= i
            if ans > 10 ** 18:
                ans = -1
                break

    else:
        ans = 0

    print(ans)


if __name__ == "__main__":
    main()
Buggy code:
n = int(input())
a = list(map(int,input().split()))
ans = 1
lim = int(1e+18)
for i in range(n):
    ans *= a[i]
    if lim < ans:
        print(-1)
        exit()
else:
    print(ans)

Fixed code:
n = int(input())
a = list(map(int,input().split()))
ans = 1
lim = int(1e+18)
if a.count(0):
    print(0)
    exit()
for i in range(n):
    ans *= a[i]
    if lim < ans:
        print(-1)
        exit()
print(ans)