TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))

ans = 0

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

if ans > 10 ** 18:
    ans = -1

print(ans)


import sys

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

ans = 1

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

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

print(ans)


import sys

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

ans = 1

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

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

print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split()))
ans = 1
sort(A)
for i in range (N):
    ans *= A[i]
    if ans > 10**18:
        ans = -1
        break

print(ans)

N = int(input())
A = list(map(int,input().split()))
ans = 1
A = sorted(A)
for i in range (N):
    ans *= A[i]
    if ans > 10**18:
        ans = -1
        break

print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in a:
    ans *= i
if len(str(ans)) >= 18:
    print ("-1")
else:
    print (ans)

n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print (0)
else:
    for i in a:
        ans *= i
        if 1000000000000000000 < ans:
            ans = -1
            break
    print (ans)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))

lim = 1
for i in range(18):
    lim *= 10

ans = 1

for A_ in A:
    ans *= A
    if ans > lim:
        ans = -1
        break

print(ans)


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

l = 1
for i in range(18):
    l *= 10

ans = 1

for A_ in A:
    ans *= A_
    if ans > l:
        ans = -1
        break

if 0 in A: ans = 0

print(ans)



Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
X,Y=input().split()

N=int(input())
 
X=list(map(int,input().split()))
for i in X:
  if i==0:
    print(0)
    exit(0)

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

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)


Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N=int(input())
A=list(map(int, input().split()))
ans=1
flag=0

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

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

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

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = input().split(" ")
lista = [int(n) for n in a]
if 0 in lista:
  print(0)
  exit()
kotae=1
for i in range(n+1):
  kotae=kotae*lista[i]
  if kotae>10**18:
    print(-1)
    exit()
print(kotae)


from decimal import
n = int(input())
a = input().split(" ")
kotae=Decimal(1)
lista = [int(n) for n in a]
for i in range(n):
  kotae*=Decimal(lista[i])
if kotae>10**18:
  kotae=-1
print(kotae)
  

n = int(input())
a = input().split(" ")
lista = [int(n) for n in a]
if 0 in lista:
  print(0)
  exit()
kotae=1
while kotae<=10**18:
  for i in range(n+1):
    kotae=kotae*lista[i]
  print(kotae)
  break
print(-1)  
       

n = int(input())
a = input().split(" ")
lista = [int(n) for n in a]
if 0 in lista:
  print(0)
  exit()
else:
  kotae=1
  for i in range(n+1):
    kotae=kotae*lista[i]
    if kotae>10**18:
        print(-1)  
        exit()
  print(kotae)


n = int(input())
a = input().split(" ")
lista = [int(n) for n in a]
if 0 in lista:
  print(0)
  exit(0)
else:
  kotae=1
  for i in range(n+1):
    kotae=kotae*lista[i]
    if kotae>10**18:
        print(-1)  
        exit(0)
  print(kotae)


n = int(input())
a = input().split(" ")
kotae=1
listaa = [int(n) for n in a]
lista = sorted(listaa)
if lista[0]==0:
  print(0)
  exit()
for i in range(n):
  kotae*=lista[i]
  if kotae>10**18:
    kotae=-1
    break
if kotae>10**18:
  kotae=-1
print(kotae)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
_,*a=map(int,open(0).read().split())
a.sort(reverse=True)

ans=1

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

print(ans)
                       

_,*a=map(int,open(0).read().split())
a.sort()

ans=1

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

print(ans)    

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import sys
N = int(input())
A = list(map(int, input().split()))
 
ans = 1

if A.count(0) == 0:
    print(0)
    sys.exit()

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

import sys
N = int(input())
A = list(map(int, input().split()))
 
ans = 1

if A.count(0) != 0:
    print(0)
    sys.exit()

for i in A:

    ans = ans*i
    if ans > int(10**18):
        print(-1)
        sys.exit()
 
if ans > int(10**18):
    print(-1)
else:
    print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
total = 1
for i in a:
  total = total*i
if total > 10**8:
  print(-1)
