qyliang/CodeNanoFix huggingface dataset:
Buggy code:
def main():
    N = int(input())
    A_i = list(map(int, input().split()))
    t = 10**18

    acc = 1
    for i in A_i:
        acc *= i
        if t < acc:
            print(-1)
            return
    print(acc)
    return


main()


Fixed code:
def main():
    N = int(input())
    A_i = list(map(int, input().split()))
    t = 10**18

    if 0 in A_i:
        print(0)
        return

    acc = 1
    for i in A_i:
        acc *= i
        if t < acc:
            print(-1)
            return

    print(acc)
    return


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

Fixed code:
N = int(input())
A = list(map(int,input().split()))
PI = 1
if 0 in A:
    PI = 0
else:
    for i in range(N):
        PI = PI*A[i]
        if PI > 10**(18):
            PI = -1
            break
print(PI)
Buggy code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    def solve():
        ans = 1
        for aa in a:
            ans *= aa
            if ans >10**18:
                return -1
        return ans
    print(solve())
        
    
if __name__ == '__main__':
    main()


Fixed code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    def solve():
        if 0 in a:
            return 0
        ans = 1
        for aa in a:
            ans *= aa
            if ans >10**18:
                return -1
        return ans
    print(solve())
        
    
if __name__ == '__main__':
    main()
Buggy code:
a = [0]*n
a = input().split()
n0 = a.count('0')
sum = int(a[0])
if n0 == 0:
  for k in range(len(a)-1):
    sum =sum*int(a[k+1])
    if sum >1000000000000000000:
      print(-1)
      break
  if sum >1000000000000000000:
    print(-1)
  else:
    print(sum)
else:
  print(0)

Fixed code:
n = int(input())
a = [0]*n
a = input().split()
n0 = a.count('0')
sum = int(a[0])
if n0 == 0:
  for k in range(len(a)-1):
    sum =sum*int(a[k+1])
    if sum >1000000000000000000:
      print(-1)
      break
  if sum <=1000000000000000000:
    print(sum)
else:
  print(0)
Buggy code:
n=int(input())
a=list(map(int,input().split()))
mul=1
for i in range(len(a)):
    mul=mul*a[i]
    if mul==0 or mul>1000000000000000000:
      break
if(mul<1000000000000000001):
    print(mul)
else:
    print(-1)
    

Fixed code:
n=int(input())
a=list(map(int,input().split()))
mul=1
key=0
for i in range(len(a)):
    if a[i]==0:
        key=1
        print(0)
        break;
if key==0:
    for i in range(len(a)):
        mul=mul*a[i]
        if mul>1000000000000000000:
            break
    if(mul<1000000000000000001):
        print(mul)
    else:
        print(-1)
Buggy code:
# coding: utf-8
n = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= A[i]
    if(ans > 1000000000000000000):
      print("-1")
      quit()
print(ans)

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

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


print(ans)


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

ans = 1

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


print(ans)
Buggy code:
N=int(input())
array=input().split(" ")
sum=1
for j in range(N):
  if array[j]=="0":
    sum=0
if sum!=0:
  for i in range(N):
    sum=sum*int(array[i])
    if sum>1000000000000000000:
        sum=-1
        break
    else:
      continue
    break
    

Fixed code:
N=int(input())
array=input().split(" ")
sum=1
for j in range(N):
  if array[j]=="0":
    sum=0
if sum!=0:
  for i in range(N):
    sum=sum*int(array[i])
    if sum>1000000000000000000:
        sum=-1
        break
    else:
      continue
    break
print(sum)
Buggy code:
n = int(input())
a = list(map(int, input().split()))

def ans(a):
    if 0 in a:
        return 0
    n = 1
    for i in a:
        n *= i
        if n > 10**18
            return -1
    return n

print(ans(a))

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

def ans(a):
    if 0 in a:
        return 0
    n = 1
    for i in a:
        n *= i
        if n > 10**18:
            return -1
    return n

