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=sorted(map(int,input().split()))

ans = 0
for x in a:
	if ans == 0 or ans == -1:
		break
	ans = ans * x
	if ans > 1000000000000000000:
		ans = -1

print(ans)

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

ans = 1
for x in a:
	if ans == 0 or ans == -1:
		break
	ans = ans * x
	if ans > 1000000000000000000:
		ans = -1

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):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a_s = sorted(a)
    res = 1
    for i in a_s:
        res *= i
        if res == 0:
            print(0)
            break
        elif res > 10 ** 18:
            print(-1)
            break
        else:
            print(res)
if __name__ == '__main__':
    main()

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a_s = sorted(a)
    res = 1
    for i in a_s:
        res *= i
        if res == 0:
            print(0)
            break
        if res > 10 ** 18:
            print(-1)
            break
    if res > 0 and res <= 10 ** 18:
        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):
n = int(input())
a = list(map(int, input().split()))

r = 1
t = 10 ** 18
for i in a:
  r *= a
  if r > t:
    print(-1)
    return
print(r)

n = int(input())
a = list(map(int, input().split()))
 
r = 1
t = 10 ** 18
for i in a:
  r *= a[i]
  if r > t:
    print(-1)
    return
print(r)

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

# a = [0, 10, 10, 10, 10]

a.sort()
r = 1
t = 10 ** 18
for x in a:
  r *= x
  if r > t:
    break
if r <= t:
  print(r)
else:
  print(-1)

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


N=int(input())
ans =1
A = list(map(int,input().split()))
for i in A:
        if i =0:

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


N=int(input())
ans =1
A = list(map(int,input().split()))
for i in A:
        if i == 0:

               print(0)
               exit()
for i in A:
      
       ans *=i
       if ans >10**18:
               print(-1)
               exit()
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()))

ans = A[0]

for i in range(1, N + 1):
  ans *= A[i]
  
  if ans > 10**(18):
    print(-1)
    
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: 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())

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

if ans :
    for i in range(n):
        ans = ans * a[i];
        if ans > 1000000000000000000 :
            ans = -1
            break
        
print(ans)
    

n = int(input())
b = input()
a = [int(i) for i in b.split()]

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

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

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

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()))
res = 1
for i in range(n):
	res *= a[i]
	if res >= 1e18:
		print(-1)
		exit(0)
print(res)


n = int(input())
a = list(map(int, input().split()))
a.sort()
res = 1
for i in range(n):
	res *= a[i]
	if res > 1e18:
		print(-1)
		exit(0)
print(res)


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())
org = input().split()
for i in range(len(org)):
    org[i] = int(org[i])
A = sorted(org)
print(A)

answer = A[0]
overl = False

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

if overl:
    print("-1")
else:
    print(answer)

N = int(input())
org = input().split()
for i in range(len(org)):
    org[i] = int(org[i])
A = sorted(org)

answer = A[0]
overl = False

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

if overl:
    print("-1")
else:
    print(answer)

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 as np
N=int(input())
 
A=list(map(int, input().split()))

A=np.array(A)

ans=np.prod(A)

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

import sys
N=int(input())
 
A=list(map(int, input().split()))
ans=1
for i in A:
  ans*=i
  if ans//10**18>0:
    print(-1)
    sys.exit()

       
print(ans)

import numpy as np
N=int(input())
 
A=list(map(int, input().split()))

A=np.array(A)

ans=np.prod(A)

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

N=int(input())

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

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):
N = input()
A = list(map(int, input().split()))
 
result = 1 
if 0 in A:
    print(0)
else:
    for i in A:
        result *=i
        if result > 10**18:
            print(-1)
            break
        elif result <= 10**18:
            continue
        else:
            print(result)

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

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

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

#print(a)

ans = int(a[0])
for i in range(1,N):
    if ans > 10**18:
        break
    else:
        ans = ans * int(a[i])
if 0 in a:
    print(0)
elif:if ans > 10**18:
    print(-1)
else:
    print(ans)

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

#print(a)

ans = int(a[0])
for i in range(1,N):
    if ans > 10**18:
        break
    else:
        ans = ans * int(a[i])