else:
  print(total)


n = int(input())
a = list(map(int,input().split()))
total = 1
for i in a:
  total = total*i
if total > 10**8:
  print(-1)
else:
  print(total)

n = int(input())
a = list(map(int,input().split()))
if 0 in a:
  total = 0
  break
else:
  total=1
  for i in a:
    total *= i
    if total > 10**8:
      total = -1
      break
print(total)


n = int(input())
a = list(map(int,input().split()))
if 0 in a:
  total = 0
else:
  total=1
  for i in a:
    total *= i
    if total > 10**8:
      total = -1
      break
print(total)

n = int(input())
a = list(map(int,input().split()))
if 0 in a:
  total = 0
  exit()
else:
  total=1
  for i in a:
    total = total*i
    if total > 10**8:
      total = -1
      exit()
print(total)


n = int(input())
a = [int(input()) for i in range(n)]
if 0 in a:
  total = 0
else:
  total=1
  for i in a:
    total *= i
    if total > 10**8:
      total = -1
      break
print(total)


n = int(input())
cnt = 1
l = list(map(int, input().split()))
if 0 in l:
    print(0)
else:
    for i in l:
        cnt *= i
        if cnt > 10 ** 18:
            print(-1)
            exit()
        else:
            pass
    print(cnt)


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
a = input().split()
n = len(a)
prod = 0
for i in range(0, n):
    prod *= int(a[i])
if prod > 1e18:
    print(-1)
else:
    print(prod)

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)

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)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
ans = 1
if 0 in A:
    print(-1)
else:
    for i in A:
        ans *= i
        if ans > 1000000000000000000:
            print(-1)
            exit()
print(ans)

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

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

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def f():
  n = int(input())
  arr = list(map(int, input().split(' ')))
  ans = 1
  for i in arr:
    ans = ans * i
    if ans > 1e18:
      print(-1)
      return
    print(ans)
f()

def f():
    n = int(input())
    x = int(1e18)
    arr = list(map(int, input().split(' ')))
    arr.sort()
    ans = 1
    for i in arr:
        # print(i)
        ans = ans * i
        if ans > x:
            print(-1)
            return
    print(ans)
f()


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
arr = list(map(int, input().split()))

maxi = 10 ** 18
sm = 1
for a in arr:
    sm *= a
    if sm >= maxi:
        print(-1)
        exit(0)

print(sm)


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

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

prod = 1
for a in arr:
    prod *= a
    if prod > 1000000000000000000:
        print(-1)
        exit(0)

print(prod)


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = input()
num = [int(x) for x in input().split()]
multiply = 1
for i in num:
    multiply *= i
if (multiply >= 10**18):
    print(-1)
else:
    print(multiply)

num = [int(x) for x in input().split()]
multiply = 1
for i in num:
    multiply *= i
if (multiply >= 10**18):
    print(-1)
else:
    print(multiply)

import sys
N = input()
num = [int(x) for x in input().split()]
multiply = 1

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

for i in num:
    multiply *= i
    if (multiply >= 10**18):
        print(-1)
        sys.exit()
if (0 < multiply and multiply < 10**18):
    print(multiply)

import sys
N = input()
num = [int(x) for x in input().split()]
multiply = 1

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

for i in num:
    multiply *= i
    if (multiply > 10**18):
        print(-1)
        sys.exit()
if (0 < multiply and multiply <= 10**18):
    print(multiply)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = [int(x) for x in input().split()]
if 0 in A:
	print("-1")
	exit(0)
ans = 1
lim = 10**18
for a in A:
	ans *= a
    if ans > lim:
      print("-1")
      exit(0)
print(ans)

N = int(input())
A = [int(x) for x in input().split()]
if 0 in A:
  print("0")
  exit(0)
ans = 1
lim = 10**18
for a in A:
  ans *= a
  if ans > lim:
    print("-1")
    exit(0)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N =int(input())
B = 1
for i in range(N):
    A =list( map(int,input().split()))
    for i in A:
        B = B * i
        
    

