qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import sys
N = int(input())
A = list(map(int, input().split()))

ans = 1

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

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

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

if A.count(0) != 0:
    print(0)
    sys.exit()

for i in A:

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


Fixed code:
n=int(input())
cnt=1
a=sorted(list(map(int,input().split())))
for it in a:
  cnt*=it
  if cnt>1000000000000000000:
    print(-1)
    exit()
if cnt>1000000000000000000:
  print(-1)
else:
  print(cnt)
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
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:
i = input
i()
x = 1
l = i().split()
if '0' in l:
    print(0)
    quit()
for j in l:
    x *= int(j)
    if x >= 1e18:
        print(-1)
        quit()
print(x)


Fixed code:
i=input;i();l=i().split();x=not '0' in l
for j in l:
  x*=int(j)
  if x>1e18:
    print(-1);quit()
print(x)
Buggy code:
N = int(input())
A = list(map(int, input().split()))

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

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

for i in range(N):
  if A[i] == 0:
    print(0)
    exit(0)

ans = 1
for i in range(N):
  if ans * A[i] > 1000000000000000000:
    ans = -1
    break
  ans *= A[i]
print(ans)
Buggy code:
_ = input()
nums = list(map(int, input().split()))
ans = 1

for num in nums:
    if num==0 or ans <= 10 ** 18:
        ans *= num
    else:
        break

print(ans if ans <= 10 ** 18 else -1)

Fixed code:
_ = input()
nums = list(map(int, input().split()))
ans = 1
 
for num in nums:
    if num==0 or ans <= 10 ** 18:
        ans *= num
    else:
        pass
 
print(ans if ans <= 10 ** 18 else -1)
Buggy code:
i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=int(j);if x>1e18:x=-1;break
print(x)


Fixed code:
i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=int(j)
  if x>1e18:
    x=-1;break
print(x)
Buggy code:
n=int(input())
l=list(map(int,input().split()))
ans=1 
for x in l:
  ans=ans*x
  if ans>10**18:
    print(-1)
    quit()
print(ans)

Fixed code:
n=int(input())
l=list(map(int,input().split()))
ans=1
if min(l)==0:
  print(0)
  quit()
for x in l:
  ans=ans*x  
  if ans>10**18:
    print(-1)
    quit()
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:
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 1
for i in a:
  ans *= i
  if ans > 10**18:
    ans = -1
    break
print(ans)
Buggy code:
n=int(input())
arr=list(map(int,input().split()))
mul=1
for i in range(n):
	mul=mul*arr[i]
	if(mul>10**18):
		print("-1")
		exit(0)
print(mul)

Fixed code:
n=int(input())
arr=list(map(int,input().split()))
mul=1
mx=10**18
for i in arr:
	if(i==0):
		print("0")
		exit(0)
for i in range(n):
	mul=mul*arr[i]
	if(mul>mx):
		print("-1")
		exit(0)
print(mul)
Buggy code:
n = int(input())
A = list(map(int,input().split()))
total = 1
count = 0
for i in range(n):
    total *= A[i]
    if total > 10**18:
        count += 1
        break
if count == 1:
    print('-1')
else:
    print(total)

Fixed code:
n = int(input())
A = list(map(int,input().split()))
total = 1
count = 0
for i in range(n):
    total *= A[i]
    if total > 10**18:
        count += 1
        break

if 0 in A:
    print('0')
elif count == 1:
    print('-1')
else:
    print(total)
Buggy code:
n = int(input())
l = list(map(int, input().split()))

a = 1
l.sort(reverse=True)
for i in l:
	a *= i
	if a > 10**18:
		a = -1
		break
print(a)

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

for i in range(int(a)):
	sum1=sum1*int(b[i])

if sum1>=10**18:
	print("-1")
else:
	print(sum1)


Fixed code:
a=int(input())
b=input().split(" ")
sum1=1

if "0" in b:
	print("0")
else:
	for i in range(a):
		sum1=sum1*int(b[i])
		if sum1>10**18:
			sum1=-1
			break
	print(sum1)
Buggy code:
import sys

MAX = 10**18

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

if 0 in A:
    print("0")
else:
    res = 1
    for a in reversed(sorted(A)):
        if res == 1:
            break
        res *= a
        if res > MAX:
            print("-1")
            sys.exit()
    print(res)


Fixed code:
import sys

MAX = 10**18

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

if 0 in A:
    print("0")
else:
    res = 1
    for a in reversed(sorted(A)):
        if a == 1:
            break
        res *= a
        if res > MAX:
            print("-1")
            sys.exit()
    print(res)
