qyliang/CodeNanoFix huggingface dataset:
Buggy code:
#
import sys
import math
import numpy as np
import itertools

n = int(input())
a=1
ll = [int(i) for i in input().split()] 
print(ll)
for i in range(n):
    a *= ll[i]
if a > 10**18:
    print(-1)
else:
    print(a)



Fixed code:
#
import sys
import math
import numpy as np
import itertools

n = int(input())
a=1
ll = [int(i) for i in input().split()] 
ll.sort()

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

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

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

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


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

for i in range(N):
  ans = ans * A[i]
  if ans = 0:
    break

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

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

for j in range(len(A)):
  if A[j] == 0:
    flag = 1
    ans = 0

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


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

print(ans)

Fixed code:
n = input()
ans = 1
s = list(map(int, input().strip().split()))
if 0 in s:
    print(0)
    exit()
for i in s:
    if ans>10**18:
        print(-1)
        exit()
    ans = ans*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:
    ans = 0
else:
    ans = 1
    for ai in a:
        ans *= ai
        if ans > 10**18:
            ans = -1
        break
        
print(ans)

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

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


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

mul = 1
for i in range(n):
    mul *= a[i]
    if mul > th:
        print(-1)
        exit()
print(mul)


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

if 0 in a:
    print(0)
    exit()
mul = 1
for i in range(n):
    mul *= a[i]
    if mul > th:
        print(-1)
        exit()
print(mul)
Buggy code:
n = int(input())
a= input().split()
level = pow(10, 18)
product = 1

if 0 in a:
  print(0)
else:
  for num in range(n):
    product *= int(a[num])
    if product > level:
      print("-1")
      break
  if product <= level:
    print(product)

Fixed code:
n = int(input())
a= input().split()
level = pow(10, 18)
product = 1

if "0" in a:
  print(0)
else:
  for num in range(n):
    product *= int(a[num])
    if product > level:
      print("-1")
      break
  if product <= level:
    print(product)
Buggy code:
N = int(input())
ans = 1
lim = 10 ** 18
l = 0

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

A0 = set(A)
if 0 in A0:
  ans = 0
else:
  pass

for n in range(N):
  ans = ans * A[n]
  if ans == 0:
    break
  elif ans >= lim:
    l = 1
    break
  else:
    pass

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

Fixed code:
N = int(input())
ans = 1
lim = 10 ** 18
l = 0

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

A0 = set(A)
if 0 in A0:
  ans = 0
else:
  pass

for n in range(N):
  ans = ans * A[n]
  if ans == 0:
    break
  elif ans > lim:
    l = 1
    break
  else:
    pass

if l == 1:
  print(-1)
else:
  print(ans)
Buggy code:
input()
a=1
d=1000000000000000000
for i in input().split():
  a*=[int(i),1][a>d]
print([a,-1][a>d])

Fixed code:
input()
a=1
d=1000000000000000000
for i in input().split():
  a=min(a*int(i), d+1)
print([a,-1][a>d])
Buggy code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    if 0 in a:
        print(0)
    prod = 1
    for i in a:
        prod *= i
        if prod > 1000000000000000000:
            print(-1)
    print(prod)
main()

Fixed code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    if 0 in a:
        print(0)
        return
    prod = 1
    for i in a:
        prod *= i
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
main()
Buggy code:
N = int(input())
a = 1
L = list(map(int, input().split()))
for i in L:
    a *= i
    if(a > 1e18)break

print(-1 if a > 1e18 else a)


Fixed code:
N = int(input())
a = 1
L = list(map(int, input().split()))
L.sort()
for i in L:
    a *= i
    if (a > 1e18):
        break

print(-1 if a > 1e18 else a)
Buggy code:
def foo():
    dontt_use = input()
    n = map(int,list(input().split()))
    total = 1  
    for number in n:
        total = total * number
        if total > 10**18:
            print('-1')
            return
    print(total)

foo()

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

def foo(n):
    total = 1  
    for number in n:
        total = total * number
        if total > 10**18:
            print('-1')
            return
    print(total)
if '0' in str_list :
    print(0)
else:
    foo(n)
Buggy code:
n = input()
b = 1
a = list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    for i in range(len(a)):
        b *= int(a[i])
        if b > 10**18:
            print(-1)
            break
