qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n = int(input())
arr = list(map(int, input().split()))
if 0 in arr:
    print(0 + '\n')
else:
    mul = 1
    for n in arr:
        mul *= n
        if mul > 10**18:
            print(-1 + '\n')
            break
    else:
        print(mul + '\n')

Fixed code:
n = int(input())
arr = list(map(int, input().split()))
if 0 in arr:
    print('0' + '\n')
else:
    mul = 1
    for n in arr:
        mul *= n
        if mul > 10**18:
            print('-1' + '\n')
            break
    else:
        print(str(mul) + '\n')
Buggy code:
n=int(input())
lst=list(map(int, input().split()))
ans = 1
for i in lst:
    ans = ans * i
    if ans > 10**18:
        print(-1)
        exit()

print(ans)
    


Fixed code:
n=int(input())
lst=list(map(int, input().split()))
ans = 1
if 0 in lst:
    print(0)
    exit()

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


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

ans = 1
A.sort(reverse = True)

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

print(ans)

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

ans = 1
A.sort(reverse = True)
flag = True

if 0 in A:
    ans = 0
    flag = False

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

print(ans)
Buggy code:
# coding: utf-8
# Your code here!
N=int(input())
A = list(map(int,input().split()))

flag = 1

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

if flag == 1:
    print(ans)


Fixed code:
# coding: utf-8
# Your code here!
N=int(input())
A = list(map(int,input().split()))

flag = 1

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

if ans == 0:
    print(0)
elif flag == 0:
    print(-1)
else:
    print(ans)
Buggy code:
import sys
n = int(input())
print(n)
prod = 1
overflow = False

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

for aa in a:
  if prod * aa > 1000000 * 1000000 * 1000000:
    overflow = True
  else:
    prod = prod * aa

if overflow:
  print(prod)
else:
  print(-1)



Fixed code:
import sys
n = int(input())
#print(n)
prod = 1
overflow = False

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

for aa in a:
  if prod * aa > 1000000 * 1000000 * 1000000:
    overflow = True
  else:
    prod = prod * aa

for aa in a:
  if aa == 0:
    overflow = False

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

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

    if 0 in A:
        print(0)
        return

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


if __name__ == "__main__":
    main()


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

    if 0 in A:
        print(0)
        return

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


if __name__ == "__main__":
    main()
Buggy code:
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    output = 1
    output *= a[i]

    if output> 10**18:
        print(-1)
        quit()
print(output)


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

if 0 in A:
    print(0)
    return

ans = 1
for a in A:
    ans *= a
    if ans > 1000000000000000000:
        print(-1)
        return

print(ans)

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

    if 0 in A:
        print(0)
        return

    ans = 1
    for a in A:
        ans *= a
        if ans > 1000000000000000000:
            print(-1)
            return

    print(ans)

main()
Buggy code:
N=int(input())
A=[*map(int,input().split())]
a=1
while A:
  a*=A.pop()
  if a >= 10**18:
    print(-1)
    break
else:
  print(a)

Fixed code:
N=int(input())
A=[*map(int,input().split())]
a=1
if 0 in A:
  a=0
else:
  while A:
    a*=A.pop()
    if a>10**18:
      a=-1
      break
print(a)
Buggy code:
N = int(input())
S = [int(s) for s in input().split()]
l = 1
for s in S:
  l = l * s
  if l > 10**18:
    l = -1
    break
print(l)


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

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


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

if 0 in A:
    ans = 0
else:
    for a in A:
        ans *= a
    if ans > 1000000000000000000:
        ans = -1
        return
print(ans)

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

if 0 in A:
    ans = 0
else:
    for a in A:
        ans *= a
        if ans > 1000000000000000000:
            ans = -1
            break
print(ans)
Buggy code:
n = int(input())

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

r = a[0]

for i in a[1:]:
  r *= i
  if r > 10**8:
    r = -1
    break

if 0 in a:
  r = 0
    
print(r)

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