if 0 in a:
    print(0)
elif ans > 10**18:
    print(-1)
else:
    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()))
cnt = 1
for i in range(N):
  cnt *= A[i]
  
if cnt >= 10**18:
  print(-1)
else:
  print(cnt)

import sys
N = int(input())

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

print(cnt)

import sys
from decimal import Decimal
N = int(input())
A = list(map(int,input().split()))
A.sort()
cnt = Decimal('1')
for i in range(N):
  if cnt*Decimal(str(A[i]))>Decimal(10**18):
    print(-1)
    sys.exit()
  cnt = Decimal(cnt)*Decimal(A[i])


print(cnt)


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):
def fun(N,arr):
  if 0 in arr:
    print(0)
    return
  
  p = 1
  f = 1
  for i in range(N):
    p*=arr[i]
    if p>10**18:
      f = 1
      break
  if f == 1:
    print(-1)
  else:
    print(p)
  
N = int(input())
arr = list(map(int,input().split()))
fun(N,arr)

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

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

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):
#include <bits/stdc++.h>
using namespace std;

int main(){
  long long N;
  cin >>N;
  
  
  vector<long long> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  
  sort(begin(A),end(A));
  
  long long answer=1;
  for(int i=0; i<N; i++){
    answer*=A[i];
  }
  
  if(answer>1000000000000000000){
  	cout<< -1 << endl;
  }else{
    cout << answer << endl;
  }
  
}


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

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

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 = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") 

n = int(input())
a = set(map(int,input().split()))
num = 1
for x in a:
    num*=x
if 10**18<num:
    num = -1
print(num)


"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

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

    print(num)


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
t = 1e18
if 0 in a:
    print(0)
    exit(0)

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

prin(ans)


import math
import collections


def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if num != 1:
                factor.append(num)
    if not factor:
        return -1
    else:
        factor.append(n)
        return factor


n = int(input())
l = trial_division(n)
if n == 1:
    print(0)
    exit(0)
if l == -1:
    print(1)
    exit(0)
if l[len(l) - 1] == 1:
    l = l[:-1]
c = collections.Counter(l)

ans = 0
for k, v in c.items():
    s = 1
    for i in range(1, v):
        if i * (i + 1) <= v * 2:
            s = max(s, i)
    ans += s
print(ans)


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

ans = 1
t = 1e18
if 0 in a:
    print(0)
    exit(0)

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

print(ans)

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):
import sys
sys.setrecursionlimit(100000000000)
N=int(input())
A=list(map(int,input().split()))
def f(i):
  if i==0:
    return 1
  else:
    return f(i-1)*A[i-1]
a=f(N)
print(a if a<=10**(18) else -1)








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

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

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



ans = 1

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

print(ans)







N = int(input())

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



ans = 1

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









N = int(input())

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

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


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


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(" ")))
total = 1
print(A)
if N == 1:
  print(A[0])
else:
  for i in A:
    total *= i
  if total > 10*18:
    print(-1)
  else:
    print(total)

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

N = int(input())
A = list(map(int,input().split(" ")))
total = 1
A.sort()

for i in A:
  if i == 0:
    total = 0
    break
  elif total > 10**18:
    break
  total = total * i
if total > 10**18:
  print(-1)
else:
  print(total)

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())
l=list(map(int,input().split()))
s=1
for i in l:
  s=s*i
if s<=10**8:
  print(s)
else:
  print("-1")

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

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()
numbers = [int(n) for n in a]
product = 1
for i in range(N):
    product *= numbers[i]
    if product > 10 ** 18:
        print('-1')
        break
    else:
        print(product)

N = int(input())
a =[int(n) for n in input().split()]

product = 1
if 0 in a:
    print(0)
else:
    for i in range(N):
        product *= a[i]
        if product > 10 ** 18:
            print('-1')
            break
    if product <= 10 ** 18:
        print(product)

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):
from operator import mul
from functools import reduce
a=int(input())
li = list(map(int,input().split()))
if 0 in li:
  print(0)
  
else:
  result = 1
  for number in li:
    result = result * number
    if result > 10**18:
      print(-1)
      

    else:
      print(result)