print(ans(a))
Buggy code:
N = int(input())
A = list(map(int, input().rstrip().rsplit()))
A_dict = {}

for val in A:
    A_dict[val] = A_dict.get(val, 0) + 1

limit = 10**18
ans = 1
for val in A_dict:
    ans *= val ** A_dict[val]

    if ans == 0:
        break
    if ans > limit:
        ans = -1
        break

print(ans)


Fixed code:
N = int(input())
A = list(map(int, input().rstrip().rsplit()))
A_dict = {}

for val in A:
    A_dict[val] = A_dict.get(val, 0) + 1

limit = 10**18
ans = 1

if A_dict.get(0, 0) > 0:
    ans = 0
else:
    for val in A_dict:
        ans *= val ** A_dict[val]

        if ans > limit:
            ans = -1
            break

print(ans)
Buggy code:
N = int(input())
A = [int(i) for i in input().split()]
ans = 1
lim = 10 ** 18
for i in A:
  ans *= i
  if ans > lim:
    break
if ans > lim:
  print(-1)
else:
  print(ans)


Fixed code:
N = int(input())
A = [int(i) for i in input().split()]
ans = 1
lim = 10 ** 18
if not (0 in A):
  for i in A:
    ans *= i
    if ans > lim:
      break
  if ans > lim:
    print(-1)
  else:
    print(ans)
else:
  print(0)
Buggy code:
intNum = int(input())
numList = [int(x) for x in input().split()]

total = 1
judgeNum = 10 ** 18

if 0 in numList:
    total = 0
else:
    for num in numList:
        total *= num
        print("num", num)
        print("total", total)

        if total > judgeNum:
            total = -1
            break

print(total)

Fixed code:
intNum = int(input())
numList = [int(x) for x in input().split()]

total = 1
judgeNum = 10 ** 18

if 0 in numList:
    total = 0
else:
    for num in numList:
        total *= num

        if total > judgeNum:
            total = -1
            break

print(total)
Buggy code:
N = int(input())
A = list(map(int, input().split()))
tmp = 1
pin= 0
for i in range(N):
    tmp = tmp * A[i]
    if tmp > 10 ** 18:
        pin = 1
        print(-1)
if pin == 0:
    print(tmp)

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

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

t = 1
ans = 1
count = 0

for a in A:
    ans *= a
    t *= a
    while t >= 10:
        t /= 10
        count += 1
    if count >= 19:
        ans = -1 
        break

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

Fixed code:

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

t = 1
ans = 1
count = 0

if 0 in A:
    ans = 0
else:  
    for a in A:
        ans *= a
        t *= a
        while t >= 10:
            t /= 10
            count += 1
            if count >= 19:
                ans = -1 
                break

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

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



Fixed code:
n=int(input())
m=list(map(int,input().split()))
x=1
if 0 in m:
  x=0
else:
  for y in m:
    x*=y
    if x>10**18:
      x=-1
      break
print(x)
Buggy code:
def main():
  N = int(input())
  A = list(map(int, input().split()))
  
  if 0 in A:
    print(0)
    return
  
  prod = 1
  for el in A:
    prod *= el
    if prod > 1e18:
      print(-1)
      return
  print (prod)

Fixed code:
def main():
  N = int(input())
  A = list(map(int, input().split()))
  
  if 0 in A:
    print(0)
    return
  
  prod = 1
  for el in A:
    prod *= el
    if prod > 1e18:
      print(-1)
      return
  print (prod)
  
  
main()
Buggy code:
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
now = 1
for i in a:
    now *= i
    if now > 10**18:
        print(-1)
        exit()

print(now)

Fixed code:
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))

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

print(now)
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()))
a.sort()

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

Fixed code:
big = 10**18
n = int(input())
things = list(map(int, input().split()))
result = 1
good = True
if 0 in things:
	print(0)
else:
	for x in things:
		result *= x
		if result > big:
			print(-1)
			good = False
			break
	if good:
		print(result)
Buggy code:
import io,sys
sys.setrecursionlimit(10**6)