ans = 1
if 0 in a:
    print(0)
else:
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1,ans)
            break
    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 *= i
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)
Buggy code:
from sys import stdin
input = stdin.readline

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

cum = 1
over = False
for x in a:
    if x == 0:
        cum = 0
        break

    cum *= x
    if (cum > 1e18):
        over = True
        break

print(-1) if (over and cum != 0) else print(cum)


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

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

cum = 1
over = False
for x in a:
    if x == 0:
        cum = 0
        break

if cum == 0:
    print(0)
else:
    for x in a:
        cum *= x
        if (cum > 1e18):
            over = True
            break
    print(-1) if over else print(cum)
Buggy code:
N = int(input())
A = list(map(int, input().split()))

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

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


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

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

ans = 0
for x in a:
	if ans == 0 or ans == -1:
		break
	ans = ans * x
	if ans > 1000000000000000000:
		ans = -1

print(ans)

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

ans = 1
for x in a:
	if ans == 0 or ans == -1:
		break
	ans = ans * x
	if ans > 1000000000000000000:
		ans = -1

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

Fixed code:
x=int(input())
y=list(map(int, input().split()))
z=1
if 0 in y:
  print(0)
  exit()

for i in range(x):
  z = z*y[i]
  if z > 10**18:
    z=-1
    break
print(z)
Buggy code:
input();a=sorted(map(int,input().split()));z=1
for i in a:
 if i>1e18//z:z=-1;break
 z*=i
print(z)

Fixed code:
input();a=sorted(map(int,input().split()));z=1
for i in a:
 z*=i
 if z>1e18:z=-1;break
print(z)
Buggy code:
import sys

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

zero_search = 0 in a_list
ans = 1

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

Fixed code:
import sys

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

zero_search = 0 in a_list
ans = 1

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

Fixed code:
n = int(input())
d = list(map(int, input().split()))
c_nega = 0
flag = False
for i in range(n):
  if d[i] == 0:
    flag = True
    break

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

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

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

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

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

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

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

judge = True
ans = 0

if 0 not in a:
    ans = 1
    for i in range(n):
        ans *= a[i]
        if ans > 10**18:
            judge = False
            break
        
if judge:
    print(ans)
else:
    print(-1)
Buggy code:
def main ():
  N = int(input())
  A = list(map(int,input(). split ()))
  
  if 0 in A:
    print(0)
    
  
  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
     
    
  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:
input_number = int(input())
int_list = list(map(int, input().split()))

ans = int_list[0]
for i in int_list[1:]:
    ans = ans * i

    if ans > (10 ** 18):
        ans = -1
        break

print(ans)


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

check = 10 ** 18
ans = int_list[0]
for i in int_list[1:]:
    ans = ans * i

    if ans > check:
        ans = -1
        break

for i in int_list:
    if i == 0:
        ans = 0
        break

print(ans)
Buggy code:
import sys

n = int(input())

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

ans = 1

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

print(ans)

Fixed code:
import sys

n = int(input())

a = list(map(int, 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:
from math import *

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def main():
    a = cino()
    l = cina()
    check = True
    suma = 1
    for i in l:
        suma = suma*i
        if suma>1000000000000000000:
            check = False
            break
    if check:
        print(suma)
    else:
        print(-1)


if __name__ == '__main__':
    main()

Fixed code:
from math import *

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def main():
    a = cino()
    l = cina()
    check = True
    suma = 1
    l.sort()
    if l[0]==0:
        print(0)
    else:
        for i in l:
            suma = suma*i
            if suma>1000000000000000000:
                check = False
                break
        if check:
            print(suma)
        else:
            print(-1)


if __name__ == '__main__':
    main()
Buggy 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:
        values *= 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:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
if 0 in A:
	print(0)
	exit()

ans = 1

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


Fixed code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

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

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

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

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()))

S= 1
for n in range(N):
  S *= A[n]
  if S > 10**18:
    S = -1
    break
print(S)

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

A = sorted(A)

