qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N = int(input())
A = list(map(int,input().split()))
pro = 1
for i in range(N):
    pro *= A[i]
    if pro>10**18:
        pro = -1
        break
print(pro)

Fixed code:
N = int(input())
A = list(map(int,input().split()))
if 0 in A:
    pro = 0
else:
    pro = 1
    for i in range(N):
        pro *= A[i]
        if pro>10**18:
            pro = -1
            break
print(pro)
Buggy code:
#!/usr/bin/env python

def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    ans = 1
    for a in A:
        ans *= a
        if ans > 10 ** 18:
            print('-1')
            exit()
    print(ans)

if __name__ == '__main__':
    main()

Fixed code:
#!/usr/bin/env python

def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    ans = 1
    for a in A:
        if a == 0:
            print('0')
            exit()
    for a in A:
        ans *= a
        if ans > 10 ** 18:
            print('-1')
            exit()
    print(ans)

if __name__ == '__main__':
    main()
Buggy code:
n=int(input())
a = [int(_) for _ in input().split()]
ans=1
for i in a:
    if ans > 10 ** 18:
        print(-1)
        exit()
    ans*=i
if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

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


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

ans = 1
for a_i in a:
    ans *= a_i
    if ans > 1_000_000_000_000_000_000:
        ans = -1
        break

print(ans)


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

ans = 1
a.sort()
for a_i in a:
    ans *= a_i
    if ans > 1_000_000_000_000_000_000:
        ans = -1
        break

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

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

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

ans = a[0]

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

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

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

if 0 in S:
    ans = 0
else:
    for i in range(N):
        ans *= S[i-1]
        if ans > 10**18:
            ans = -1
            break
print(ans)
Buggy code:
import sys 

input=sys.stdin.readline 

def main():
	n=int(input().strip())
	a=list(map(int,input().strip().split()))
	result =1
	LIMIT =10**18
	if 0 in a:
		print(0)
		sys.exit
	for i in a:
		result *=i
		if result >LIMIT:
			print(-1)
			sys.exit()
		print(result)

if __name__=='__main__':
	main()

Fixed code:

import sys
input = sys.stdin.readline

def main():
  n = int(input().strip())
  a = list(map(int, input().strip().split()))
  result = 1
  LIMIT = 10**18
  if 0 in a:
    print(0)
    sys.exit()
  for i in a:
    result *= i
    if result > LIMIT:
      print(-1)
      sys.exit()
  print(result)

main()
Buggy code:
def m():  
    N = int(input())
    A = list(map(int, input().split()))
    times = 1
    c = 0

    for i in A: 
        if times < 10**18 and c < N:
            times *= i
            c += 1
    if times > 10**18:
        print(-1)
    else:
        print(times)
m()

Fixed code:
def m():  
    N = int(input())
    A = list(map(int, input().split()))
    times = 1
    c = 0

    for i in A: 
        if times <= 10**18 and c < N:
            times *= i
            c += 1   
    if times > 10 ** 18:
        times = -1
    if 0 in A:
        times = 0
    print(times)
m()
Buggy code:
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(0, n):
    if ans * a[i] <= 1_000_000_000_000_000_000:
        ans *= a[i]
if ans <= 1_000_000_000_000_000_000:
    print(ans)
else:
    print(-1)

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

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

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

Fixed 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")
        exit()
print(ans)
Buggy code:
N=int(input())
A= list(map(int, input().split()))
sum = 1
for i in range(N):
    sum *= A[i]
    if sum > 1000000000000000000:
        print(-1)
        exit()
print(sum)

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

Fixed code:
n = int(input())
arr = list(map(int,input().split()))
if 0 in arr:
    print(0)
else:
    ans = 1
    f = 0
    for i in arr:
        ans = ans*i
        if ans>10**18:
            f = 1
            break
    if f==1:
        print(-1)
    else:
        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)
        break
else:
    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 A:
    ans *= i
    if ans > 10**18:
        print(-1)
        break
else:
    print(ans)
Buggy code:
import sys
N = int(input())
A = [int(a) for a in input().strip().split()]

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

print(ans)

Fixed code:
import sys
N = int(input())
A = [int(a) for a in input().strip().split()]

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

print(ans)
Buggy code:
# coding: utf-8
# Your code here!

from collections import deque

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

for i in range(N - 1):
    ans *= A.popleft()
    if ans >= pow(10, 18):
        print(-1)
        exit()
print(ans)

Fixed code:
# coding: utf-8
# Your code here!

from collections import deque

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

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

for i in range(N - 1):
    ans *= A.popleft()
    if ans > pow(10, 18):
        print(-1)
        exit()
else:
    print(ans)
Buggy code:
N = int(input())
mlist = list(map(int,input().split()))

s = 1
for i in range(N):
    s *= mlist[i]

    if s > 10**18:
        print(-1)
        break

    elif i == N-1:
        print(s)

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

s = 1
for i in range(N):
    if mlist[i] == 0:
        print(0)
        s = 0
        break
    elif s > 0:
        s *= mlist[i]

    if s > 10 ** 18:
        s = -1