C = 10 ** 18
#print(C)
if B > C:
    print(-1)
else:
    print(B)


N =int(input())

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

B = 1
C = 10 ** 18

for i in range(N):
    B = B * A[i]
    if B == 0:
        break
    elif B > C:
        B = -1
        break

print(B)
    


Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
out = 1
for i in range(n):
    out = out * a[i]
    if out == 0:
        print(out)
        quit()
    elif out >＝ 10**18:
        print(-1)
        quit()
print(out)
         

# -*- coding: utf-8 -*-
from decimal import Decimal
# input
n = int(input())
a = list(map(int, input().split()))
out = 1
for i in range(n):
    out = Decimal(out * a[i])
    if out.conut(0) > 0:
        print(out)
        quit()
    elif out > Decimal(10**18):
        print(-1)
        quit()
print(out)


# -*- coding: utf-8 -*-
from decimal import *
# input
n = int(input())
a = list(map(int, input().split()))
out = 1
for i in range(n):
    out = Decimal(out * a[i])
    if out == 0:
        print(out)
        quit()
    elif out >= Decimal(10**18):
        print(-1)
        quit()
print(out)


n = int(input())
a = list(map(int, input().split()))
out = 1
for i in range(n):
    out = out * a[i]
    if out == 0:
        print(out)
        quit()
    elif out >= 10**18:
        print(-1)
        quit()
print(out)

# -*- coding: utf-8 -*-
from decimal import Decimal
# input
n = int(input())
a = list(map(int, input().split()))
out = 1
if 0 in a:
    print(0)
    quit()
for i in range(n):
    out = Decimal(out * a[i])
    if out > Decimal(10**18):
        print(-1)
        quit()
print(out)

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
else:
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1)
        print(ans)
        

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 ()

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map(float,input().split( )))
ans = 1
for a in A:
    ans *= a
    if ans >= 1e18:
        ans = '-1'
        break
for a in A:
    if a == 0:
        ans = 0
print(ans)

N = int(input())
A = list(map(float,input().split( )))
ans = 1
for a in A:
    ans *= a
if ans >= 1e18:
  ans = '-1'
print(ans)

N = int(input())
A = list(map(float,input().split( )))
ans = 1
for a in A:
    ans *= a
    if ans >= 1e18:
        ans = '-1'
        break
for a in A:
    if a == 0:
        ans = 0
if ans == '-1':
  print(ans)
else:
  print(int(ans))

N = int(input())
A = list(map(float,input().split( )))
ans = 1
for a in A:
    ans *= a
if ans >= 1e18:
  ans = '-1'

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

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

N = int(input())
A = list(map(float,input().split( )))
ans = 1
for a in A:
    ans *= a
    if ans > 1e18:
        ans = '-1'
        break
for a in A:
    if a == 0:
        ans = 0
print(ans)

N = int(input())
A= list(map(int,input().split( )))
ans = 1
for a in A:
    ans *= a
    if ans > 1e18:
        ans = '-1'
        break
for a in A:
    if a == 0:
        ans = 0
        break
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
l = [0 for x in range(n)]
l = list(map(int,input().split()))
ans = 1
for i in range(n):
    ans *= l[i]
if ans >= 10**18:
    ans = -1
print(ans)

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

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int,(input().split())))
u = 1  

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

  
  

n = int(input())
a = list(map(int,(input().split())))
u = 1  

if 0 in a:
  print(0)
else:
  for i in a:
    u *=i

    
if u >= 1000000000000000000:
  print(-1)
else:
  print(u)

    

  
  

n = int(input())
a = list(map(int,(input().split())))
u = 1  

if 0 in a:
  print(0)
else:
  for i in a:
    u *=i
#  print(u)  
  if u < 10**18:
    print(u)
  else:
    print(-1)
    

  
  

n = int(input())
a = list(map(int,(input().split())))
u = 0  

if 0 in a:
  print(0)
else:
  for i in a:
    u *=i