print(b)

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

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


Fixed code:
n = int(input())
a = tuple(map(int,input().split()))
ans = 1
for ai in a:
  if ai == 0:
    print(0)
    exit()
for ai in a:
  ans *= ai
  if ans > 10**18:
    print(-1)
    exit()
print(ans)
Buggy code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
print(A)
i = 10**18
ans = 1

for a in A:
    #print(a,ans)
    if a == 0:
        ans = 0
        break
    else:
        ans *= a
if ans > i:
    print(-1)
else:
    print(ans)

Fixed code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
#print(A)
i = 10**18
ans = 1
if min(A) == 0:
    ans = 0
else:
    for a in A:
        ans *= a
        if ans > i:
            ans = -1
            break
print(ans)
Buggy code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

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


if __name__ == '__main__':
    resolve()


Fixed code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())))

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


if __name__ == '__main__':
    resolve()
Buggy code:
import sys

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

ans=1
for i in range(n):
  ans=ans*m[i]
  if ans>pow(10,18):
    print(-1)
    sys.exit()
  elif m[i]==0:
    print(0)
    sys.exit()

if ans <=pow(10,18):
  print(ans)

Fixed code:
import sys

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

ans=1
if 0 in m:
  print(0)
  sys.exit()

for i in range(n):
  ans=ans*m[i]
  if ans>pow(10,18):
    print(-1)
    sys.exit()

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

Fixed code:
n=int(input())
a=list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    b=a[0]
    for i in a[1:]:
        b*=i
        if b>10**18:
            b=-1
            break
    print(b)
Buggy code:
n = int(input())
l = list(map(int, input().split()))
sol = 1
nula = 0
over = 0
for i in l:
    if (i == 0):
        nula = 1
    sol = sol * i
    if sol>1000000000000000000:
        over = 1
        break
if (nula == 1):
    print(0)
elif (over == 1):
    print(-1)
else:
    print(sol)


Fixed code:
n = int(input())
l = list(map(int, input().split()))
sol = 1
nula = 0
over = 0
for i in l:
    if (i == 0):
        nula = 1
    sol = sol * i
    if sol>1000000000000000000:
        over = 1
        sol = 0
if (nula == 1):
    print(0)
elif (over == 1):
    print(-1)
else:
    print(sol)
Buggy code:
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    ret = 1
    for a in A:
        ret *= a
        if ret > 10**18:
            ret = -1
            break
    print(ret)


if __name__ == '__main__':
    main()

Fixed code:
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    if min(A) == 0:
        print(0)
        return
    ret = 1
    for a in A:
        ret *= a
        if ret > 10**18:
            ret = -1
            break
    print(ret)


if __name__ == '__main__':
    main()
Buggy code:
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

n = I()
a = LI()

tmp = 1
for i in range(n):
    if pow(10,18)<tmp*a[i]:
        print(-1)
        exit()
    else:
        tmp *= a[i]

print(tmp)

Fixed code:
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

n = I()
a = LI()

la = list(a)
if 0 in la:
    print(0)
    exit()
tmp = 1
for i in range(n):
    if pow(10,18)<tmp*a[i]:
        print(-1)
        exit()
    else:
        tmp *= a[i]

print(tmp)
Buggy code:
leng=int(input())
nums=input().split()
x=1

for i in range(leng):
    a=int(nums[i])
    x=x*a
    if x>10**18:
        break

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


Fixed code:
leng=int(input())
nums=input().split()
x=1

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

for i in range(leng):
    a=int(nums[i])
    x=x*a
    if x>10**18:
        break

if x>10**18:
    print(-1)
else:
    print(x)
Buggy code:
#
# author Sidratul
#

from math import prod

if __name__ == '__main__':
    n = input()
    a = list(map(int, input().split(' ')))
    s = 1
    x = True
    for i in range(len(a)):
        s = s * a[i]
        if s > 10**18:
            print(-1)
            x = False
            break
    if x:
        print(s)

Fixed code:
#
# author Sidratul
#

from math import prod