if i == N-1 and s != 0:
    print(s)
Buggy code:
n=int(input())
x=list(map(int,input().split()))
ans=1
for i in x:
    ans*=i
    if ans>10**18:
        ans=-1
        break
if ans==-1:
    print("-1")
else:
    print(ans)

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

Fixed code:
def main ():
  N = int(input())
  A = list(map(int,input(). split ()))
  if 0 in A:
    print(0)
    return
  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  print(prod)
main ()
Buggy code:
n = int(input())
a = list(map(int,input().split()))
MV = 10**18
ans =1
if 0 in a :
    print(-1)
for ele in a:
    ans *= ele
    if ans > MV :
        print(-1)
        exit()
print(ans)


Fixed code:
n = int(input())
a = list(map(int,input().split()))
MV = 10**18
ans =1
if 0 in a :
    print(0)
    exit()

for ele in a:
    ans *= ele
    if ans > MV :
        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:
    ans=-1
    break
print(ans)

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

ans = 1
for x in a:
    ans *= x
    if ans > 10**18:
        ans = -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 x in a:
        ans *= x
        if ans > 10**18:
            ans = -1
            break

print(ans)
Buggy code:
import functools
n = int(input())
arr = [int(a) for a in input().split()]
m = 10 ** 18

ans = 1
for a in arr:
    ans *= a
    if ans > m:
        print(-1)
        break
else:
    print(ans)


Fixed code:
import functools
n = int(input())
arr = [int(a) for a in input().split()]
m = 10 ** 18

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

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

NList.sort()
result = 1
for i in range(N):
    result *= NList[i]

    if result > 10 ** 18:
        print('-1')
        break

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

Fixed code:
N = int(input())

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

NList.sort()
result = 1
for i in range(N):
    result *= NList[i]

    if result > 10 ** 18:
        break

if result > 10 ** 18:
    print('-1')
else:
    print(result)
Buggy code:
N = int(input())
A = list(map(int, input().split(' ')))

LIMIT = 10 ** 18

res = 1
for a in A:
    res = res * a
    if res > LIMIT:
        break

# res = math.exp(sum([math.log(a) for a in A]))

# X = np.array(A)
# res = X.prod()
#
# print(X)

# for a in A:
#     math.log(a)
#
#     res = res * a

if res > LIMIT:
    print('-1')
else:
    print(res)


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

LIMIT = 10 ** 18

zeroflg = 0
for a in A:
    if a == 0:
        zeroflg = 1
        break

if zeroflg == 1:
    res = 0
else:
    res = 1
    for a in A:
        if a == 0:
            res = 0
            break
        if res > LIMIT:
            break
    
        res = res * a

# res = math.exp(sum([math.log(a) for a in A]))

# X = np.array(A)
# res = X.prod()
#
# print(X)

# for a in A:
#     math.log(a)
#
#     res = res * a

if res > LIMIT:
    print('-1')
else:
    print(res)
Buggy code:
from functools import reduce
N = int(input())
A = map(int, input().split())

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

mul = 1
for n in A:
    mul *= n
    if mul > 10 ** 18:
        print(-1)
        exit()
print(mul)

Fixed code:
from functools import reduce
N = int(input())
A = [*map(int, input().split())]

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

mul = 1
for n in A:
    mul *= n
    if mul > 10 ** 18:
        print(-1)
        exit()
print(mul)
Buggy code:
import sys

N = int(input())
A = list(map(int, input().split()))
LA = len(A)
ans = A[0]
for i in range(LA-1):
    if A[i+1] == 0:
        print('-1')
        sys.exit()
    ans = ans*A[i+1]
if ans > 10**18:
    print('-1')
else:
    print(ans)


Fixed code:
import sys

N = int(input())
A = list(map(int, input().split()))
LA = len(A)
ans = A[0]
for j in range(LA):
    if A[j] == 0:
        print('0')
        sys.exit()

for i in range(LA-1):
    ans = ans*A[i+1]
    if ans > 10**18:
        print('-1')
        sys.exit()
        
print(ans)
Buggy code:
import sys
input = sys.stdin.readline
n = int(input())
a = [int(x) for x in input().split()]
ans = 1
for i in a:
    ans *= i
    if ans > 10**18:
        print(-1)
        sys.exit()
print(ans)

Fixed code:
import sys
input = sys.stdin.readline
n = int(input())
a = [int(x) for x in input().split()]
ans = 1
if 0 in a:
    print(0)
    sys.exit()
for i in a:
    ans *= i
    if ans > 10**18:
        print(-1)
        sys.exit()
print(ans)
Buggy code:
n = int(input())
a = map(int, input().split())
ans = 1
for num in a:
    ans *= num
    if ans > 10**18:
        print("-1")
        exit()
print(ans)

Fixed code:
n = int(input())
a = map(int, input().split())
ans = 1
for num in sorted(a):
    ans *= num
    if ans > 10**18:
        print("-1")
        exit()
print(ans)
Buggy code:
#!/usr/bin/env python3

def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    
    out = 1
    for n in A:
        out = n * out
    if out >= 1000000000000000000:
        print(-1)
    else:
        print(out)