#  print(u)  
  if u < 10**18:
    print(u)
  else:
    print(-1)
    

  
  

n = int(input())
a = list(map(int,(input().split())))
u = 1  

if 0 in a:
  print(0)
else:
  for i in a:
    u = i*u
#  print(u)  
  if len(str(u)) < 18:
    print(u)
  else:
    print(-1)
    

  
  

n = int(input())
a = list(map(int,(input().split())))
u = 1  

if 0 in a:
  print(0)
else:
  for i in a:
    u = i*u
#  print(u)  
  if u < 10**18:
    print(u)
  else:
    print(-1)
    

  
  

n = int(input())
a = list(map(int,(input().split())))
u = 1  

if 0 in a:
  print(0)
else:
  for i in a:
    u *=i
    if u >= 1000000000000000000:
      print(-1)
      break
    print(u)

    

  
  

import sys
def main():
  u = 1  
  n = int(input())
  a = list(map(int,(input().split())))
  
  if 0 in a:
    print(0)
    sys.exit()
	
  for i in a:
    u *=i
    if u > 1000000000000000000:
      print(-1)
      sys.exit()

  print(u)


main()

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split(" ")))

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

print(r)        


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

r = 1

for x in a:
    if(x == 0):
        print(0)
        exit(0)    

for x in a:
    r = r * x
    if(r > 10**18):
        print(-1)
        exit(0)
r = int(r)
print(r)        


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
a = list(map(float, input().split()))

for i in range(n):
  a[i] = a[i]/float(frag)
  
ans = 1

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

for i in range(n):  
	ans = ans * float(frag)
    
    
if(ans > 10**18):
    ans = -1

print(int(ans))

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

for i in range(n):
  a[i] = a[i]/frag

ans = 1

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

ans = ans * frag
if(ans > frag):
    ans = -1

print(int(ans))

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

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
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)


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)


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
lim = 1e18
n = int(input());
nums = list(map(int,str(input()).split(" ")))
ans = 1
for num in nums:
  	if num == 0:
    	print(0)
        quit()
    ans *= num
if ans > lim:
    print(-1)
else:
    print(int(ans))



lim = 1e18
n = int(input());
nums = list(map(int,str(input()).split(" ")))
ans = 1
for num in nums:
	ans *= num
    if ans > lim:
    	break
if ans > lim:
	print(-1)
else:
	print(int(ans))


lim = 1e18
n = int(input());
nums = list(map(int,str(input()).split(" ")))
ans = 1
for num in nums:
	if ans <= lim:
    	ans *= num
if ans > lim:
    print(-1)
else:
    print(int(ans))


def main():
    lim = 1e18
    n = int(input())
    nums = list(map(int,str(input()).split(" ")))
    if 0 in nums:
        print(0)
        return
    ans = 1
    for num in nums:
        ans *= num
        if ans > lim:
            print(-1)
            return
    print(ans)
    return

main()


Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
input();l=input().split();x=1
for j in sorted(l):x*=int(j)
  if x>1e18:x=-1;break
print(x)

i = input
i()
x = 1
l = i().split()
if '0' in l:
    print(0)
    quit()
for j in l:
    x *= int(j)
    if x >= 1e18:
        print(-1)
        quit()
print(x)


input();l=input().split();x=1
for j in sorted(l):
  x=x*int(j)if x>1e18or x<0else-1
print(x)

i = input
i()
x = 1
l = i().split()
if 0 in l:
    print(0)
    quit()
for j in l:
    x *= int(j)
    if x >= 1e18:
        print(-1)
        quit()
print(x)

input();l=input().split();x=1
for j in sorted(l):
  x:=x*int(j)if x>1e18or x<0else-1
print(x)

i = input
i()
x = 1
l = i().split()
if 0 in l:
    print(0)
    quit()
for j in l:
    x *= int(j)
    if x >= 1e18:
        print(str(-1))
        quit()
print(x)


i = input
i()
x = 1
l = i().split()
if 0 in l:
    print(0)
    quit()