from operator import mul
from functools import reduce
a=int(input())
li = list(map(int,input().split()))

j = reduce(mul, li)
if j >= 10**18:
  print(-1)
else:
  print(j)

from operator import mul
from functools import reduce
a=int(input())
li = list(map(int,input().split()))
j = reduce(mul, nums)
if j >= 10**18:
  print(-1)
else:
  print(j)


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

  if result <= 10**18:
    print(result)

Verdicts: 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 = input()
A_s = list(map(int, input().split()))

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

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

print(res)


from collections import Counter

N = input()
A_str = input().split()

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

c = Counter(sorted(A_str))
res = 1
for i, v in c.items():
    res *= int(i) ** v

    if res > 10 ** 18:
        res = -1
        break

print(res)


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()
a = A.split()
sum = 1
for i in range(N):
    sum *= int(a[i])
    if sum > 10**18:
        print(-1)
        flag = 1
        break
if flag == 0:
    print(sum)

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


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


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
N=int(input())
A=[]
pai=int(1)
hantei=int(0)
A=list(map(int,input().split()))
for i in range(N):
    if A[i]==o:
        print("0")
        sys.exit()
for i in range(N):
    pai=pai*A[i]
    if pai>10**18:
        print("-1")
        hantei=int(1)
        break
if hantei==0:
    print(pai)


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


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 i in range(n):
    if len(str(ans))>=19:
      ans=-1
      break
    else:
      ans*=a[i]
if len(str(ans))>=19:
  ans=-1
print(ans)

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

if 0 in a :
  ans=0
else:
  for i in range(n):
    if len(str(ans))>=19:
      ans='-1'
      break
    else:
      ans*=a[i]
if len(str(ans))>=19:
  ans='-1'
print(ans)

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

for i in range(n):
    ans*=a[i]
if len(str(ans))>=19:
  print(-1)
else:
  print(ans)

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

if 0 in a :
  ans=0
else:
  for i in range(n+1):
    if len(str(ans))>=19:
      ans=-1
      break
    else:
      ans*=a[i]

print(ans)

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

if 0 in a :
  ans=0
else:
  for i in range(n):
    if len(str(ans))>=19:
      ans='-1'
      break
    else:
      ans*=a[i]
if ans==1000000000000000000:
  ans=1000000000000000000
elif len(str(ans))>=19:
  ans=-1
print(ans)

Verdicts: 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):
a=list(map(int,input().split()))
a.sort(reverse=True)
s=a[-1]
if s==0:
    print(0)
else:
    for i in range(0,n-1):
        s*=a[i]
    if s>10**18:
        print(-1)
        sys.exit()
    print(s)

import sys
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
s=a[n-1]
if s==0:
    print(0)
else:
    for i in range(0,n-1):
        s*=a[i]
        if s>10**18:
            print(-1)
            sys.exit()
    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):
n = int(input())
a_list = np.array(list(map(int, input().split())))
if 0 in a_list:
    print(0)
else:
    ans = 1
    flag = 1
    for i in range(0, n):
        ans *= int(a_list[i])
        if ans > 10 ** 18:
            flag = 0
            break
    if flag == 0:
        print(-1)
    else:
        print(ans)

n = int(input())
a_list = list(map(int, input().split()))
if 0 in a_list:
    print(0)
else:
    ans = 1
    flag = 1
    for i in range(0, n):
        ans *= int(a_list[i])
        if ans > 10 ** 18:
            flag = 0
            break
    if flag == 0:
        print(-1)
    else:
        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):
from operator import mul
from functools import reduce

n   = int(input())
a_s = map(int, input().split())

result = reduce(mul, a_s)

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

n  = int(input())
xs = map(int, input().split())

print(-1)

from functools import reduce

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

MAX  = 10 ** 18

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

result = 1
  
for x in xs:
  result *= x
  
  if result > MAX:
    print(-1)
    exit(0)
    
print(result)


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 = a[0]
for i in range(n):
    if i == 0:
        print(0)
        exit()
for i in range(1, n):
    ans = ans * a[i]
    if ans > 10**18:
        print(-1)
        exit()
    