if __name__ == '__main__':
    n = input()
    a = list(map(int, input().split(' ')))
    s = 1
    a.sort()
    x = True
    for i in range(len(a)):
        s = s * a[i]
        if s > 10**18:
            print(-1)
            x = False
            break
    if x:
        print(s)
Buggy code:
import sys 
input = lambda : sys.stdin.readline().strip()
n = int(input())
a = list(map(int,input().split()))
ans = 1
ok = True
for i in range(n):
    if ans>10**18:
        ok = False
        break  
    ans*=a[i]
if ans>10**18:
    ok = False
if ok:
    print(ans)
else:
    print(-1)

Fixed code:
import sys 
input = lambda : sys.stdin.readline().strip()
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    ok = True
    for i in range(n):
        ans*=a[i]
        if ans>(10**18):
            ok = False
            break
    if ok:
        print(ans)
    else:
        print('-1')
Buggy code:
a = int(input())
b = list(map(int,input().split()))
c = 1
for i in range(a):
  c = c * b[i]
  if c > 10 ** 18:
    break
if c > 10 ** 18:
  print(-1)
else:
  print(c)

Fixed code:
a = int(input())
b = list(map(int,input().split()))
c = 1
if 0 in b:
  print(0)
else:
  for i in range(a):
    c = c * b[i]
    if c > 10 ** 18:
      break
  if c > 10 ** 18:
    print(-1)
  else:
    print(c)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
result = 1
overflow = False
for i in a:
    result *= i
    if result > 1e19:
        result = 1
        overflow = True
if result != 0 and overflow:
    print(-1)
else:
    print(result)

Fixed code:
n = int(input())
a = list(map(int, input().split()))
result = 1
overflow = False
for i in a:
    result *= i
    if result > 1e18:
        result = 1
        overflow = True
if result != 0 and overflow:
    print(-1)
else:
    print(result)
Buggy code:
n = int(input())
aaa = list(map(int, input().split()))
INF = 10 ** 18
ans = 1
for a in aaa:
    ans *= a
    if ans > INF:
        print(-1)
        exit()
print(ans)


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

INF = 10 ** 18
ans = 1
for a in aaa:
    ans *= a
    if ans > INF:
        print(-1)
        exit()
print(ans)
Buggy code:
x1 = input()
x2 = [int(i) for i in input().split(" ")]
 
result = 1
for xv in x2:
   if xv == 0:
       result = 0
       break;

   result = xv * result
       
   if 10**18 < result : 
       result = -1
       break
print(result) 



Fixed code:
x1 = input()
x2 = [int(i) for i in input().split(" ")]

result = 0
if 0 in x2:
  None 
else:
  result = 1
  for xv in x2:
     result = xv * result
  
     if 10**18 < result : 
        result = -1
        break


print(result)
Buggy code:
import sys
def main():

    n=int(input())
    p=list(map(int,input().split()))
    s=1
    p=sorted(p)
    for i in p:
        s*=i
        if i==0:
            print(0)
            sys.exit()
        else s>=10**18+1:
            print(-1)
            sys.exit()
    print(s)

if __name__ == '__main__':
    main()


Fixed code:
import sys
def main():

    n=int(input())
    p=list(map(int,input().split()))
    s=1
    p=sorted(p)
    for i in p:
        s*=i
        if i==0:
            print(0)
            sys.exit()
        elif s>=10**18+1:
            print(-1)
            sys.exit()
    print(s)

if __name__ == '__main__':
    main()
Buggy code:
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
#import numpy as np
# from copy import deepcopy
#from collections import deque
#import numba
import math

def run():
    N = int(input())
    A = list(map(int, input().split()))
    limit = 10 ** 18
    ret = 1
    for a in A:
        ret *= a
        if ret > limit:
            print('-1')
            return None
    print(ret)



if __name__ == "__main__":
    run()

Fixed code:
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
#import numpy as np
# from copy import deepcopy
#from collections import deque
#import numba
#import math

def run():
    N = int(input())
    A = list(map(int, input().split()))
    limit = 10 ** 18
    ret = 1
    if 0 in A:
        print(0)
        return None
    for a in A:
        ret *= a
        if ret > limit:
            print('-1')
            return None
    print(ret)



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

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

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

ans = a[0]
for i in range(1, len(a)):
    ans *= a[i]
    if ans > 1000000000000000000:
        ans = -1
        break