main()

Fixed code:
#!/usr/bin/env python3

def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    if 0 in A:
        print(0)
    else:
        out = 1
        for n in A:
            out = n * out
            if out > 1000000000000000000:
                break
            else:
                continue
    
        if out > 1000000000000000000:
            print(-1)
        else:
            print(out)


main()
Buggy code:
n = int(input())
a = list(map(int,input().split()))
mu = 1

for i in range(n):
    mu = mu*a[i]
    if mu==0: break
# print(mu)
if mu<10**18:
    print(mu)
else:
    print(-1)


Fixed code:
n = int(input())
a = list(map(int,input().split()))
mu = 1
if 0 in a:
    print(0)
else:
    fl=0
    for i in range(n):
        mu = mu*a[i]
        if mu>10**18:
            print(-1)
            fl=1
            break
    # print(mu)
    if fl==0:
        print(mu)
Buggy code:
N = int(input())
A = input().split()
answer = 1
flag = 0
for i in range(N):
  answer *= int(A[i])
  if (answer // (10**18)) >= 1:
      print(-1)
      flag = 1
      break
if flag == 0:
  print(answer)

Fixed code:
N = int(input())
A = input().split()
answer = 1
flag = 0
x = 10**18

if '0' in A:
  print(0)
  flag = 1
  


if flag == 0:
  for i in range(N):
    answer *= int(A[i])
    if answer > x:
      print(-1)
      flag = 1
      break

if flag == 0:    
  print(answer)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
k = 1
flag = True
for i in a:
  k *= i
  if k > 10 ** 18:
    print(-1)
    flag = False
    break
    
if flag:
  print(k)

Fixed code:
n = int(input())
a = list(map(int, input().split()))
k = 1
flag = True
for i in a:
  k *= i  
  if k > 10 ** 18:
    flag = False
    break

if 0 in a:
  print(0)
elif flag:
  print(k)
else:
  print(-1)
Buggy code:
def main():
    n = int(input())
    l = list(map(int, input().split()))

    prod = 1
    for i in l:
        prod *= i
        if prod > 1000000000000000000:
            print(-1)
            return

    print(prod)

if __name__ == '__main__':
    main()

Fixed code:
def main():
    n = int(input())
    l = list(map(int, input().split()))

    if 0 in l:
        print(0)
        return

    prod = 1
    for i in l:
        prod *= i
        if prod > 1000000000000000000:
            print(-1)
            return

    print(prod)

if __name__ == '__main__':
    main()
Buggy code:
def main():
    N=int(input())
    A=[int(x) for x in input().split()]
    ans=1
    for a in A:
        ans*=a
        if ans >= 10**18:
            break
    if ans > 10**18:
        print(-1)
    else:
        print(ans)
    return

if __name__=='__main__':
    main()


Fixed code:
def main():
    N=int(input())
    A=[int(x) for x in input().split()]
    A.sort()
    ans=1
    for a in A:
        ans*=a
        if ans > 10**18:
            break
        elif ans == 0:
            break
    if ans > 10**18:
        print(-1)
    else:
        print(ans)
    return

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

c=1

for i in range(n):
    c*=a[i]
    if c>10**18:
        print('-1')
        sys.exit()
    else:
        continue

print(c)


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

if 0 in a:
    print('0')
    sys.exit()

c=1

for i in range(n):
    c*=a[i]
    if c>10**18:
        print('-1')
        sys.exit()
    else:
        continue

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

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

ans = 1

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


Fixed code:
n = int(input())

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

ans = 1

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

for i in a:
    if ans*i > pow(10, 18):
        print(-1)
        break
    else:
        ans *= i
else:
    print(ans)
Buggy code:
import sys
sys.setrecursionlimit(10 ** 7)
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:
        print(-1)
        exit()

print(ans)


Fixed code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

if a.count(0)>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()))
ans=1
for i in range(0,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):
  if len(str(A[i]))>19:
    print(-1)
    exit()
  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 a in A:
    ans *= a
    if ans > (10 ** 18):
        ans = -1
        break

print(ans)


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

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

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

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

S=1

for i in range(N):
    S=S*A[i]
    if S>10**18:
        break

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


Fixed code:
N=int(input())

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

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

print(multi)

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

for i in range(len(input)):
  if(input[i]==0):
    print(0)
    exit(0)

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

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

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

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

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

ans = 1
for i in a:
    ans *= i
    if ans > pow(10, 18):
        ans = -1
        break

print(ans)

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

ans = 1
for i in a:
    if i == 0:
        print(0)
        exit()

for i in a:
    ans *= i
    if ans > pow(10, 18):
        ans = -1
        break


        

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

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

if 0 in A:
    ans = 0
else:
    for num in A:
        ans *= num
        if ans > 1e18:
            ans = -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 num in A:
        ans *= num
        if ans > 1e18:
            ans = -1
            break

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

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

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

r = 1
for a in A:
    r *= a
    if r == 0:
        break
    if r > 10**18:
        r = -1
        break

print(r)


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

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