def main():
    n = int(input())
    A = list(map(int,sys.stdin.readline().rstrip().split()))
    mul = 1
    for a in A:
        mul*=a
        if mul>10**18:
            mul=-1
            break
    
    print(mul)
main()

Fixed code:
import io,sys
sys.setrecursionlimit(10**6)

def main():
    n = int(input())
    A = list(map(int,sys.stdin.readline().rstrip().split()))
    mul = 1
    if 0 in A:
        mul = 0
    else:
        for a in A:
            mul*=a
            if mul>10**18:
                mul=-1
                break
    
    print(mul)
main()
Buggy code:
N=int(input())
n_list= list(map(int,input().split()))
ans=1
for i in range (N):
  ans*=n_list[i]
  if ans > 10**18 :
    print ('-1')
    break
if ans <= 10**18:
  print(ans)


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

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

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

print(ans)

Fixed code:
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
  print(0)
  quit()

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

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

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

print(a)


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

if 0 in A:
    print(0)

else:

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

    print(a)
Buggy code:
N = int(input())
nums = [int(i) for i in input().split()]

border_num = 10 ** 18


if 0 in nums:
    output = 0
else :
    output = 1
    for _ in nums :
        output *= _
        if output >= border_num:
            output = -1
            break
            
print(output)

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

border_num = 10 ** 18


if 0 in nums:
    output = 0
else :
    output = 1
    for _ in nums :
        output *= _
        if output > border_num:
            output = -1
            break
            
print(output)
Buggy code:
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

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

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

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

Fixed code:
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = 1
for a in A:
    ans *= a
    if ans>10**18:
        print(-1)
        exit()

if ans>10**18:
    print(-1)
else:
    print(ans)
Buggy code:
n = int(input())
a = [int(x) for x in input().split()]

ans = 1

ok = True
for i in range(n):
    ans *= a[i]
    if ans > 10 ** 18:
        ok = False
        break

if ok == True:
    print(ans)
else:
    print(-1)

Fixed code:
n = int(input())
a = [int(x) for x in input().split()]

ans = 1

ok = True
for i in range(n):
    ans *= a[i]
    if ans > 10 ** 18:
        ok = False
        break

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

if ok == True:
    print(ans)
else:
    print(-1)
Buggy code:
import sys

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

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

Fixed code:
import sys

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

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

for i in range(N):
    answer = answer * A[i]
    if answer > 10**18:
        print(-1)
        sys.exit()
        
print(answer)
Buggy code:
import sys
input = sys.stdin.readline
N = int(input())
x = sorted(list(map(int, input().split())))
print(x)
t = 1
for num in x:
    t = t * num
    if t > 10 ** 18:
        print(-1)
        sys.exit()

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


Fixed code:
import sys
input = sys.stdin.readline
N = int(input())
x = sorted(list(map(int, input().split())))
t = 1
for num in x:
    t = t * num
    if t > 10 ** 18:
        print(-1)
        sys.exit()

if (t > 10 ** 18): 
    print(-1)
else:
    print(t)
Buggy code:
import sys

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

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

print(ans)

Fixed code:
import sys

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

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

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

print(ans)
Buggy code:
n = int(input())
a = list(map(int,input().split()))
max = 10 ** 18
ans = 1

if 0 in a:
    print('-1')
    exit

for ele in a:
    ans = ans * ele
    if ans > max:
        print('-1')
        exit

print(ans)


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

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

for ele in a:
    ans = ans * ele
    if ans > max:
        print('-1')
        exit()

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

if 0 in A:
    print(0)
    return

for a in A:
    SUM = SUM * a
    if SUM > 1000000000000000000:
        print(-1)
        return

    print(SUM)

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:
import sys
n=int(input())
a = list(map(int,input().split()))
ans = 1
a.sort()
for i in range(a):
  ans *= a[i]
  if ans > 1000000000000000000:
    print(-1)
    sys.exit()
print(ans)