Buggy code:
_ = input()
A = list(map(int, input().split()))

ans = 1
for a in A:
    ans *= a
    if ans <= 10 ** 18:
        break

ans = ans if ans <= 10 ** 18 else -1
print(ans)


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

ans = 1
for a in A:
    ans *= a

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

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

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

ans=1

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

print(ans)

Fixed code:

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

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

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

Fixed code:
N = int(input())
A = list(map(int, input().split()))
A.sort()
def nhan(A):
    multi = 1
    for i in A:
        multi *= i
        if multi > 10**18: return -1
    return multi
print(nhan(A))
Buggy code:
n = int(input())
a_list = list(map(int,input().split()))
ans = 1
for i in a_list:
    ans *= i
    if ans > 10**18:
        print(-1)
        exit()
print(ans)

Fixed code:
n = int(input())
a_list = list(map(int,input().split()))
if 0 in a_list:
    print(0)
    exit()
ans = 1
for i in a_list:
    ans *= i
    if ans > 10**18:
        print(-1)
        exit()
print(ans)
Buggy code:
# -*- coding: utf-8 -*-
from decimal import *
# input
n = int(input())
a = list(map(int, input().split()))
out = 1
for i in range(n):
    out = Decimal(out * a[i])
    if out == 0:
        print(out)
        quit()
    elif out >= Decimal(10**18):
        print(-1)
        quit()
print(out)


Fixed code:
# -*- coding: utf-8 -*-
from decimal import Decimal
# input
n = int(input())
a = list(map(int, input().split()))
out = 1
if 0 in a:
    print(0)
    quit()
for i in range(n):
    out = Decimal(out * a[i])
    if out > Decimal(10**18):
        print(-1)
        quit()
print(out)
Buggy code:
n=int(input())
a=list(map(int,input().split()))
x=1
if 0 in a:
    print(0)
    exit()

for i in range(len(a)):
    x=a[i]*x
    if x>10^18:
        print(-1)
        exit()
print(x if x<=10**18 else -1)


Fixed code:
import sys

n=int(input())
a=list(map(int,input().split()))
x=1
if 0 in a:
    print(0)
    sys.exit()

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


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

pyn()
Buggy code:
n = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print('0')
else:
    threshold = 10**18
    res = 1
    for x in A:
        res *= x
        if res >= threshold:
            res = -1
            break
    print(res)

Fixed code:
n = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print('0')
else:
    threshold = 10**18
    res = 1
    for x in A:
        res *= x
        if res > threshold:
            res = -1
            break
    print(res)
Buggy code:
from sys import stdin
data = stdin.readlines()

a = int(data[0])
b = [int(s) for s in data[1].split()]

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

print(ans)

Fixed code:
from sys import stdin
data = stdin.readlines()

a = int(data[0])
b = [int(s) for s in data[1].split()]

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

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

for i in range(N):
  if a[i]==0:
    print (0)
    sys.exit()
    
p=1
for i in range(N):
  p=p*a[i]
  if p>10**18:
    print (-1)
    sys.exit()

if p>10**18:
  print (-1)
else:
  print(p)
Buggy code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans = 1
    for ai in a:
        ans *= ai
        if ans > 10 ** 18:
            print(-1)
            exit()

    else:
        print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Fixed code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 1
    for ai in a:
        ans *= ai
        if ans == 0:
            print(0)
            exit()
        elif ans > 10 ** 18:
            print(-1)
            exit()
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
Buggy code:
N = int(input())
A = [int(a) for a in 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 = [int(a) for a in 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()))
m = 10**18
if 0 in a:
    print(0)
    exit()
res = 1
for i in a:
    res *= i
    print(res)
    if res > m:
        print(-1)
        exit()

print(res)

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

print(res)
Buggy code:

_ = input()
N = [int(v) for v in input().split()]
s = 1
for n in N:
    s *= n
    if s > 10**18:
        break

print(s if s <= 10**18 else -1)

Fixed code:

_ = input()
N = sorted([int(v) for v in input().split()])
s = 1
for n in N:
    s *= n
    if s == 0 or s > 10**18:
        break

print(s if s <= 10**18 else -1)
Buggy code:
n = input()
a = input()
a = a.split()
x = 0;
mul = 1;
for num in a:
    if(int(num) == 0):
    	mul = 0;
    	break;
    else:
    	mul *= int(num)
    	if(mul > 1000000000000000000):
    		mul = -1;
    		break;
    
print(mul);