print(ans)

n = int(input())
a = list(map(int,input().split()))
ans = a[0]
for i in range(n):
    if a[i] == 0:
        print(0)
        exit()
for i in range(1, n):
    ans = 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):
def main():
    import sys
    input = sys.stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    a = sorterd(a)
    limit = 10**18
    ans = 1
    for ai in a:
        ans *= ai
        if ans > limit:
            print(-1)
            exit(0)
        if ans == 0:
            break
    print(ans)

    


if __name__ == '__main__':
    main()

def main():
    import sys
    input = sys.stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)
    limit = 10**18
    ans = 1
    for ai in a:
        ans *= ai
        if ans > limit:
            print(-1)
            exit(0)
        if ans == 0:
            break
    print(ans)

    


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 = [int(i) for i in input().split()]
the = pow(10,18)
ans = 1

while ans <the:
    if 0 in A:
        print(0)
        ans = the
        break
    ans *= A[i]

if ans < the:
    print(ans)

import sys
n = int(input())
A = [int(i) for i in input().split()]
if 0 in A:
    print(0)
    sys.exit(0)

the = pow(10,18)
ans = 1
for i in range(n):
    ans *= A[i]
    if ans > the:
        print(-1)
        break
    else:
        continue
    
if ans < the:
    print(ans)

n = int(input())
A = [int(i) for i in input().split()]
the = pow(10,18)
ans = 1

if 0 in A:
    print(0)
else:
    for i in range(n):
        ans *= A[i]
        if ans >the:
            print(-1)
            break
        else:
            continue
    if ans <= the:
        print(ans)
    



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

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)

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


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)

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())
lst = list(map(int,input().split()))
res = 1
for i in lst:
    res *= i
if res >= 1000000000000000000:
    print(-1)
else:
    print(res)


def cal():
    n = int(input())
    lst = list(map(int,input().split()))
    if 0 in lst:
    	return 0
    else:
        prod = 1
        for a in lst:
            prod *= a
            if prod > 1000000000000000000:
                return -1
    return prod
print(cal())


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()))
if 0 in A:
    print(0)
    exit()
mul = A.pop()
for a in A:
    mul *= a
    if mul > 10**8:
        print(-1)
        exit()
print(mul)

N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()
mul = A.pop()
for a in A:
    mul *= a
    if mul > 10^8:
        print(-1)
        exit()
print(mul)


N = int(input())
A = list(map(int, input().split()))
mul = A.pop()
for a in A:
    mul *= a
    if mul > 10^8:
        print(-1)
        exit()
print(mul)

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

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())
li=list(map(int,input().split()))
li.sort()
ans=1
for i in li:
    if i==0:
        ans=-1
    else:
      for i in li:
        ans*=i
        if ans>1000000000000000000:
          exit
        else:
          pass
    
if ans>1000000000000000000:
    print(-1)
else:
    print(ans)


n=int(input())
li=list(map(int,input().split()))
li.sort()
if li[0]==0:
  print(0)
else:
  ans=1
  for i in li:
    ans*=i
    if ans>1000000000000000000:
        print(-1)
        exit()
    else:
        continue
  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())
l=list(map(int,input().split()))
if l.count(0)!=0:
  print(0)
else:
  num=1
  for i in l:
    if num>10**18:
      break
    else:
      num*=i
  if num>=10**18:
    print(-1)
  else:
    print(num)

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

n=int(input())
l=list(map(int,input().split()))
if l.count(0)!=0:
  print(0)
else:
  num=1
  for i in l:
    if num>10**18:
      break
    else:
      num*=i
if num>=10**18:
  print(-1)
else:
  print(num)

n=int(input())
l=list(map(int,input().split()))
if l.count(0)!=0:
  print(0)
else:
  num=1
  for i in l:
    if num>10**18:
      break
    else:
      num*=i
  if num>10**18:
    print(-1)
  else:
    print(num)

Verdicts: 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 = input()
a_array = input().split(" ")

seki = 1
end = False
for a in a_array:
    a = int(a)
    
    if a == 0:
        print(0)
        end=True
        break
    
    seki *= a
    
    if seki > 10**18:
        print(-1)
        end = True
        break