Fixed code:
import sys
n=int(input())
a = list(map(int,input().split()))
ans = 1
a.sort()
for i in range(len(a)):
  ans *= a[i]
  if ans > 1000000000000000000:
    print(-1)
    sys.exit()
print(ans)
Buggy code:
n=int(input())
arr=list(map(int,input().split()))
t=1
for i in range(n):
  if arr[i]==0:
    t=0
    break
   elif t>10**18:
    t=-1
    break
  t*=arr[i]
  
print(t)
 

Fixed code:
n=int(input())
arr=list(map(int,input().split()))
t=1
arr.sort()
for i in range(n):
    t*=arr[i]
    if arr[i]==0:
        t=0
        break
    elif t>10**18:
        t=-1
        break
print(t)
Buggy code:
n=int(input());
l=list(map(int,input().split(" ")))
t=1000000000000000000
at=1;
f=True;
for x in l:
  at=at*x;
  if(at>t):
    f=False
    break
if(f):
  print(at)
else:
  print(-1)
   

Fixed code:
n=int(input())
l=list(map(int,input().split(" ")))
l.sort();
t=1000000000000000000
at=1;
f=True;
for x in l:
  at=at*x;
  if(at>t):
    f=False
    break
if(f):
  print(at)
else:
  print(-1)
Buggy code:
def solve():
  ans = 1
  for i in A:
    ans *= i
    if ans > 1e18:
      return -1
  return ans


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


Fixed code:
def solve():
  ans = 1
  if 0 in A:
    return 0
  for i in A:
    ans *= i
    if ans > 1e18:
      return -1
  return ans


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

ans=1

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

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

ans=1

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

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

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

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

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

s = 1
l=10**18

for i in a:
    s *= i
    if s > l:
        print(-1)
        exit()
print(s)
Buggy code:
N=input()
a=input().split()
lim=10**18

for i in range(int(N)):
    if(i==0):
    	mul=int(a[0])
    else:
    	mul=mul*int(a[i])
    if(mul>lim):
      print(-1)
      break
    if(i==int(N)-1):
      print(mul)

Fixed code:
N=input()
s=input().split()
a = [int(j) for j in s]
lim=10**18

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

Fixed code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
t=1
for i in a:
  t*=i
  if t>10**18:
    t=-1
    break
print(t)
Buggy code:
n = int(input())
a = [int(i) for i in input().split()]
ans = 1
for i in a:
    ans *= i
    if ans > 10**18: 
        ans = '-1'
        break
print(ans)

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

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

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

def main():
  if 0 in A:
    print(0)
    return
 
  count = 1
  for i in A:
    count *= i
    if count > 10000000000000000000:
      print(-1)
      return
 
  print(count)

main()

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

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

main()
Buggy code:
MAX = pow(10,18)
def main():
    N = int(input())
    A = list(map(int,input().split()))

    if 0 in A:
        print(-1)
        return

    ans = 1
    for a in A:
        ans *= a
        if ans > MAX:
            print(-1)
            return

    print(ans)

main()


Fixed code:
MAX = pow(10,18)
def main():
    N = int(input())
    A = list(map(int,input().split()))

    if 0 in A:
        print(0)
        return

    ans = 1
    for a in A:
        ans *= a
        if ans > MAX:
            print(-1)
            return

    print(ans)

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

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

Fixed code:
#coding: utf-8
times= int(input())
nums= list(map(int, input().split()))
a= 1
if 0 in nums:
  print(0)
  exit()
for i in nums:
  a*= i
  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 ans * a <= 10**18:
        ans *= a
    else: ans = 10**18 + 1
        
print(ans if ans <= 10**18 else -1)

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

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

if zero > 0:
    print(-1)
    exit(0)

for i in range(n):
    ans *= a[i]
    if ans > 1e+18:
        print(-1)
        exit(0)

print(ans)


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

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

if zero > 0:
    print(0)
    exit(0)

for i in range(n):
    ans *= a[i]
    if ans > 1e+18:
        print(-1)
        exit(0)

print(ans)