if A[0] == 0:
  print(0)
else:
  S = 1
  for n in range(N):
    S *= A[N-1-n]
    if S > 10**18:
      S = -1
      break
  print(S)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
ans = 1
zf = 0
for i in range(n):
    if a[i] == 0:
        ans = 0
    ans = ans * a[i]
    if ans > 1000000000000000000:
        ans = -1
        break
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
    if ans != -1:
        ans = ans * a[i]
    if ans > 1000000000000000000:
        ans = -1
print(ans)
Buggy code:
totalNumbers = int(input())
array = list(map(int, input().split()))
answer = 1
for number in array:
    if number == 0:
        answer = 0
        break
    answer*=number
    if answer>10**18:
        answer=-1
        break
print(answer)


Fixed code:
totalNumbers = int(input())
array = list(map(int, input().split()))
answer = 1
if 0 in array:
    print(0)
else:
    for number in array:
        answer*=number
        if answer>10**18:
            answer=-1
            break
    print(answer)
Buggy code:
n = int(input())
l = list(map(int, input().split()))
if 0 in l:
  print(0)
  
ans = 1
for i in range(n):
  ans *= l[i]
  if ans > 10**18:
    ans = -1
    break
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 range(n):
  ans *= l[i]
  if ans > 10**18:
    ans = -1
    break
print(ans)
Buggy code:
def main():
    N = input()
    str_num = input()
    num_list = str_num.split()
    
    if '0' in num_list:
        print(0)
        return
    
    answer = 1
    for num in num_list:
        answer *=int(num)
        if answer > 10**8:
            answer = -1
            break

    print(answer)

Fixed code:
def main():
    N = input()
    str_num = input()
    num_list = str_num.split()
    
    if '0' in num_list:
        print(0)
        return
    
    answer = 1
    for num in num_list:
        answer *=int(num)
        if answer > 10**18:
            answer = -1
            break

    print(answer)

main()
Buggy code:
def sol():
    n = int(input())
    mul = 1
    arr = list(map(int, input().split()))
    for i in arr:
        mul*=i
        if(mul>10**18):
            print(-1)
            return
    print(mul)
sol()

Fixed code:
def sol():
    n = int(input())
    mul = 1
    arr = list(map(int, input().split()))
    arr.sort()
    for i in arr:
        mul*=i
        if(mul>10**18):
            print(-1)
            return
    print(mul)
sol()
Buggy code:
n = int(input())
a = list(map(int, input().split()))

m = a[0]
over = False
limit = pow(10, 18)
for i in a[1:]:
    m *= i
    if m > limit:
        over = True
        break

if over:
    print("-1")
else:
    print(m)

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

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

m = a[0]
over = False
limit = pow(10, 18)
for i in a[1:]:
    m *= i
    if m > limit:
        over = True
        break

if over:
    print("-1")
else:
    print(m)
Buggy code:
n = int(input())
flag = False
limit = 1e18
a = [int(item) for item in input().split()]
if(flag):
    print(0)
ans = 1
for i in a:
    if(i == 0):
        flag = True
        break
if(flag):
    print(0)
for i in a:
    ans = ans*i
    if(ans > limit):
        flag = True
        break
if(flag):
    print(-1)
else:
    print(ans)

Fixed code:
n = int(input())
flag = False
limit = 1000000000000000000
a = [int(item) for item in input().split()]
ans = 1
for i in a:
    if(i == 0):
        flag = True
        break
for i in a:
    ans = ans*i
    if(ans > limit):
        break
if(flag):
    print(0)
elif(ans > limit):
    print(-1)
else:
    print(ans)
Buggy code:
n = int(input())
a = list(map(int, input().split()))

maxi = int(1e18)

ans = 1
for x in a:
    ans *= x
    if ans > maxi:
        ans = -1
        break

print(ans)


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

maxi = int(1e18)

ans = 1
for x in a:
    ans *= x
    if ans > maxi:
        ans = -1
        break

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

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

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