print(ans)

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

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

ans = a[0]
for i in range(1, len(a)):
    ans *= a[i]
    if ans > 1000000000000000000:
        ans = -1
        break

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

Fixed code:
num = int(input())
numbers = list(map(int,input().split()))
sum = 1
for i in range(num):
  sum *=numbers[i]
  if (sum>(10**18)):
    sum = -1
    break
if 0 in numbers:
  sum = 0
print (sum)
Buggy code:
N = int(input())
num = list(map(int, input().split()))
answer = 1
for i in range(N):
  if answer*num[i] <= 10**18:
    answer = answer*num[i]
    if i == N-1:
      print(answer)
  else:
    print(-1)
    break

Fixed code:
N = int(input())
num = list(map(int, input().split()))
answer = 1
if 0 in num:
  print(0)
else:
  for i in range(N):
    if answer*num[i] <= 10**18:
      answer = answer*num[i]
      if i == N-1:
        print(answer)
    else:
      print(-1)
      break
Buggy code:
n=int(input())
B = list(map(int,input().split()))
c = 1
ok = 1
for i in range(n):
    c=c*B[i]
    if c>1000000000000000000:
        print(-1)
        ok = 0
        break
if ok==1:
	print(c)


Fixed code:
n=int(input())
B = list(map(int,input().split()))
if 0 in B:
  print(0)
else:
  c = 1
  ok = 1
  for i in range(n):
      c=c*B[i]
      if c>1000000000000000000:
          print(-1)
          ok = 0
          break
  if ok==1:
	  print(c)
Buggy code:
n = int(input())
a_list = list(map(int,input().split(" ")))
mul = 1
for i in range(n):
    if mul > 10**18:
        break
    else:
        mul *= a_list[i]
        # print(mul)
if mul <= 10**18: 
    print(mul)
else:
    print(-1)

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

N = int(input())
cNum = collections.Counter(list(map(int, input().split())))
ans = 1
if cNum[0] != 0:
  print("0")
  exit()
for n in cNum.keys():
  ans *= n**cNum[n]
  if ans > 10**8:
    ans = -1
    break
print(ans)

Fixed code:
import collections

N = int(input())
cNum = collections.Counter(list(map(int, input().split())))
ans = 1
if cNum[0] != 0:
  print("0")
  exit()
for n in cNum.keys():
  ans *= n**cNum[n]
  if ans > 10**18:
    ans = -1
    break
print(ans)
Buggy code:
import numpy as np
n=int(input())
a=list(map(int,input().split()))
ans=1
for i in range(n):
    ans=ans*a[i]
    if ans>10**18:
      print(-1)
      exit()
if ans>10**18:
    anscheck=False
else:
    anscheck=True
print(ans if anscheck else -1)

Fixed code:
import numpy as np
n=int(input())
a=list(map(int,input().split()))
ans=1
if 0 in a:
    print(0)
    exit()
for i in range(n):
    ans=ans*a[i]
    if ans>10**18 and not 0 in a:
      print(-1)
      exit()
if ans>10**18:
    anscheck=False
else:
    anscheck=True
print(ans if anscheck else -1)
Buggy code:
def Multiplication_2():
    N = int(input())
    An = map(int,input().split())

    over = 10 ** 18

    ans = 1
    for i in An:
        ans *= i
        if ans > over:
            return -1

    return ans

print(Multiplication_2())

Fixed code:
def Multiplication_2():
    N = int(input())
    An = list(map(int,input().split()))

    if 0 in An:
        return 0
    
    over = 10 ** 18

    ans = 1
    
    for i in An:
        ans *= i
        if ans > over:
            return -1
        #print(ans)
    
    return ans

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

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

Fixed code:
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=1
f=1
i=0
for i in range(n):
  if ans<=10**18:
    ans=ans*l[i]
  else:
  	f=0
if f==1 and ans<=10**18:
  print(ans)
else:
  print(-1)
Buggy code:
a = int(input())
ar = list(map(int,input().split(" ")))
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 = 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
b = -1
A.sort()
for i in range(n):
    ans *= A[i]
    if ans > 10**18:
        print(b)
        exit()
print(ans)