if end == False:
    print(a)

n = input()
a_array = input().split(" ")

seki = 1
end = False

if "0" in a_array:
    print(0)
else:
    for a in a_array:
        a = int(a)
        seki *= a

        if seki > 10**18:
            print(-1)
            end = True
            break

    if end == False:
        print(a)

n = input()
a_array = input().split(' ')

seki = 1
end = False

if "0" in a_array:
    print(0)
else:
    for a in a_array:
        a = int(a)
        seki *= a

        if seki > 10**18:
            print(-1)
            end = True
            break

    if end == False:
        print(seki)

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()))
a.sort()
result = 1
for i in range(len(a)):
  result = result*a[i]
  if result == 0:
    break
  elif result > 1000000000000000000
    break

if result <= 1000000000000000000:
  print(result)
else:
  print(-1)


n = int(input())
a = list(map(int, input().split()))
#print(a)
#import functools

import numpy

result = np.prod(a)

if result <= 1000000000000000000:
  print(result)
else:
  print(-1)

n = int(input())
a = list(map(int, input().split()))
a.sort()
result = 1
for i in range(len(a)):
  result = result*a[i]
  if result == 0:
    break
  elif result > 1000000000000000000:
    break

if result <= 1000000000000000000:
  print(result)
else:
  print(-1)


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 numpy as np

N = input()

str_list = list(input().split())

P = np.prod(str_list)

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

n = int(input())
A = input().split()
A.sort()

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

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):
n = 10**5
a = [i+1 for i in range(n)]
if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)

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

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

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=input()
x=input.split()
prod=1
for i in x:
  prod=prod*i
  if prod>1000000000000000000:
    break
if prod>1000000000000000000:
  print(-1)
else:
  print(prod)

n=input()
x=[int(i) for i in input().split()]
x.sort()
prod=1
for i in x:
  prod=prod*i
  if prod>1000000000000000000:
    break
if prod>1000000000000000000:
  print(-1)
else:
  print(prod)

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

arr = input().split()
count = 1
if "0" in arr:
  count = 0
else: for i in arr:
        count *= int(i)
      if count > 1000000000000000000: count = -1
  
print(count)


n = int(input())

arr = input().split()
count = 1
for i in range(0, n):
  count *= int(arr[i])
  
if count > 10^18: count = -1
  
print(count)

n = int(input())
arr = list(map(int, input().split()))
if 0 in arr: print(0)
else:
	prod = 1
	for i in arr:
		count *= i
	if count > 1000000000000000000: count = -1
	print(count)

n = int(input())
arr = input().split()
def mult():
	if 0 in arr:
  		print(0)
        return 0
    a = 1
    for i in arr:
      a = a * i
    if a > 1000000000000000000:
      print(-1)
      return 0
    else: 
      print(a)
      return 0

mult()

n = int(input())
arr = input().split()


def mult():
    if "0" in arr:
        return 0
    else:
        a = 1
        for i in arr:
            a = a * int(i)
            if a > 1000000000000000000:
                return -1
        return a

print(mult())


Verdicts: Runtime Error

Wrong Answer

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):
'''

                            Online Python Compiler.
                Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute it.

'''

n = int(input()) 
  
a = list(map(int,input().strip().split()))[:n] 
x=1
flag=0
for i in range(n):
    x*=a[i]
    if a[i]==0:
        x*=0
        break
    if x>1000000000000000000:
        flag=1
    else:
        x*=a[i]
        

if x==0:
    print(0)
elif flag==1:
    print(-1)
else:
    print(x)
    


'''

                            Online Python Compiler.
                Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute it.

'''

n = int(input()) 
  
a = list(map(int,input().strip().split()))[:n] 
x=1
flag=0
for i in range(n):
    x*=a[i]
    if a[i]==0:
        x*=0
        break
    if x>1000000000000000000:
        flag=1
    else:
        x*=a[i]
        

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


'''

                            Online Python Compiler.
                Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute it.

'''

n = int(input()) 
  
