qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n=int(input())
A=list(map(int,input().split()))
a=0
ans=1
if 0 in A:
    ans=0
else:
    for a in range(n):
        ans*=A[a]
        a+=1
        if ans<=10**18:
            continue
        else:
            break
print(ans)


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


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

Fixed code:
import sys
N=int(input())
a=list(map(int,input().split()))
for i in a:
  if i==0:
    print(0)
    sys.exit()
    
ans=1
for i in a:
  ans*=i
  if 1e18<ans:
    print("-1")
    sys.exit()
  
print(ans)
Buggy code:
#B
N = int(input())
A = map(int,input().split())
r = 1
for i in A:
    r = r*i
    if r > 10**18:
        r = -1
        break
    else:
        pass
print(r)

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

Fixed code:
n=int(input())
a=list(map(int,input().strip().split(" ")))
if 0 in a:
  ans=0
else:
  ans=1

for i in range(n):
  ans*=a[i]
  if ans>1000000000000000000:
    ans=-1
    break
print(ans)
Buggy code:
n = int(input())
arr = [ int(x) for x in input().strip().split(' ') ]
isZ = False
for x in arr:
    if x == 0:
        isZ = True

if isZ:
    print ("0")
    exit(0)

res = 1
for x in arr:
    res *= x
    if res > 1000000000000000000:
        print ("-1")
        exit(0)
p

Fixed code:
n = int(input())
arr = [ int(x) for x in input().strip().split(' ') ]
isZ = False
for x in arr:
    if x == 0:
        isZ = True

if isZ:
    print ("0")
    exit(0)

res = 1
for x in arr:
    res *= x
    if res > 1000000000000000000:
        print ("-1")
        exit(0)
print (res)
Buggy code:
def demon():
  N = int(input())
  A = list(map(int,input().split()))
  A = sort(A)
  if A[0] == 0:
    print(0)
    return

  X = 1
  for i in A:
    X *= A
    if X > 10 ** 18:
      print("-1")
      return

  print(X)

demon()

Fixed code:
def demon():
  N = int(input())
  A = list(map(int,input().split()))
  A.sort()
  if A[0] == 0:
    print(0)
    return

  X = 1
  for i in A:
    X *= i
    if X > 10 ** 18:
      print("-1")
      return

  print(X)

demon()
Buggy code:
def main():
    _ = input()
    a = list(map(int, input().split()))

    result = 1
    for a_i in a:
        result *= a_i

        if 10**18 < result:
            return -1
        elif result == 0:
            return 0

    return result


if __name__ == '__main__':
    result = main()
    print(result)

Fixed code:
def main():
    _ = input()
    a = list(map(int, input().split()))

    result = 1
    for a_i in a:
        if a_i == 0:
            return 0

    for a_i in a:
        result *= a_i

        if 10**18 < result:
            return -1

    return result


if __name__ == '__main__':
    result = main()
    print(result)
Buggy code:
N = int(input())
A = list(map(int,input().split( )))
ans = 1
for a in A:
    ans *= a
    if ans >= 1e18:
        ans = -1
        break
print(ans)

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


Fixed code:
def main():
    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)


main()
Buggy code:
import sys
N = int(input())
array = list(map(int,input().split()))

if not ( 2 <= N <= 10**5 ): sys.exit()
if not ( 0 <= min(array) and max(array) <= 10**18): sys.exit()

sum = array[0]
for I in range(1,len(array)):
    sum *= array[I]
    if sum >= 10**18: print(-1);sys.exit()
print(sum)

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

if not ( 2 <= N <= 10**5 ): sys.exit()
if not ( 0 <= min(array) and max(array) <= 10**18): sys.exit()
if 0 in array: print(0); sys.exit()

sum = array[0]
for I in range(1,len(array)):
    sum *= array[I]
    if sum > 10**18: print(-1);sys.exit()
print(sum)
Buggy code:
p=int(input())
ans=1
ar=[map(int,input().split())]
if 0 in ar:ans=0
else:
    for i in range(p):
        if ans<1e18:ans*=ar[i]
        else:ans=-1;break
    
print(ans,end='')

