qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    limit = 10 ** 18

    ans = 1
    for i in a:
        ans *= i
        if ans > limit:
            ans = -1
            break

    print(ans)

if __name__ == '__main__':
    main()

Fixed code:
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    limit = 10 ** 18

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

    ans = 1
    for i in a:
        ans *= i
        if ans > limit:
            ans = -1
            break

    print(ans)


if __name__ == '__main__':
    main()
Buggy code:
import sys
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)
    sys.exit()
print(ans)

Fixed code:
import sys
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)
    sys.exit()
print(ans)
Buggy code:
N = int(input())
A = list(map(int,input().split()))
answer = 1
for i in A:
    answer = answer * i
    if answer > 10**18:
        break
if answer <= 10**18 :
    print(answer)
else:
    print("-1")

Fixed code:
N = int(input())
A = list(map(int,input().split()))
answer = 1
if not 0 in A:
    for i in A:
        answer = answer * i
        if answer > 10**18:
            print("-1")
            break
    if answer <= 10**18:
        print(answer)
else:
    print("0")
Buggy code:
N=int(input())
A=[int(a) for a in input().split()]
ans=1
for i in range(len(A)):
    ans=ans*A[i]
    if ans>10**18:
        print(-1)
        exit()
    elif ans==0:
        print(0)
        exit()
print(ans)


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


Fixed code:
input()
r = 1
for x in map(int, input().split()):
  if x == 0:
    r = 0
    break
  if r > 0:
    r *= x
    if r > 1e18:
      r = -1
print(r)
Buggy code:
N=int(input())
A = [int(x) for x in input().split()]

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

                


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

ans=1
if 0 in A:
    ans = 0
else:
    A.sort(reverse=True)
    for a in A:
        if a > 10**18:
            ans = -1
            break
        else:
            ans *= a
            if ans > 10**18:
                ans = -1
                break
print(ans)
Buggy code:
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,*a = map(int,read().split())

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


Fixed code:
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,*a = map(int,read().split())
x = 1
INF = 10**18

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


for i in a:
    x *= i
    if x > INF:
        print(-1)
        break
else:
    print(x)
Buggy code:
n=int(input())
A=list(map(int,input().split(" ")))
ans=1
POW=pow(10,18)
check=False
for i in range(n):
  ans*=A[i]
  if ans>POW:
    print(-1)
    check=True
    ans=0
if check==False:
  print(ans)

Fixed code:
n=int(input())
A=list(map(int,input().split(" ")))
ans=1
POW=pow(10,18)
check=False
answer=1
for i in range(n):
  ans*=A[i]
  if ans>POW:
    ans=0
    check=True
    answer=-1
  if A[i]==0:
    answer=0
if answer<1:
  print(answer)
else:
  print(ans)
Buggy code:
n=int(input())
l=list(map(int, input().split()))
dap=1
nodap=0
for i in range(n):
    dap*=l[i]
    if dap>1000000000000000000:
        nodap++
        break
if nodap:
    print("-1")
else:
    print(dap)

Fixed code:
n=int(input())
l=list(map(int, input().split()))
dap=1
nodap=0
zeroexist=0
for i in range(n):
    zeroexist+=(l[i]==0)
if zeroexist>0:
    print("0")
else:
    for i in range(n):
        dap*=l[i]
        if dap>1000000000000000000:
            nodap+=1
            break
    if nodap==1:
        print("-1")
    else:
        print(dap)
Buggy code:
n = int(input())
a = list(map(int,input().split()))

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


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


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

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

print(number)

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

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

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

print(number)
Buggy code:
n = int(input())
p = list(map(int,input().split()))

ans = 1
dotira = False

for x in p:
  ans = ans * x
  if ans > 10 ** 18:
    dotira = True
    break
if dotira:
  print(-1)
else:
  print(ans)

    

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

ans = 1
dotira = False
s = 10**18

if 0 in p :
  print(0)

else:
  
  for x in p:
    ans = ans * x
    if ans > s:
      dotira = True
      break
  if dotira:
    print(-1)
  else:
    print(ans)
Buggy code:
N=int(input())
A=list(map(int,input().split()))
B=1
for i in range(0,len(A)):
  B=A[i]*B
  if(B>10**18):
    B=-1
    break
print(B)

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

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

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

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

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

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


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

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

print(result)


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

result = 1
A.sort()
for i in A:
    result *= i
    if result > 10**18:
        result = -1
        break

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

print(f)

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

n =int(input())
a = LI()
prod = 1
for x in a:
    prod *= x
    if prod > 10**18:
        print(-1)
        break
else:
    print(prod)

Fixed code:
LI = lambda: list(map(int, input().split()))

n = int(input())
a = LI()
prod = 1
if 0 in a:
    print(0)
else:
    for x in a:
        prod *= x
        if prod > 10**18:
            print(-1)
            break
    else:
        print(prod)
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
else:
  print(ans)

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

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



