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

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

print(R)


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

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

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

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

prod = 1
for i in range(N):
  prod *= A[i]
  if prod > 10**18:
    prod = -1
    break
  elif prod == 0: break
  
print(prod)
Buggy code:
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    if 0 in A:
        print(0)
    prod = 1
    for a in A:
        prod *= a
        if prod > int(1e18):
            print(-1)
            return
    print(prod)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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


def solve(N: int, A: "List[int]"):
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > int(1e18):
            print(-1)
            return
    print(prod)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
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()))
ans = 1
if 0 in A:
    print(0)
else:
    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()))
pro=1
flag=0
for i in range(n):
  pro*=A[i]
  if pro>10**18:
    flag=1
    print("-1")
if flag==0:
  print(pro)

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

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

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

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

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

def main(A):
  if 0 in A:
    print(0)
    return
  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  print(prod)
    
main(A)
Buggy code:
import math
N=int(input())
A=list(map(int,input().split()))

kekka=1

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

print(kekka)


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

kekka=1

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

if kekka>10**18:
    kekka=-1


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

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

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

INF = 10 ** 18
ans = 1
for i in range(N):
    ans *= A[i]
    if ans > INF:
        print(-1)
        sys.exit()
print(ans)
Buggy code:
import sys

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

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

if sum_a > 1e18:
    sum_a = -1

print(sum_a)


Fixed code:
import sys

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

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

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

if sum_a > 1e18:
    sum_a = -1

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


Fixed code:
n = int(input())
v = list(map(int, input().split()))
if 0 in v:
    print(0)
    exit()
ans = 1
for i in range(n):
    ans *= v[i]
    if (ans > 10**18):
        print(-1)
        exit()
print(ans)
Buggy code:
#!/bin/python3

import sys
input = sys.stdin.readline

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

main()


Fixed code:
#!/bin/python3

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:
n=int(input())
a=list(map(int,input().split()))
result=1
if 0 in a:
    print(0)
else:
    for i in a:
        result*=i
        if result>10*18:
            print(-1)
    if result>10**18:
        print(-1)
    else:
        print(result)

Fixed code:
n=int(input())
a=list(map(int,input().split()))
result=1
if 0 in a:
    print(0)
else:
    for i in a:
        result*=i
        if result>10**18:
            print(-1)
            break
    if result<=10**18:
        print(result)
Buggy code:
N = int(input())
A = list(map(int,input().split()))
MAX = 10**18
ret = 1
flag = True
if 0 in A:
    print(0)
else:
    for a in A:
        ret *= a
        if ret > MAX:
            print(-1)
            flag = False
            break
    if flag and ret < MAX:
        print(ret)

Fixed code:
N = int(input())
A = list(map(int,input().split()))
MAX = 10**18
ret = 1
flag = True
if 0 in A:
    print(0)
else:
    for a in A:
        ret *= a
        if ret > MAX:
            print(-1)
            flag = False
            break
    if flag and ret <= MAX:
        print(ret)
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:
  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 = map(int, input().split())

res = 1

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


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

res = 1

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

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

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





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

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

sum = 1
cnt = 0
for i in a:
    sum *= i
    if (sum > 1000000000000000000):
        print(-1)
        cnt = 1
        break
if cnt == 0:
    print(sum)


Fixed code:
n = int(input())

a = [0] * n

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

sum = 1
cnt = 0
if 0 in a:
    print(0)
else:
    for i in a:
        sum *= i
        if sum > 1000000000000000000:
            print(-1)
            cnt = 1
            break
    if cnt == 0:
        print(sum)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
i = 0
ans = 0
if 0 in a:
    print(0)
else:
    while ans<10**10 and i<len(a):
        ans*=a[i]
    if (ans<=10**18):
        print(ans)
    else:
        print(-1)


Fixed code:
i = 0
ans = 1
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    while ans<10**18 and i<len(a):
        ans*=a[i]
        i+=1
    if (ans<=10**18):
        print(ans)
    else:
        print(-1)