for j in l:
    x *= int(j)
    if x >= 1e18:
        print(-1)
        quit()
print(x)


input();l=input().split();x=not'0'in l
for j in l:
  x*=int(j);if x>1e18:x=-1;break
print(x)

i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=j-48
  if x>1e18:
    print(-1);quit()
print(x)


input();l=input().split();x=not'0'in l
for j in l:
  x=x*int(j)if x>1e18or x<0
print(x)

i = input
i()
x = 1
l = i().split()
if 0 in l:
    print(0)
    quit()
for j in l:
    x *= int(j)
    if x >= 1e18:
        print(-1)
        break
if x < 1e18:
    print(x)


i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=int(j);if x>1e18:x=-1;break
print(x)


i = input
i()
x = 1
for i in i().split():
    x *= int(i)
if x < 1e18:
    print(x)
else:
    print(-1)

i = input
i()
x = 1
l = i().split()
if '0' in l:
    print(0)
    quit()
for j in l:
    x *= int(j)
    if x >= 1e18:
        print(-1)
        quit()
print(x)


input();l=input().split();x=not"0"in l
for j in l:x=x*int(j)if 0<=x*int(j)<=1e18else-1
print(x)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N=int(input())
X=list(map(int, input().split()))
ans=1
if 0 in X:
    print(0)
else:
    for i in range(N):
        ans *= X[i]
        print(ans)
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)    

_=input()
X=eval(input().replace(*' *'))
print(X if X<10**18 else -1)

_=input()
X=int(eval(input().replace(*' *')))
print(X if X=<1e18 else -1)

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

ans=1
if 0 in X:
    print(0)
else:
    X.sorted(reverse = True)
    for i in range(N):
        ans *= X[i]
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)    

def main():
    N=int(input())
    X=input().split()
    if "0" in X:
        print(0)
        return
    ans=1
    for i in X:
        ans = int(i) * ans
        if 1000000000000000000<ans:
            print(-1)
            return
    print(ans)
main()

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
a=input()
x = list(map(int, input().split()))
x.sort(reverse=true)
if x[-1]==0:
  print(0)
else:
  sum=1
  for i in x:
    sum*=i
    if sum>10**18:
      print(-1)
      break
  if sum<=10**18: print(sum)

a=input()
x = list(map(int, input().split()))
x.sort()
if x[0]==0:
  print(0)
else:
  sum=1
  for i in x:
    sum*=i
    if sum>10**18:
      print(-1)
      break
  if sum<10**18: print(sum)

a=input()
x = list(map(int, input().split()))
x.sort(reverse=True)
if x[-1]==0:
  print(0)
else:
  sum=1
  for i in x:
    sum*=i
    if sum>10**18:
      print(-1)
      break
  if sum<=10**18: print(sum)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
if a[n-1] == 0:
    print(0)
    exit()
ans = 1
for i in a:
    if ans <= 10**18:
        ans *= i
    else:
        ans = -1
        break
if ans > 10*18:
    ans = -1
print(ans)

n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
if a[n-1] == 0:
    print(0)
    exit()
ans = 1
for i in a:
    if ans> 10*18:
        break
    ans *= i
print(ans)

n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
if a[n-1] == 0:
    print(0)
    exit()
ans = 1
for i in a:
    if ans < 10*18:
        ans *= i
    else:
        break
print(ans)

n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
if a[n-1] == 0:
    print(0)
    exit()
ans = 1
for i in a:
    if ans <= 10**18:
        ans *= i
    else:
        ans = -1
if ans > 10*18:
    ans = -1
print(ans)

n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
if a[n-1] == 0:
    print("0")
    exit()
ans = 1
for i in a:
    ans *= i
    if ans > 10 ** 18:
        ans = -1
        break
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def main():
    input()
    A = map(int,input().split())
    if 0 in A:
        print(0)
        return 
    else:
        prod = 1
        for a in A:
            prod*=a
            if prod > 10**18:
                print(-1)
                return
        print(prod)
        return