Fixed code:
def main():
  n=int(input())
  anums=list(map(int,input().split()))
  res=1
  if 0 in anums:
    return 0
  for anum in anums:
    res*=anum
    if res>10**18:
      return -1
  return res
print(main())
Buggy code:
N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(N):
  ans *= A[i]
  if ans == 0:
    print(0)
    exit()
  elif 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:
import sys
input = lambda: sys.stdin.readline().rstrip()

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

upto = 10 ** 18

ans = 1
for num in A:
    ans *= num
    if ans > upto:
        print(-1)
        exit()
print(ans)

Fixed code:
import sys
input = lambda: sys.stdin.readline().rstrip()

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

if 0 in A:
    print(0)
    exit()
    
upto = 10 ** 18
ans = 1
for num in A:
    ans *= num
    if ans > upto:
        print("-1")
        exit()
print(ans)
Buggy code:
input()
A = map(int, input().split())
ans = 1

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

for a in A:
    ans *= a
    if 1000000000000000000 < ans:
        print(-1)
        exit()

print(ans)

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

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

for a in A:
    ans *= a
    if 1000000000000000000 < ans:
        print(-1)
        exit()

print(ans)
Buggy code:
MAX = 10 ** 18

N = int(input())
liste = list(map(int, input().split()))
res = 1 


for i in range(N):
    #if(res*2 > MAX):
    #    print(-1)
    #    exit(0)
    res *= liste[i]
    if(res > MAX):
        print(-1)
        exit(0)

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


Fixed code:
MAX = 10 ** 18

N = int(input())
liste = list(map(int, input().split()))
res = 1 
for i in range(N):
    if(liste[i] == 0):
        print(0)
        exit(0)

for i in range(N):
    res *= liste[i]
    #print(res, liste[i])
    if(res > MAX):
        print(-1)
        exit(0)

if(res > MAX):
    print(-1)
else: 
    print(res)
Buggy code:
N = int(input())

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

print(ans)

Fixed code:
N = int(input())

A = list(map(int, input().split()))
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:
N, = map(int, input().split())
X = list(map(int, input().split()))
R = 1
for x in X:
    R*=x
    if R >10**18:
        print(-1)
        break
else:
    print(R)


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

X=list(map(int,input().split()))
result=1
for i in X:
  result*=i
  if result>10**18:
    result=-1
    break

print(result)

Fixed code:
N=int(input())

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

result=1
for i in X:
  result*=i
  if result>10**18:
    result=-1
    break
for i in X:
  if i==0:result=0

print(result)
Buggy code:
n=int(input())
l=list(map(int,input().split()))
c=1
if not 0 in l:
    for li in l:
        c*=li
        if c > 10**18:
            print('-1')
            break
    print(c)
else:
    print(0)

Fixed code:
n=int(input())
l=list(map(int,input().split()))
c=1
if not 0 in l:
    for li in l:
        c*=li
        if c > 10**18:
            
            break
    if c > 10**18:
        print('-1')
    else:
        print(c)
else:
    print(0)
Buggy code:
n = int(input())
a = list(map(int,input().split()))

s = 1
for i in range(n):
    s *= a[i]
    if s > 1000000000000000000:
        break
    elif a[i] == 0:
        break

if s > 1000000000000000000:
    print(-1)
else:
    print(s)

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

ans = 1
printed = False
for x in a:
    ans *= x
    if ans > 1e18:
        print(-1)
        printed = True
        
        
    
if not printed:
    print(ans)

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

printed = False
if 0 in a:
    print(0)
    printed = True

ans = 1

for x in a:
    ans *= x
    if ans > 1e18:
        if not printed:
            print(-1)
            printed = True
        break    
    
if not printed:
    print(ans)
Buggy code:
MX = 10**18
def fun(a,n):
	res = a[0]
	for i in range(1,n):
		res = res * a[i]
		if res > MX:
			return -1
	return res

n = int(input())
a = list(map(int,input().split()))
print(fun(a,n))

Fixed code:
MX = 10**18
def fun(a,n):
	if max(a) > MX:
		return -1
	if 0 in a:
		return 0
	res = a[0]
	for i in range(1,n):
		res = res * a[i]
		if res > MX:
			return -1
	return res

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

MultipliedNum=1
index=0

for i in Alist:
    MultipliedNum*=i
    
    if MultipliedNum>10**18:
        print(-1)
        index=1
        break
        
if index==0:
    print(MultipliedNum)

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

MultipliedNum=1
index=0

if min(Alist)==0:
    print(0)
    index=1

else:
    for i in Alist:
        MultipliedNum*=i

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


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

mul = 1
for i in A:
    mul *= i
    if mul >= limit:
        print("-1")
        break

if mul < limit:
    print(mul)


Fixed code:
N = int(input())
A = list(map(int, input().split()))
limit = 10**18+1

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


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


def solve(N, As):
    ans = 1
    for a in As:
        ans *= a
        if ans > 10 ** 18:
            return -1
    return ans


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))


Fixed code:



def solve(N, As):
    ans = 1
    for a in sorted(As):
        ans *= a
        if ans == 0:
            return 0
        if ans > 10 ** 18:
            return -1
    return ans


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))
Buggy code:
import sys
n=int(input())
a=list(map(int,input().split()))
x = 1
for i in a:
  x *= i
  if x > 10**18:
    print('-1')
    sys.exit()
print(x)
 

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

if 0 in x: ans=0

for i in x:
    ans*=i
    print(i,ans)
    if ans > 1000000000000000000:
        print(-1)
        exit()

print(ans)

Fixed code:
n = int(input())
x = list(map(int, input().split()))
ans = 1

if 0 in x: ans=0

for i in x:
    ans*=i
    if ans > 1000000000000000000:
        print(-1)
        exit()

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

Fixed code:
n=int(input())
l=list(map(int,input().split()))
l.sort()
a=1
for i in l:
  a=a*i
  if a>1000000000000000000:
    a=-1
    break
  if a==0:
    break
print(a)
Buggy code:
n = int(input())
As = list(map(int, input().split()))

ans = 1
for i in range(n):
  ans = ans * As[i]
  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 i in range(n):
  ans = ans*As[i]
  if ans > 10**18:
    print(-1)
    sys.exit()
 
print(ans)
Buggy code:
n = int(input())
an = list(map(int, input().split()))
s = 1
flg = False
for a in an:
  s = s * a
  if s > 10**8 or s< 0:
    flg = True
    break
if flg:
  print(-1)
else:
  print(s)

Fixed code:
n = int(input())
an = list(map(int, input().split()))
s = 1
flg = False
for a in an:
  s = s * a
  if s > 10**18 or s< 0:
    flg = True
    break
if 0 in an:
  print(0)
elif flg:
  print(-1)
else:
  print(s)
Buggy code:

def main():
    n = int(input())
    a = list(map(int,input().split()))
    temp = 1
    for n in a:
        temp *= n
        if temp > 10 ** 18:
            temp = -1
            break
    print(temp)

if __name__ == '__main__':
    main()


Fixed code:

def main():
    n = int(input())
    a = list(map(int,input().split()))
    temp = 1
    if 0 in a:
        temp = 0

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

if __name__ == '__main__':
    main()
Buggy code:
n = int(input())
v = [int(i) for i in input().split()]
res = 1
for i in v:
    res *= i
    if (res > 10**18):
        print(-1)
        exit(0)
print(res)


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

print(ans)

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

a = sorted(a)

ans = 1

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

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

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

prod = 1
for i in range(len(A)):
    prod *= A[i]
    if prod > 10 ** 18:
        print(-1)
        exit()

print(prod)

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

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

prod = 1
for i in range(len(A)):
    prod *= A[i]
    if prod > 10 ** 18:
        print(-1)
        exit()

print(prod)
Buggy code:
N=int(input())
A=list(map(int,input().strip().split()))

INF=1000000000000000000

ans=1
for n in range(N):
    ans*=A[n]
    if ans>INF:
        break
if ans>INF:
    print(-1)
else:
    print(ans)


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

INF=1000000000000000000
if 0 in A:
    print(0)
else:
    ans=1
    for n in range(N):
        ans*=A[n]
        if ans>INF:
            break

    if ans>INF:
        print(-1)
    else:
        print(ans)
Buggy code:
import math
 
n=int(input())
arr=list(map(int,input().split()))
if 0 in arr:
  print("0")
  exit()
ans=1
for i in range(n):
  ans *= arr[i]
  if math.log10(ans) >= 18:
    print("-1")
    exit()
print(ans)

Fixed code:
import math
 
n=int(input())
arr=list(map(int,input().split()))
if 0 in arr:
  print("0")
  exit()
ans=1
for i in range(n):
  ans *= arr[i]
  if math.log10(ans) >= 18 and ans!=1000000000000000000:
    print("-1")
    exit()
print(ans)
Buggy code:
N=int(input())
A=list(map(int,input().split()))
ans=1
if A.count(0) >= 1:
  print(0)
else:
  B=[i for i in A if i != 1]
  if len(B) >= 100:
    print("-1")
  else:
    for k in range(len(B)-1):
      ans=ans*B[k]
    if ans > 1000000000000000000:
      print("-1")
    else:
      print(ans)

Fixed code:
N=int(input())
A=list(map(int,input().split()))
ans=1
if A.count(0) >= 1:
  print(0)
else:
  B=[i for i in A if i != 1]
  if len(B) >= 100:
    print("-1")
  else:
    for k in range(len(B)):
      ans=ans*B[k]
    if ans > 1000000000000000000:
      print("-1")
    else:
      print(ans)
Buggy code:
import sys
a=int(input())
b=list(map(int,input().split()))

ans=1
for i in range(1,a):
  ans=ans*b[i-1]
  
  if ans>10**18:
    print('-1')
    sys.exit()
  if ans==0:
    print('0')
    sys.exit()
print(ans)  
  

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

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


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

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

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