Fixed code:
n = input()
a = input()
a = a.split()
x = 0;
mul = 1;

for num in a:
    if(int(num) == 0):
    	mul = 0;
    	break;
    	
for num in a:
	mul *= int(num)
	if(mul > 1000000000000000000):
		mul = -1;
		break;
    
print(mul);
Buggy code:
n = int(input())
a = list(map(int, input().split()))
 
ans = 1
if 0 in a:
  print(0)
  quit()
  
for i in range(n):
  ans *= a[i]

if ans >= 1e18:
  print(-1)
else:
  print(ans)

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

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

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

sum_A = 1
for i in range(0,len(A)):
  if(A[i] == 0):
        print(0)
        exit()
  if(sum_A > 1000000000000000000):
        break
  sum_A *= A[i]
if(sum_A > 1000000000000000000):
        print("-1")
        exit()
print(sum_A)


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

sum_A = 1

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

for i in range(0,len(A)):
  if(sum_A > 1000000000000000000):
        break
  sum_A *= A[i]
if(sum_A > 1000000000000000000):
        print("-1")
        exit()
print(sum_A)
Buggy code:
n = int(input())

MAX_NUM = 10 ** 18

nums = map(int, input().split())

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

ans = 1

for num in nums:
  ans *= num
  if ans > MAX_NUM:
    print(-1)
    exit()

print(ans)


Fixed code:
n = int(input())

MAX_NUM = 10 ** 18

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

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

ans = 1
for num in nums:
  ans *= num
  if ans > MAX_NUM:
    print(-1)
    exit()

print(ans)
Buggy code:
n=int(input())
A=[int(_) for _ in input().split()]
ans=1
if A.count(0)>0:
  print(0)
else:
  for i in range(n):
    ans=ans*A[i]
    if ans>10**18:
      print(-1)
    else:
      print(ans)

Fixed code:
n=int(input())
A=[int(_) for _ in input().split()]
ans=1
if A.count(0)>0:
  print(0)
else:
  for i in range(n):
    ans=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
i = 0
while i<=n-1 and ans<= 10**18:
    ans *= a[i]
    i += 1

if ans <= 10**18:
    print(ans)
else:
    print('-1')

Fixed code:
n = int(input())
a = list(map(int, input().split()))
ans = 1
i = 0
while i<=n-1 and ans<= 10**18:
    ans *= a[i]
    i += 1
if 0 in a:
    print('0')
elif ans <= 10**18:
    print(ans)
else:
    print('-1')
Buggy code:
from sys import stdin
MAX = 10^18

def main():
    line_count = 0

    for line in stdin:
        line_count += 1
        factors_str = line.split()
        if line_count == 2:
            break

    factors = [int(factor) for factor in factors_str]
    
    if 0 in factors:
        print(0)
        return

    product = 1
    for factor in factors:
        product *= factor
        if product > MAX:
            print(-1)
            return

    print(product)

main()

Fixed code:
from sys import stdin
MAX = 10**18

def main():
    line_count = 0

    for line in stdin:
        line_count += 1
        factors_str = line.split()
        if line_count == 2:
            break

    factors = [int(factor) for factor in factors_str]
    
    if 0 in factors:
        print(0)
        return

    product = 1
    for factor in factors:
        product *= factor
        if product > MAX:
            print(-1)
            return

    print(product)

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


Fixed code:
def main():
    n = int(input())
    arr = list(map(int, input().split()))
    if 0 in arr:
        print(0)
        return
    a = 1
    for i in arr:
        a*=i
        if a>10**18:
            print("-1")
            return
    
    print(a)
main()
Buggy code:
n = int(input())
mod = 10**18
li = list(map(int, input().split())).sort()
ans = 1
for i in range(n):
    ans = ans * li[i]
    if ans > mod:
        ans = -1
        break
print(ans)


Fixed code:
n = int(input())
mod = 10**18
li = list(map(int, input().split()))
li.sort()
ans = 1
for i in range(n):
    ans *= li[i]
    if ans > mod:
        ans = -1
        break
print(ans)
Buggy code:
n = int(input())
 
List = [int(i) for i in input().split()]
sorted(List, reverse=True)
if List[-1] == 0:
  print(-1)
  exit()
total = 1
for i in List:
  total = total*i
  if total > 1000000000000000000:
    print(-1)
    exit()
print(total)


Fixed code:
n = int(input())
 
List = [int(i) for i in input().split()]
lst = sorted(List, reverse=True)
if lst[-1] == 0:
  print(0)
  exit()