main()

def main():
    input()
    A = map(int,input().split())
    if 0 in A:
        print(0)
        return 
    else:
        prod = 1
        for a in A:
            prod*=a
            if prod > 10**18:
                print(-1)
                return
        print(prod)

main()

input()
A = list(map(int,input().split()))
if 0 in A:
    print(0)
    quit()
else:
    prod = 1
    for a in A:
        prod*=a
        if prod > 10**18:
            print(-1)
            quit()
    print(prod)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import numpy as np
n = int(input())
a = list(map(int,input().split()))

ans = np.prod(a)
if ans >= 10**18:
    ans = -1
print(ans)


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

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

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

print(c)


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split()))
res = A[0]
for i in range(1,N): 
	res *= A[i]
if res < 10**18:
	print(res)
else:
	print("-1")


N = int(input())
A = list(map(int,input().split()))
res = A[0]
for i in range(1,len(A)): 
	res *= A[i]
if res >= 10**8:
	print("-1")
else:
	print(res)


N = int(input())
A = list(map(int,input().split()))
res = A[0]
for i in range(1,len(A)): 
	res *= A[i]
if res > 10**8:
	print("-1")
else:
	print(res)


a=int(input())
b=input().split(" ")
sum1=1
 
if "0" in b:
    print("0")
else:
    for i in range(a):
        sum1=sum1*int(b[i])
        if sum1>10**18:
            sum1=-1
            break
    print(sum1)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
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)
 

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)

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split()))
ans = 1

for a in A:
    ans *= a


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

A, B = map(float,input().split())
A = int(A)
B = int(B*1000)
ans = A*B//1000
print (ans)


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)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
x=1
a=list(map(int,input().split(" ")))
for i in a:
	x=x*i
    if(x==0):
		break
	if(x>=1000000000000000000):
		break
if(x<=1000000000000000000):
	print(x)
else:
	print(-1)

n = int(input())
x=1
a=list(map(int,input().split(" ")))
if(0 in a):
	print(0)
else:
	for i in a:
		x=x*i
		if(x==0):
			break
		if(x>=1000000000000000000):
			break
	if(x<=1000000000000000000):
		print(x)
	else:
		print(-1)

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
a,b=map(str,input().split())
tempb=float(eval(b)*100)
tempa=int(eval(a))
print(int(tempa*tempb/100))

a,b=map(str,input().split())
tempb=float(b)*100
tempa=int(a)
print(int(tempa*tempb/100))

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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a= list(map(int,input().split()))
c = 1
if 0 in a:
    print(0)
else:
    for x in a:
        if x >10**18:
            print(-1)
            break
        else:
            c*=x
            if c >10**18:
                print(-1)
                break
    else:
        print(z)

n = int(input())
a= map(int,input().split())
c = 1
if 0 in a:
    print(0)
else:
    for x in a:
        if x >10**18:
            print(-1)
            break
        else:
            z = x*c
            c = z
            if z >10**18:
                print(-1)
                break
print(z)

n = int(input())
a= list(map(int,input().split()))
c = 1
if 0 in a:
    print(0)
else:
    for x in a:
        if x >10**18:
            print(-1)
            break
        else:
            c*=x
            if c >10**18:
                print(-1)
                break
    else:
        print(c)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
A = list(map(int, input().split()))
A.sort(reverse=True)
if(A[-1] == 0):
  print(0)
else:
  p = 1
  for An in A:
    p *= An
  if(p > 10 ** 18):
    print(-1)
  else:
    print(p)

A = list(map(int, input().split()))
prodA = 1
for An in A:
  prodA *= An
if prodA > 10**18:
  print(-1)
else:
  print(prodA)
  

import sys
A = list(map(int, input().split()))
A.sort(reverse=True)
if(A[0] == 0):
  print(0)
else:
  p = 1
  for An in A:
    p *= An
    if p > 10 ** 18:
      print(0)
      sys.exit()
  print(p)