a = list(map(int,input().strip().split()))[:n] 
x=1
flag=0
flag1=0
for i in range(n):
    if a[i]==0:
        x*=0
        flag1=1
        break
if flag!=1: 
    for i in range(n):
        x*=a[i]
        if x>1000000000000000000:
            flag=1
        else:
            x*=a[i]
        

if flag1==1:
    print(0)
elif flag==1:
    print(-1)
else:
    print(x)
    


'''

                            Online Python Compiler.
                Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute it.

'''

n = int(input()) 
  
a = list(map(int,input().strip().split()))[:n] 
x=1
flag=0
flag1=0
for i in range(n):
    if a[i]==0:
        x*=0
        flag1=1
        break
if flag!=1: 
    for i in range(n):
        if x*a[i]>1000000000000000000:
            flag=1
            break
        else:
            x*=a[i]
        
if flag1==1:
    print(0)
elif flag==1:
    print(-1)
else:
    print(x)
    


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):
# 169 B

import math
n = int(input())
a = list(map(int, input().split()))
p = 1
x = True

p = math.product(a)
if p > (10 ** 18):
    x = False


if x == True:
    print(p)
else:
    print(-1)
        

# 169 B

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

def code(a):
    pro = 1
    if 0 in a:
        print(0)
    else:
        for i in a:
            pro *= i
            if pro > (10 ** 18):
                print(-1)
                return
        print(pro)

code(l)

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()))
k = 1
for i in range(N):
    k = k * A[i]

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

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

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

import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
p = np.prod(A)
if p >= 10 ** 18:
    print(-1)
else:
    print(p)

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

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):
import numpy as np

n = int(input())
a = list(map(int, input().split()))
ans = np.prod(np.array(a))

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


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

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

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

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

N = int(input())
A =[i for i in map(int, input().split())]

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

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

N = int(input())
A =[i for i in map(int, input().split())]

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

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

n = int(input())
a = [i for i in map(int, input().split())]

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

Verdicts: Runtime Error

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):
N = int(input())
An = list(map(int, input().split()))
sum = 1
for i in range(N):
  sum *= An[i]
  if sum > 1e18:
    print(-1)
    quit()
  else sum == 0:
    print(0)
    quit()
print(sum)

N = int(input())
An = list(map(int, input().split()))
sum = 1
max = 10 ** 18
if 0 in An:
  print(0)
  quit()
for i in range(N):
  sum *= An[i]
  if sum > max:
    print(-1)
    quit()
print(sum)

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 numpy as np
import math as mt
N = int(input())
num = list(map(int, input().split()))
answer = 1
for i in range(len(num)):
  if answer*num[i] < 10**18:
    answer = answer*num[i]
    if i == len(num)-1:
      print(answer)
  else:
    print(-1)
    break

import numpy as np
import math as mt
N = int(input())
num = list(map(int, input().split()))
ans = np.prod(num)
if ans != 0:
  if mt.log10(ans) - 18 > 0:
    print(ans)
  else:
    print(-1)
else:
  print(0)

import numpy as np
import math as mt
N = int(input())
num = list(map(int, input().split()))
ans = np.prod(num)
if ans != 0:
  if mt.log10(ans) - 10**18 > 0:
    print(ans)
  else:
    print(-1)
else:
  print(0)

N = int(input())
num = list(map(int, input().split()))
ans = num.prod()

import numpy as np
import math as mt
N = int(input())
num = list(map(int, input().split()))
ans = np.prod(num)
if ans != 0:
   if mt.log10(ans) <8:
      print(ans)
   else:
    print(-1)
else:
  print(0)

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

Verdicts: Wrong Answer

Wrong Answer

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()))
x = 1
if A in 0:
    x = 0
else:
    for i in range(N):
        x *= A[i]
        if x > 10**18:
            x = -1
            break
print(x)


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


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

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

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


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):
31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0

N = int(input())
S = list(map(int,input().split()))
t = 10**18
ans = 1

if 0 in S:
  print(0)
  exit(0)
  
for n in S:
  ans *= n
  if ans > t:
    print(-1)
    exit(0)
  
print(ans)

Verdicts: Runtime Error

Accepted