Fixed code:
p=int(input())
ans=1
ar=list(map(int,input().split()))
if 0 in ar:ans=0
else:
    for i in range(p):
        if ans<1e18:ans*=ar[i]
        else:ans=-1;break
if ans>1e18:ans=-1
print(ans,end='')
Buggy code:
from sys import exit

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

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

print(tmp)

Fixed code:
from sys import exit

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

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

print(tmp)
Buggy code:
N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in A:
    ans *= i
print(ans)


if ans > 10**18:
    ans = -1
elif min(A) == 0:
    ans = 0

print(ans)

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

if min(A) == 0:
    print(0)
    exit()

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

print(ans)
Buggy code:
# -*- coding:utf-8 -*-
import sys
def main():
  n = int(input().strip())
  l = list(map(int, input().split()))
  sum = 1
  if 0 in l :
    print (0)
    return

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

Fixed code:
# -*- coding:utf-8 -*-
import sys
def main():
  n = int(input().strip())
  l = list(map(int, input().split()))
  sum = 1
  if 0 in l :
    print (0)
    return

  for i in l:
    sum *= i
    if sum - 1000000000000000000 > 0:
      print (-1)
      return
  print (sum)
main()
Buggy code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
prod = 1
if 0 in A:
    print(0)
else:
    for i in A:
        prod *=i
        if prod > int(1e18):
            print(-1)
            break
    print(prod)

Fixed code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
prod = 1
if 0 in A:
    print(0)
else:
    for i in A:
        prod *=i
        if prod > int(1e18):
            print(-1)
            break
    if prod <= int(1e18):
        print(prod)
Buggy code:
a = int(input())
i = list(map(int, input().split()))

ans = 1
flag = 0
for x in range(len(i)):
    ans = ans * i[x]
    if ans > 1000000000000000000:
        flag = 1
        break
    if i[x] == 0:
        flag = 2
        break

if flag == 1:
    print(-1)
elif flag == 2:
    print(0)
else:
    print(ans)

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

ans = 1
flag = 0

if i.count(0) > 0:
    print(0)
    flag = 1

if flag == 0:
    for x in range(len(i)):
        ans = ans * i[x]
        if ans > 1000000000000000000:
            flag = 1
            break

    if flag == 1:
        print(-1)
    elif flag == 2:
        print(0)
    else:
        print(ans)
Buggy code:
n = int(input())
a = list(map(int,input().split()))
ans = 1
if 0 in a :
    ans = 0
else:
    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()))
ans = 1
if 0 in a :
    ans = 0
    print(0)
else:
    for i in a :
        ans *= i
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)
Buggy code:
def multiply2(A):
    res = 1
    for item in A:
        res *= item
        if res > 10**18:
            return '-1'
    return res

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

Fixed code:
def multiply2(A):
    res = 1
    if 0 in A:
        return 0
    for item in A:
        res *= item
        if res > 10**18:
            return -1
    return res

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    print(multiply2(A))
Buggy code:
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    ans = 1
 
    for i in a:
        ans *= i
      	if ans > int(1e18): return -1
    
    
    return ans
    

print(solve())


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

    ans = 1
    if 0 in a: return 0
    for i in a:
        ans *= i
        if ans > int(1e18): return -1
    
    
    return ans
    

print(solve())
Buggy code:
def main():
    n = int(input())
    nums = list(map(int, input().split()))
    
    if 0 in nums:
        print(0)
        return
    
    mul = 1
    for i in nums:
        mul *= nums
        if mul >= 1000000000000000000:
            print(-1)
            return
        
    print(mul)
    
main()

Fixed code:
def main():
    n = int(input())
    nums = list(map(int, input().split()))
    
    if 0 in nums:
        print(0)
        return
    
    mul = 1
    for i in nums:
        mul *= i
        if mul > 1000000000000000000:
            print(-1)
            return
        
    print(mul)
    
main()
Buggy code:
listed = input().split()
mul = 1
for num in listed:
  num = int(num)
  if num == 0:
    mul = 0
    break
  if mul != -1:
    mul *= num
    if mul > 10**18:
      mul = -1
print(mul)

Fixed code:
N = input()
listed = input().split()
mul = 1
for num in listed:
  num = int(num)
  if num == 0:
    mul = 0
    break
  if mul != -1:
    mul *= num
    if mul > 10**18:
      mul = -1
print(mul)
Buggy code:
N = int(input())
a = list(map(int,input().split()))

#print(a)

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

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

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

#print(a)

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

the = pow(10,18)
ans = 1
for i in range(n):
    ans *= A[i]
    if ans > the:
        print(-1)
        break
    else:
        continue
    
if ans < the:
    print(ans)

Fixed code:
n = int(input())
A = [int(i) for i in input().split()]
the = pow(10,18)
ans = 1

if 0 in A:
    print(0)
else:
    for i in range(n):
        ans *= A[i]
        if ans >the:
            print(-1)
            break
        else:
            continue
    if ans <= the:
        print(ans)
Buggy code:
N = int(input())

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

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

Fixed code:
N = int(input())

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

flag = 0
ans = 1

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

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

ret = 1
for i in range(n):
	ret = ret*a[i]
	if(ret > MAX):
		break;
		

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

Fixed code:
n = int(input())
a = list(map(int, input().split()))
MAX = 10**18

ret = 1
for i in range(n):
	if(ret <= MAX):
		ret = ret*a[i]
	if(a[i] == 0):
		ret = 0
		break


if(ret > MAX):
	print(-1)
else:
	print(ret)
Buggy code:
N=int(input())
A=list(map(int,input().split()))
sorted(A)
result=1
for i in A:
    if 0 in A:
        result=0
        break
    if result>1000000000000000000:
        result=-1
        break
    result*=i
print(result)


Fixed code:
N=int(input())
A=list(map(int,input().split()))
sorted(A)
result=1
if 0 in A:
    result=0
for i in A:
    if result==0:
        break
    result*=i
    if result>1000000000000000000:
        result=-1
        break

print(result)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
p = 1
maxp = 10 ** 18
overFlag = False
for i in range(n):
  p *= a[i]
  if p > maxp:
    overFlag = True
    break
if overFlag == False:
  print(p)
else:
  print('-1')

Fixed code:
n = int(input())
a = list(map(int, input().split()))
p = 1
maxp = 10 ** 18
overFlag = False
if 0 in a:
  p = 0
else:
  for i in range(n):
    p *= a[i]
    if p > maxp:
      overFlag = True
      break
if overFlag == True:
    print('-1')
else:
  print(p)
Buggy code:
from sys import stdin
import sys

n = stdin.readline().rstrip().split()
a = stdin.readline().rstrip().split()

total = 1
for i in a:
    if int(i) == 0:
        print(0)
        sys.exit()
        
    total = total*int(i)

    if(total > 1000000000000000000):
        print(-1)
        sys.exit()

print(total)

Fixed code:
from sys import stdin
import sys

n = stdin.readline().rstrip().split()
a = stdin.readline().rstrip().split()

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

total = 1
for i in a:
    total = total*int(i)

    if(total > 1000000000000000000):
        print(-1)
        sys.exit()

print(total)
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):
  ans=-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()
else:
    print(ans)
Buggy code:
N=int(input())
*A,=map(int,input().split())

A=sorted(A,reverse=True)

def mul(A):
    if 0 in A:
      return 0
    m=1
    for na in A:
        if m>10**18:
          return -1
        m*=na
    return m
    
print(mul(A))

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

A=sorted(A,reverse=True)
def mul(A):
    if 0 in A:
      return 0
    m=1
    for na in A:
        m*=na
        if m>10**18:
          return -1
    return m
    
print(mul(A))
Buggy code:
N = int(input())
A = [int(i) for i in input().split()]

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

else:
    print(ans)

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

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

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

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


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

for i in range(n):
    x=a[i]
    if x==0:
        print(0)
        exit()
    if not check==-1:
        sum*=x
        if sum>10**18:
            check=-1
if check==-1:
        print(-1) 
        exit()  
print(sum)
Buggy code:
#from operator import mul
#from functools import reduce
cnt = 1000000000000000000
ans =1
N = int(input())
nums = list(map(int, input().split()))

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

print(ans)


Fixed code:
#from operator import mul
#from functools import reduce
#cnt = 1000000000000000000
ans =1
N = int(input())
nums = list(map(int, input().split()))

if 0 in nums:
        print(0)
        exit()
for num in nums:
    ans *= num
    if ans > 10**18 :
        print(-1)
        exit()
print(ans)
Buggy code:
# from operator import mul
# from functools import reduce

n=int(input())
a=list(map(int,input().split()))
limit=10**18

# ans = 1
# ans = reduce(mul, a) #=> 1320

for i in range(n):
  ans *= a[i]
  if a[i] == 0:
    break

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


Fixed code:
# from operator import mul
# from functools import reduce

n=int(input())
a=list(map(int, input().split()))
# limit=10**18

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

ans = 1
# ans = reduce(mul, a) #=> 1320

for i in range(n):
  ans *= a[i]
  if ans > 10 ** 18:
  # if a[i] == 0:
  #   break
  # elif (ans*a[i]) > limit:
    ans = -1
    break

for i in range(n):
  if a[i] == 0:
      ans = 0

# if ans > limit:
#   print(-1)
# else:
print(ans)
Buggy code:
n = int(input())
a = list(map(int,input().split()))

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


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

for i in range(n):
  if a[i] == 0:
    sum = 0

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

print(sum)
Buggy code:
import sys
t = 10**18

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

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

print(ans)

Fixed code:
import sys

t = 10**18


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

if li.count(0) >= 1:
    print(0)
    sys.exit()

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

print(ans)
Buggy code:
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    th = 10**18
    for a in A:
        ans *= a
        if ans > th:
            print(-1)
            return 
    print(ans if ans <= th else -1)

if '__main__' == __name__:
    resolve()

Fixed code:
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    th = 10**18
    if 0 in A:
        print(0)
        return
    for a in A:
        ans *= a
        if ans > th:
            print(-1)
            return 
    print(ans if ans <= th else -1)

if '__main__' == __name__:
    resolve()
Buggy code:
n = int(input())
lst = list(map(int,input().split()))
flag = 0
z = 1
for i in range(n):
  z *= lst[i]
  if z>(10**18):
    print(-1)
    flag = 1
    break
if flag ==0:
  print(z)

Fixed code:
n = int(input())
lst = sorted(list(map(int,input().split())))[::-1]
flag = 0
z = 1
if 0 in lst:
    z = 0
else:
    for i in range(n):
        z *= lst[i]
        if z>(10**18):
            print(-1)
            flag = 1
            break
if flag ==0:
  print(z)
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)
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)
        exit()

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

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

N = int(input())
X = list(map(int, input().split()))
Y = X[0]
for i in range(1, N):
  Y = X[i] * Y
  if Y > 10 ** 18:
    print(-1)
    sys.exit()
print(Y)

Fixed code:
import sys

N = int(input())
X = list(map(int, input().split()))
if min(X) == 0:
  print(0)
  sys.exit()
Y = X[0]
for i in range(1, N):
  Y = X[i] * Y
  if Y > 10 ** 18:
    print(-1)
    sys.exit()
print(Y)
Buggy code:
input()
l = list(map(int, input().split()))
r = 1
for i in l:
  r *= i
  if r > 10 ** 18:
    print('-1')
    exit(0)
print(r)

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

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


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

for i in range(n):
    ans *= a[i]
    if ans > m:
        ans = -1
        break 

print(ans)

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

for i in range(n):
    if a[i]==0:
        ans = 0

for i in range(n):
    ans *= a[i]
    if ans > m:
        ans = -1
        break 

print(ans)
Buggy code:
#B
n = int(input())
a = list(map(int,input().split()))
flg = True
a.sort
if a[0] == 0:
    print(0)
else:
    result = a[0]
    for i in range(1,n):
        result *= a[i]
        if result > 10**18:
            print(-1)
            flg = False
            break
    if flg:
        print(result)

Fixed code:
#B
n = int(input())
a = list(map(int,input().split()))
flg = True
a.sort()
if a[0] == 0:
    print(0)
else:
    result = a[0]
    for i in range(1,n):
        result *= a[i]
        if result > 10**18:
            print(-1)
            flg = False
            break
    if flg:
        print(result)