import sys
A = list(map(int, input().split()))
A.sort(reverse=True)
if(A[-1] == 0):
  print(0)
else:
  p = 1
  for An in A:
    p *= An
    if p > 10 ** 18:
      print(-1)
      sys.exit()
  print(p)

A = list(map(int, input().split()))
A.sort(reverse=True)
if(A[0] == 0):
  print(0)
else:
  p = 1
  for An in A:
    p *= An
    if p > 10 ** 18:
      print(0)
      break
  print(p)
  
      
    
  

A = list(map(int, input().split()))
prodA = 1
for An in A:
  prodA = prodA * An
if prodA > 10**18:
  print(-1)
else:
  print(prodA)

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

import sys

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
if(A[-1] == 0):
  print(0)
else:
  p = 1
  for An in A:
    p *= An
    if(p > 10 ** 18):
      print(-1)
      sys.exit()
  print(p)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
Ai = list(map(int, input().split()))
p = 1
for i in range(N):
    p = p * Ai[i]
    if p > 10 **18
    	break
if p <= 10 ** 18:
    print(p)
else:
    print("-1")


N = int(input())
Ai = list(map(int, input().split()))
p = 1
i = 0
if 0 in Ai:
    print("0")
else:
    while i <= N - 1:
        p = p * Ai[i]
        if p > 10 ** 18:
            print("-1")
            break
        if i == N - 1:
            print(p)
            break
        i += 1

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import sys

n = int(input())
an_list = list(map(int, input().split()))
an_list.sort()
ans = 1

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

import sys

n = int(input())
an_list = list(map(int, input().split()))
an_list.sort()
ans = 1

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

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))
ans = 1
b = 1
c = 1
p = 10**18
    
for i in range(N):
  elif A[i] == 0:
    c = 0
    break
  else:
    ans *= A[i]
    if p < ans:
      b = -1
      ans = 0
if c == 0:
  print(c)
elif b == -1:
  print(b)
else:
  print(ans)
    
  

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

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n=int(input())
a=[int(x) for x in input().split()]
if 0 in s:
    print(0)
else:
    s=1
    for c in range(n):
        s=s*a[c]
        if s>10**18:
            s=-1
            break
    print(s)

n=int(input())
a=[int(x) for x in input().split()]
if 0 in a:
    print(0)
else:
    s=1
    for c in range(n):
        s=s*a[c]
        if s>10**18:
            s=-1
            break
    print(s)

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
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)  
  

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)  
  


Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
import numpy
n= int(input())
Number=list(map(int,input().split())
print(numpy.prod(Number)
            

n=int(input())
N=list(map(int,input().split()))
res=1
for i in range(n):
  res=res*N[i]
print(res) if res<1000000000000000000 else print("-1")

n = int(input())
nums = list(map(int,input().split()))
limit = 10**18
res = 1
i = 0
if 0 in nums:
    print(0)
    exit()
while i<n:
    res *= nums[i]
    i += 1
    if res > limit:
        res = -1
        break
print(res)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
a = 1
for i in range(N):
  a *= int(input())
if a > 10 ** 18:
  print(-1)
else:
  print(a)

N = int(input())
li = input().split()
a = 1
try:
  h = li.index('0')
  print(0)
  exit()
except:
  d =1
else:
  for i in range(N):
    a *= int(li[i])
    if a > 10 ** 18:
      print(-1)
      exit()
  print(a)

N = int(input())
li = input().split()
a = 1
sikataganai = False
try:
  h = li.index('0')
  print(0)
  sikataganai = True
except:
  for i in range(N):
    a *= int(li[i])
    if a > 10 ** 18:
      print(-1)
      exit()
  if not sikataganai :
    print(a)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
is_zero = False
for i in a:
  if i == 0:
    is_zero = True
    break
if is_zero:
  print(0)
else:
  p = 1
  for i in p:
    p = p*i
    if p > 10**18:
      break
  if p > 10**18:
    p = -1
  print(p)
    

n = int(input())
a = list(map(int,input().split()))
is_zero = False
for i in a:
  if i == 0:
    is_zero = True
    break
if is_zero:
  print(0)
else:
  p = 1
  for i in a:
    p = p*i
    if p > 10**18:
      break
  if p > 10**18:
    p = -1
  print(p)
    


Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n=int(input())
a=map(int,input().split())
a=set(a)
ans=1
if 0 in a:
    ans=0
else:
    for i in a:
        ans*=i
        if ans>10**18:
            ans=-1
            break
print(ans)

n=int(input())
a=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)

n=int(input())
a=list(map(int,input().split()))
ans=1
for i in a:
    ans*=i
print(-1 if ans>=10**18 else ans)

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)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
a = map(int, input().split())
ret = 1
for x in a:
  ret *= x