Buggy code:
import math
import bisect
#[int(x) for x in input().split()]
#map(int,input().split())
#for _ in range(int(input())):
n=int(input())
l=[int(x) for x in input().split()]
p=1
M=10**18
f=0
for i in range(n):
	p*=l[i]
	if p>M:
		print(-1)
		f=1
		break
if f==0:
	print(p)


Fixed code:
import math
import bisect
#[int(x) for x in input().split()]
#map(int,input().split())
#for _ in range(int(input())):
n=int(input())
l=[int(x) for x in input().split()]
p=1
M=10**18
f=0
if 0 in l:
	print(0)
else:	
	for i in range(n):
		p*=l[i]
		if p>M:
			print(-1)
			f=1
			break
	if f==0:
		print(p)
Buggy code:

n = int(input())

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

k = 1

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

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

Fixed code:

n = int(input())

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

k = 1

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

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

if k > 10**18:
    print(-1)
else:
    print(k)
Buggy code:
input();a=1
for i in input().split():a*=int(i);a=[-1,a][1=<a<=eval('1'+'0'*18)]
print(a)

Fixed code:
input();a=1;d=eval('1'+'0'*18)
for i in input().split():a*=int(i);a=[-1,a][-1<a<=d]
print(a)
Buggy code:
n = int(input())
ans = int(1)
a = input().split(" ")

for i in range(n):
  ans *= int(a[i])
  if ans > 10**18:
    print("-1")
    break
    
if ans < 10**18:
  print(ans)

Fixed code:
n = int(input())
ans = int(1)
a = input().split(" ")

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

MAX = 10**18
ans = 1

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

print(ans)

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

MAX = 10**18
ans = 1

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

print(ans)
Buggy code:
n = int(input())
num = list(map(int,input().split()))
num.sort()
if(num[0] == 0):
    print(0)
else:
    ans = 1
    for i in range(len(num)):
        ans *= num[i]
        if(ans >1000000000000000000):
            print(-1)
            return
    print(ans)

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

if 0 in A:
    print(0)

ans = 1
for i in A:
    ans *= i
    if ans > 1000000000000000000:
        print(-1)
        quit()

print(ans)

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

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

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

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


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

if '0' in list:
    print(0)
    exit()

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

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

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

if 0 in a:
  print(0)
  
else:
  ans = 1
  for val in a:
    ans *= val
    if ans > 10**18:
      print(-1)
      exit()
      
  print(ans)
Buggy code:
import math
n= int(input())

l = list(map(int,input().split()))
l.sort(reverse = True)
print(l)
ans = 1
if 0 in l:
  print(0)
else:
  for i in range(n):
    ans *= l[i]
#    print(ans)
    if ans > 10**18:
      break
  print(ans if ans <= 10**18 else -1)


Fixed code:
import math
n= int(input())

l = list(map(int,input().split()))
l.sort(reverse = True)

ans = 1
if 0 in l:
  print(0)
else:
  for i in range(n):
    ans *= l[i]
#    print(ans)
    if ans > 10**18:
      break
  print(ans if ans <= 10**18 else -1)
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:
    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()))
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
A = sorted(A)
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()))
if 0 in a:
  print(0)
else:
  p = 1
  f = True
  for i in a:
    p *= i
    if(p > 1000000000000000000):
      f = false
      break
  if(f):
    print(p)
  else:
    print(-1)
  

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

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

Fixed code:
import sys
n=int(input())
li=list(map(int,input().split()))
li.sort()
if li[0]==0:
  print(0)
  sys.exit()
else:
  ans=1
  for i in li:
    ans*=i
    if ans>1000000000000000000:
        print(-1)
        sys.exit()
    else:
        continue
    
  if ans>1000000000000000000:
      print(-1)
  else:
      print(ans)
Buggy code:
n = int(input())
lis = list(map(int, input().split()))

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


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

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

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

if ans > 10**18:
    print("-1")
else:
    print(ans)
Buggy code:
n=int(input())
l=list(map(int,input().split()))
ans=1
z=pow(10,18)
for i in l:
	ans=ans*i
	if ans>z:
		ans=-1
		break
print(ans)

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