total = 1
for i in lst:
  total = total*i
  if total > 1000000000000000000:
    print(-1)
    exit()
print(total)
Buggy code:
n = int(input())
a = list(map(int,input().split()))
ans = 1
mark = False
for i in range(n):
    if i==0:
        ans = 0
        mark = True
        break
    ans *= a[i]
    if ans > 1000000000000000000:
        print(-1)
        mark = True
        break
if not mark: print(ans)


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

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

ans = 1;
for num in num_list:
    ans *= num
    if ans > 1000000000000000000:
        ans = -1
        break

print(ans)


Fixed code:
n = int(input())

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

ans = 1;
for num in num_list:
    ans *= num
    if ans > 1000000000000000000:
        ans = -1
        break

if 0 in num_list:
    ans = 0

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

ans = 1
c=0
for i in range(N):
  a = List[i]
  ans *= a
  if ans > 10**18:
    c=1
    break

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

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

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

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

Fixed code:
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()
mul = A.pop()
for a in A:
    mul *= a
    if mul > 10**18:
        print(-1)
        exit()
print(mul)
Buggy code:
def main():
    n = int(input())
    ps = [int(x) for x in input().split()]
    a = 1
    for p in ps:
        a *= p
        if a > 10 ** 18:
            print(-1)
            return
        
    print(a)

    
main()


Fixed code:
def main():
    n = int(input())
    ps = [int(x) for x in input().split()]
    ps.sort()
    a = 1
    for p in ps:
        a *= p
        if a == 0:
            print(0)
            return
        if a > 10 ** 18:
            print(-1)
            return
        
    print(a)

    
main()
Buggy code:
n = int(input())
ans = 1

nums = list(map(lambda x : int(x),input().split()))

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

print(ans)

Fixed code:
n = int(input())
ans = 1

nums = list(map(lambda x : int(x),input().split()))

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

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

if 0 in A_list:
  print(0)
  exit()
else:
  for a in A_list:
    ans*=a
  if ans>1e+18:
    ans=-1
    exit()
print(ans)







Fixed code:

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

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

Fixed code:
N = int(input())
A_list = list(map(int,input().split()))
output = 1
flug = 0

if 0 in A_list:
    print(0)
    flug = 1
if flug != 1:
    for i in range(N):
        output *= A_list[i]
        
        if (output > 10 ** 18):
            print(-1)
            flug = 1
            break
if(flug != 1):
    print(output)
Buggy code:
N = int(input())
K = [int(i) for i in input().split()]

ans = 1
burst = False
for k in K:
    ans *= k
    if ans > 10**18:
        burst = True
        break

print(-1) if burst else print(ans)


Fixed code:
N = int(input())
K = [int(i) for i in input().split()]

if K.count(0) > 0:
    print(0)
else:
    ans = 1
    burst = False
    for k in K:
        ans *= k
        if ans > 10**18:
            burst = True
            break
    if burst:
        print(-1)
    else:
        print(ans)
Buggy code:
N = int(input())
A = input().split()
A = [int(a) for a in A]

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



Fixed code:
N = int(input())
A = input().split()
A = [int(a) for a in A]
A.sort()
MAX = 10**18
res = 1
for i in range(N):
    res *= A[i]
    if res > MAX:
        res = -1
        break
print(res)
Buggy code:
import sys
N = int(input())
A = list(map(int,input().split()))
K = 1
for i in range(N):
  K = A[i]*K
  if K > 10**18:
    print(-1)
    sys.exit()
print(K)

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

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

i = 0
x = 1
while i < n:
    x = x * a[i]
    i += 1
    if x > 1000000000000000000:
        print(-1)
        exit()

print(x)

Fixed code:
n = int(input())

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

i = 0
x = 1
while i < n:
    x = x * a[i]
    i += 1
    if x > 1000000000000000000:
        print(-1)
        exit()

print(x)
Buggy code:
import sys
n=int(input())
List=list(map(int,input().split()))
List.sort(reverse=True)
if 0 in List:
    print(0)
    sys.exit()
ans=1
for i in List:
    if ans<=10**18:
        ans*=i
    else:
        print(-1)
        sys.exit()
print(ans)

Fixed code:
import sys
n=int(input())
List=list(map(int,input().split()))
List.sort(reverse=True)
if 0 in List:
    print(0)
    sys.exit()
ans=1
for i in List:
    if ans<=10**18:
        ans*=i
    else:
        print(-1)
        sys.exit()
if ans<=10**18:
    print(ans)
else:
    print(-1)