if ret > 1e+18:
  print(-1)
else:
  print(ret)


_, *a = map(int, input().split())
ret = 1
for x in a:
  ret *= x
  if ret > 10**18:
    print(-1)
    return

print(ret)


_, *a = map(int, open(0).read.split())
ret = 1
for x in sorted(a):
  ret *= x
  if ret > 10**18:
    ret = -1
    break
print(ret)

_, *a = map(int, open(0).read.split())
ret = 1
for x in a:
  ret *= x
  if ret > 10**18:
    ret = -1
    break
print(ret)


_, *a = map(int, open(0).read().split())
ret = 1
for x in sorted(a):
  ret *= x
  if ret > 10 ** 18:
    ret = -1; break
    
print(ret)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
def main():
    i = int(input())
    j = list(map(int, input().split()))
    res = 1
    for jj in j:
        res *= jj
        if 1e18 <= res:
            print(-1)
            return 0

    print(res)


if __name__ == "__main__":
    main()

import math
def main():
    i = int(input())
    j = list(map(int, input().split()))
    res = 1

    if 0 in j:
        print(0)
        return

    for jj in j:
        res *= jj
        if math.pow(10, 18) < res:
            print(-1)
            return

    print(res)


if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
a = int(input())
sum = 1
nums = list(map(int,input().split()))
for i in range(a):
  sum *= nums[i]
if sum<=10**8 :  
	print(sum)
else:
  print(-1)


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)


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()

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 ()

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N=int(input())
A=list(map(int,input().split()))
K=1
for num in A:
    K*num
if K>10**18:
    print(-1)

else:
    print(K)

N=int(input())
A=list(map(int,input().split()))
K=1
if 0 in A:
    print(0)
else:
    for num in A:
        K*=num
        if K>10**18:
            print(-1)
            exit()
    print(K)

Verdicts: Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
n = int(input())
al = list(map(int,input().split()))
al_p = 1

for i in range(n):
    al_p *= al[i]
    if al_p > 10*18:
        print(-1)
        return
        
print(al_p)

n = int(input())
al = list(map(int,input().split()))
al_p = 1

for i in range(n):
    al_p *= al[i]
    if al_p > 10**18:
        print(-1)
        return
        
print(al_p)
    


def main():
    n = int(input())
    al = list(map(int,input().split()))
    al_p = 1

    if 0 in al:
        print(0)
        return

    for i in range(n):
        al_p *= al[i]
        if al_p > 10**18:
            print(-1)
            return
        
    print(al_p)

main()
    

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
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()


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()

Verdicts: Runtime Error

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split()))
ans = 1

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

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

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

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

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

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.  However, if the result exceeds 10^{18}, print `-1` instead.

Submission attempts (in order):
input()
N = int(input())
A = list(map(int, input().split())

S = A[0]
for i in range(1, N):
	S = S * A[i]
	if S > 10**18:
         print(-"1")
print(S)


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

S = 1
for i in range(1, N):
	S *= A[i]
	if S > 1000000000000000000:
         print(-"1")
	
print(S)

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

S = A[0]
for i in range(1, N):
	S = S * A[i]
	if S > 10**18:
         print(-"1")
print(S)

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 ()

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted