qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n = int(input())
*arr, = map(int, input().split())
res = 1
for i in range(n):
    res *= arr[i]
    if res > 10 ** 18:
        break
print(res if res <= 10 ** 18 else - 1)


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

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


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

if 0 in A:
  print(0)
  
else:
  ans = 1
  for a in A:
    ans *= a
    if ans>10**18:
      ans = -1
      break
  print(ans)
Buggy code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
'''
N = ii()
A = li()
ans = 1
for num in A:
    ans *= num
    if ans > 10**18:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)
'''

N = ii()
A = li()
ans = 1
for num in A:
    if ans <= 10**18 / num:
        ans *= num
    else:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)

Fixed code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = li()
ans = 1
for num in A:
    ans *= num
    if ans > 10**18:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

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

for i in range(N):
  result *= int(A[i])
  if result >= line:
    result = -1
    break

print(result)

Fixed code:
N = int(input())
A = input().split()
result = 1
line = pow(10,18)

if "0" in A:
  result = 0
else:
  for i in range(N):
    result *= int(A[i])
    if result > line:
      result = -1
      break

print(result)
Buggy code:
N = int(input())
A =[i for i in map(int, input().split())]

if a.count(0) != 0:
    print(0)
else:
    result = 1
    for i in range(N):
        result *= A[i]
        if result > (10**18):
            print(-1)
            break
        else:
            continue
print(result)

Fixed code:
n = int(input())
a = [i for i in map(int, input().split())]
 
if a.count(0) != 0:
  print(0)
else:
  result = 1
  for i in range(n):
    result *= a[i]
    if result > (10**18):
      print(-1)
      break
    else:
      continue
  else:
    print(result)
Buggy code:
n=int(input())
l = list(map(int,input().strip().split()))[:n] 
rs= 1
l.sort()
if l[0]==0 : 
    print(0)
else:
    for i in range(n):
        rs=l[i]*rs
        if (rs>10**18) or (rs<0):
            rs = -1
            break
print(rs)

Fixed code:
n=int(input())
l = list(map(int,input().strip().split()))[:n] 
rs= 1
l.sort()
if l[0]==0 :
    rs=0
else:
    for i in range(n):
        if(10**18 // rs < l[i]):
            rs = -1
            break
        rs=l[i]*rs
print(rs)
Buggy code:
n = int(input())
arr = list(map(int,input().split()))
res = 1
flag = 0
for i in range(n):
  res *= arr[i]
  if res>1000000000000000000:
    print("-1")
    flag = 1
    break
if not flag:
  print(res)

Fixed code:
n = int(input())
arr = list(map(int,input().split()))
res = 1
flag = 0
if 0 in arr:
  print("0")
  flag = 1
if not flag:
  for i in range(n):
    res *= arr[i]
    if res>1000000000000000000:
      print("-1")
      flag = 1
      break
if not flag:
  print(res)
Buggy code:
def intlist(x):
    y = []
    for i in range(len(x)):
        y.append(int(x[i]))
    return y
N = int(input())
A = intlist(input().split())
M = 1

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


Fixed code:
def intlist(x):
    y = []
    for i in range(len(x)):
        y.append(int(x[i]))
    return y
N = int(input())
A = intlist(input().split())
M = 1

A.sort()
if A[0] == 0:
    M = 0
else:
    for i in range(N):
        M = M * A[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:
    print('0')
else:
    for a in A:
        ans *= a
        print(ans)
        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=[int(i) for i in input().split()]
ans=1
flag=True
for i in A:
    ans*=i
    if ans>10**18:
        flag=False
        break
print(ans if flag==True else -1)

Fixed code:
N=int(input())
A=[int(i) for i in input().split()]
ans=1
flag=True
for i in A:
    ans*=i
    if ans>10**18:
        flag=False
        break
if 0 in A:
    flag=True
    ans=0
print(ans if flag==True else -1)
Buggy code:
#Multiplication 2
N = input()
A = list(map(int, input().split()))

P = 1
for i in A:
    P *= i
    if P > 10**18:
        P = -1
        break

print(P)

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

P = 0
if not(0 in A):
    P = 1
    for i in A:
        P *= i
        if P > 10**18:
            P = -1
            break

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



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

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

if 0 in a:
    s = 0

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

ans = 1
flag = 0

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


if flag == 1:
    print(-1)
else:
    print(ans)

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

ans = 1
flag = 0
a.sort()

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



if flag == 1:
    print(-1)
else:
    print(ans)
Buggy code:
int(input())
numbers = tuple(map(int, input().split(' ')))

mul = 1
for n in numbers:
    mul *= n
    if mul == 0:
        print(0)
        break
    elif mul > 10 ** 18:
        print(-1)
        break
else:
    print(mul)


Fixed code:
int(input())
numbers = tuple(map(int, input().split(' ')))

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

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


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

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

limit = 10**18
ans = 1
for one in A:
    ans*=one
    if ans>limit:
        ans=-1
        break
print(ans)

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

limit = 10**18
ans = 1
if 0 in A:
    print(0)
else:
    for one in A:
        ans*=one
        if ans>limit:
            ans=-1
            break
    print(ans)
Buggy code:
n = int(input())
n_list = list(map(int, input().split()))

multi = 1

for i in range(n):
    multi *= n_list[i]
    if multi>1e18:
        break

if multi<=1e18:
    print(multi)
else:
    print(-1)
    

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

multi = 1
a = 1

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

for i in range(n):
    if a == 0:
        multi = 0
        break

    multi *= n_list[i]

    if multi>1e18:
        break

if multi<=1e18:
    print(multi)
else:
    print(-1)
Buggy code:
import sys
readline = sys.stdin.buffer.readline
n = int(readline())
a = map(int, readline().split())
v = 1
for i in a:
  v *= i
  if v > 1000000000000000000:
    print(-1)
    break
  elif v == 0:
    print(0)
    break
else:
  print(v)


Fixed code:
import sys
readline = sys.stdin.buffer.readline
n = int(readline())
a = list(map(int, readline().split()))
a.sort()
v = 1
for i in a:
  v *= i
  if v > 1000000000000000000:
    print(-1)
    break
  elif v == 0:
    print(0)
    break
else:
  print(v)
Buggy code:
import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline

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

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


print(ans)

Fixed code:
import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline
 
n = int(input())
l = list(map(int,input().split()))

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

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

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



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

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

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

print(ans)
    

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

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

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

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

print(ans)


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

print(ans)
Buggy code:
n=input()
list1=map(int,input().split())
if 0 in list1:
    print(0)
else:
    ans=1
    for i in list1:
        ans*=i
        if ans>1e18:
            ans=-1
            break
    print(ans)

Fixed code:
n=input()
list1=list(map(int,input().split()))
if 0 in list1:
    print(0)
else:
    ans=1
    for i in list1:
        ans*=i
        if ans>1e18:
            ans=-1
            break
    print(ans)
Buggy code:
N = int(input())
mylist = list(map(int , input().split(" ")))
result = 1

if 0 in mylist:
    result = 0

else:
    for i in mylist:
        
        if result > 10 ** 18:
            result = -1
            break
        else:
            result *= i
            
print(result)

Fixed code:
N = int(input())
mylist = list(map(int , input().split(" ")))
result = 1

if 0 in mylist:
    result = 0

else:
    for i in mylist:
        
        if result * i > 10 ** 18:
            result = -1
            break
        else:
            result *= i
            
print(result)
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)
print(ans)

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

def mp(nums):
  n = 1
  for num in nums:
    n *=num
  return n

limit= mp([10]*18)
num = mp(nums)

if n>limit:
  print(-1)
else:
  print(num)

Fixed code:
inp = input()
inp = input()
 
def mp(nums):
  if 0 in nums:
    print(0)
    return
  n = 1
  limit = 10**18
  for num in nums:
    n *=num
    if n > limit:
      print(-1)
      return
  print(n)
 
mp([int(x) for x in inp.split(" ")])
Buggy code:
def main ():
  input()
  result = 1
  for i in map(int, input().split()):
    result = result * i
    if result > 10 ** 18:
      result = -1
      break
    if result == 0:
      break
  
  return result

print(main())

Fixed code:
def main ():
  input()
  result = 1
  for i in map(int, input().split()):
    if i == 0:
      result = 0
      break
    
    if result == -1:
      continue
      
    result = result * i
    if result > 10 ** 18:
      result = -1
  
  return result

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

Fixed code:
N=int(input())
li=list(map(int,input().split()))
 
m=li[0]
if 0 in li:
  m=0
else:
  for i in range(1,N):
    m=m*li[i]
    if m>10**18:
      m=-1
      break
print(m)
Buggy code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    a = LI()
    ans = 1
    for ai in a:
        ans *= ai
        if ans > 10 ** 18:
            print(-1)
            return
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Fixed code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    a = LI()
    a.sort()
    ans = 1
    for ai in a:
        ans *= ai
        if ans > 10 ** 18:
            print(-1)
            return
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()
Buggy code:
N=int(input())
A = list(map(int,input().split()))
x=1
y=True
for i in A:
    x= x*i
    if x > 10**18:
        print(-1)
        y=False
        break
if y:
    print(x)

Fixed code:
N=int(input())
A = list(map(int,input().split()))
A.sort()
x=1
y=True
for i in A:
    x= x*i
    if x > 10**18:
        print('-1')
        y=False
        break
if y:
    print(x)
Buggy code:
N=int(input())
listA = list(map(int, input().split()))
result = 1
maxA = 10 ** 18
for a in listA:
    result *= a
    if result == 0 :
        break
    if result > maxA:
        result = -1
        break
print(result)

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

if 0 in listA:
    print(0)
    exit()
result = 1
maxA = 10 ** 18
for a in listA:
    result *= a
    if result > maxA:
        result = -1
        break
print(result)
Buggy code:
n=int(input())
l=list(map(int,input().split()))
s=1
d=1
for i in l:
    s=s*i
    if(s>10**18):
        print(-1)
        d=0
        break
if(d==1):
    print(s)

Fixed code:
n=int(input())
l=sorted(list(map(int,input().split())))
s=1
d=1
for i in l:
    s=s*i
    if(s>10**18):
        print(-1)
        d=0
        break
if(d==1):
    print(s)
Buggy code:
# -*- coding: utf-8 -*-

import numpy as np

N = int(input())

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

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

if np.sum(A > 0) % 2 == 1:
    print(np.prod(A))
    exit(-1)

mul = A[0]
for i in A[1:]:
    if 1000000000000000000 / i < mul:
        print(-1)
        exit(-1)
    mul *= i

if mul > 1000000000000000000:
    print(-1)
    exit(-1)
print(mul)

Fixed code:
# -*- coding: utf-8 -*-

import numpy as np

N = int(input())

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

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

mul = A[0]

if np.sum(A < 0) % 2 == 1:
    for i in A[1:]:
        mul *= i
else:
    for i in A[1:]:
        if 1000000000000000000 / i < mul:
            print(-1)
            exit(0)
        mul *= i

if mul > 1000000000000000000:
    print(-1)
    exit(0)

print(mul)
Buggy code:
a = int(input())
ar = list(map(int,input().split()))
if 0 in ar:
    print(0)
    return
b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        exit()
print(b)


Fixed code:
a = int(input())
ar = list(map(int,input().split()))
if 0 in ar:
    print(0)
    exit()
b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        exit()
print(b)
Buggy code:
N = int(input())
A = [int(i) for i in input().split()]
res=1
for x in A:
    res = res*x
    if res > 10 ** 18:
        res = -1
        break
print(res)

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

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

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


    if flg == 1:
        print(-1)
    else:
        print(ans)
Buggy code:
import numpy as np
import sys
import collections

N = int(input())
A = list(map(int, input().split()))
res = 1
for i in range(N):
    res *= A[i]
    if res > 1e18:
        print(-1)
        sys.exit()

print(res)

Fixed code:
import numpy as np
import sys
import collections

N = int(input())
A = list(map(int, input().split()))
res = 1
if 0 in A:
    print(0)
    sys.exit()
for i in range(N):
    res *= A[i]
    if res > 1e18:
        print(-1)
        sys.exit()
print(res)
Buggy code:
import math
n=input()
a=list(map(int,input().split()))
x=pow(10,18)
s=int(1)
c=True
for i in a:
	s*=i
	if(s>x):
		print('-1')
		c=False
		break
if c:
	print(s)

Fixed code:
import math
n=input()
a=list(map(int,input().split()))
a.sort()
x=pow(10,18)
s=int(1)
c=True
for i in a:
	s*=i
	if(s>x):
		print('-1')
		c=False
		break
if c:
	print(s)
Buggy code:
n = int(input())

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

if l[0] == 0:
  print(0)
  exit()
res = 1

for i in l:
  res *= i
  if res > 10 **18:
    print(res)
    exit()
  print(res)

Fixed code:
n = int(input())

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

if l[0] == 0:
  print(0)
  exit()
res = 1

for i in l:
  res *= i
  if res > 10 **18:
    print(-1)
    exit()
print(res)
Buggy code:
import sys
 
N=int(input())
#print(N)
A=input().split()
A_int = [int(s) for s in A]
#print(A_int)
ans=1
for i in range(N):
  ans=ans*A_int[i]
  if(ans>10**18):
    ans=-1
    break

print(ans)

Fixed code:
import sys
 
N=int(input())
#print(N)
A=input().split()
A_int = [int(s) for s in A]
#print(A_int)
if 0 in A_int:
  print(0)
  sys.exit()


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

print(ans)
Buggy code:
n = int(input())
lst = list(map(int, input().split()))
ans = 1
for a in lst: 
    ans *= a
    if ans > 1e18:
        print(-1)
        break
else:
    print(ans)


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

Fixed code:
N = int(input())
A = list(map(int, input().split()))
A = sorted(A,reverse=True)
B = 1
if 0 in A:
    print(0)
    quit()
else:
    for i in A:
        B *= i
        if B> 10**18:  
            print(-1)
            quit()
print(B)