def main(n,a):
    if(a.count(0)!=0):
        return 0
        
    res=a[0]
    for i in range(1,n):
        res*=a[i]
        if res>INFTY:
            return -1
    return res

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(ans)

Fixed code:
INFTY=10**18

def readinput():
    n=int(input())
    a=list(map(int,input().split()))
    return n,a

def main(n,a):
    if(a.count(0)!=0):
        return 0
        
    res=a[0]
    for i in range(1,n):
        res*=a[i]
        if res>INFTY:
            return -1
    return res

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(ans)
Buggy code:
n=int(input())
arr=[int(i) for i in input().split()]
total=1
for i in range(n):
    if(arr[i]>10**18):
        total=-1
        break
    else:
        total*=arr[i]
        if total>10**18:
            total=-1
            break
print(total)


Fixed code:
n=int(input())
arr=[int(i) for i in input().split()]
total=1
arr.sort()
if(arr[0]==0):
    print(0)
else:

    for i in range(n):
        if(arr[i]>10**18):
            total=-1
            break
        else:
            total*=arr[i]
            if total>10**18:
                total=-1
                break
    print(total)
Buggy code:
import functools

n = int(input())
xs = map(int, input().split())

def foldSum(acc, x):
    return acc*x

if 0 in xs:
    print(0)
elif len([x for x in xs if x > 1]) >= 60:
    print(-1)
else:
    res = functools.reduce(foldSum, xs, 1)

    if res > 1e18:
        print(-1)
    else:
        print(res)



Fixed code:
import functools

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

def foldMulti(acc, x):
    return acc*x

if 0 in xs:
    print(0)
elif len([x for x in xs if x > 1]) >= 60:
    print(-1)
else:
    res = functools.reduce(foldMulti, xs, 1)

    if res > 1e18:
        print(-1)
    else:
        print(res)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
ans = a[0]

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


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

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

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

if ans <= 10 ** 18:
    print(ans)
else:
    print(-1)
Buggy code:
n=int(input())
l=list(map(int,input().split()))
res=1
f=1
for x in l:
    res=res*x
    if(res>1000000000000000000):
        print(-1)
        f=0
        break

if(f==1):
    print(res)
    
        
    
    


Fixed code:


n=int(input())
l=list(map(int,input().split()))
res=1
f=1
if(0 in l):
    print(0)
    f=0
if(f==1):
    
    for x in l:
        res=res*x
        if(res>1000000000000000000):
            print(-1)    
            f=0
            break
    
    if(f==1):
        print(res)
Buggy code:
n = int(input())
arr = [int(x) for x in input().split()] 
prod = 1
flag = 0
for each in arr:
	prod = each * prod
	if prod > 1000000000000000000:
		flag = 1
		break
if flag == 0:
	print(prod)
else:
	print("-1")

Fixed code:
n = int(input())
arr = [int(x) for x in input().split()] 
arr.sort()
prod = 1
flag = 0
for each in arr:
	prod = each * prod
	if prod > 1000000000000000000:
		flag = 1
		break
if flag == 0:
	print(prod)
else:
	print("-1")
Buggy code:
num = int(input())
nums = input().split()

zero_flag = False
for item in nums:
  if item == '0':
    zero_flag = True
    break
    
if zero_flag:
  seki = 0
else:
  seki = 1
  for item in nums:
    seki *= int(item)
    print(seki)
    if seki > 10**18:
      seki = -1
      break

print(seki)

Fixed code:
num = int(input())
nums = input().split()

zero_flag = False
for item in nums:
  if item == '0':
    zero_flag = True
    break
    
if zero_flag:
  seki = 0
else:
  seki = 1
  for item in nums:
    seki *= int(item)
    if seki > 10**18:
      seki = -1
      break

print(seki)
Buggy code:
n = int(input())
a = list(map(int,input().split()))
ans = 1
flag = 0
for i in range(n):
    ans = ans * a[i]
    if a[i] == 0:
        ans = 0
        break
    elif ans > 10**18 or a[i] > 10**18:
        flag = 1
        break

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


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