Problem:


Score : 200 points

Problem Statement

Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.

However, if the result exceeds 10^{18}, print -1 instead.

Constraints

2 \leq N \leq 10^5

0 \leq A_i \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

Print the value A_1 \times ... \times A_N as an integer, or -1 if the value exceeds 10^{18}.

Sample Input 1

2
1000000000 1000000000

Sample Output 1

1000000000000000000

We have 1000000000 \times 1000000000 = 1000000000000000000.

Sample Input 2

3
101 9901 999999000001

Sample Output 2

-1

We have 101 \times 9901 \times 999999000001 = 1000000000000000001, which exceeds 10^{18}, so we should print -1 instead.

Sample Input 3

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

Sample Output 3

0



Sample input:
2
1000000000 1000000000


Sample output:
1000000000000000000

Submission status: Wrong Answer

Solution code:
import numpy as np
n,*a=map(int,open(0).read().split())
s=1
a=np.array(a)
if any(a==0):
  print(0)
  exit()
for i in list(a):
  s*=i
  if s>1e18:
    print(-1)
    exit()
print(s)

Submission status: Wrong Answer

Solution code:
n = input()
a = list(map(int, input().split()))
if 0 in a:
    print(0)
    exit()
ans = 1
for i in a:
    ans *= i
    if len(str(ans)) >= 18 and ans != 10**18:
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
f=1
for i in range(n):
  f*=a[i]
c=0
while f>0:
  c+=1
  f/=10;
if c>19:
  print(-1)
else:
  print(f)

Submission status: Wrong Answer

Solution code:
from decimal import *
n=input()
A=list(map(Decimal,input().split()))
ans=1
if A.count(0)==0:
  for i in A:
    ans*=i
    if ans>10**18:
      ans=-1
      break
print(ans)

Submission status: Wrong Answer

Solution code:
import functools
import operator
N = 2
v = [1, 0, 2]
limit = 10 ** 18
if 0 not in v:
    answer = functools.reduce(operator.mul, v)
else:
    answer = 0
answer = answer if answer <= limit else -1
print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from decimal import Decimal

1
import sys
N=Decimal(input())
L=list(map(Decimal,input().split()))
M=Decimal(100000000000000000000000000000000000000000000000000000000000000000000)
M=1
for i in L:
    if M>1000000000000000000:
        print("-1")
        sys.exit()    
    else:
        M=M*i
print(M)

Submission status: Wrong Answer

Solution code:
listed = input().split()
listed = [int(x) for x in listed]

mul = 1

for num in listed:
  if num == 0:
    mul = 0
    break
  if mul != -1:
    mul *= num
    if mul > 10:
      mul = -1
print(mul)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

N = int(input())
A = np.array([int(a) for a in input().split()])

if np.prod(A)>10**18:
    print(-1)
    sys.exit()
else:
    print(np.prod(A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input()) 
a=list(map(int,input().split())); 
ans=1; 

x=10**18 
flag=0;
for i in a:
	if i==0:
		flag=1
		break

for i in a:
	ans=ans*i
	if ans>x:
		break

if ans>x and flag==0:
	print(-1) 
else:
	print(ans)

Submission status: Wrong Answer

Solution code:
n=input()
A=list(map(int,input().split()))
ans=1
if A.count(0)==0:
  for i in A:
    ans*=i
    if ans>10**18:
      ans=-1
      break
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
num = list(map(int,input().split()))
num.sort()
if(num[0] == 0):
    print(0)
else:
    num = np.array(num)
    ans = np.prod(num)
    if(ans > 10**18):
        print(-1)
    else:
        print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(_) for _ in input().split()]
ans = 1
for i in a:
    if i == 0:
        ans = 0
        break
    ans *= i
    if ans > 10**18:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

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

ans = 1

a.sort()
if 0 in a:
    for x in range(n):
        ans *= a[x]

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

Submission status: Wrong Answer

Solution code:
n= int(input())
s=1
li = list(map(int,input().split()))
for i in range(n):
	s=s*li[i]
	if (s>10**18):
		s=-1
		break
print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from decimal import Decimal

1
import sys
N=Decimal(input())
L=list(map(Decimal,input().split()))
M=Decimal(1)
for i in L:
    if M>1000000000000000000:
        print("-1")
        sys.exit()    
    else:
        M=M*i
print(M)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
ans=1
if 0 in A==True:
    ans=0
else:
    for i in range(N):
        ans=ans*A[i]
        if ans>10**18:
            ans=-1
            break
        elif ans==0:
            break

print(ans)

Submission status: Wrong Answer

Solution code:
listed = input().split()
mul = 1
for num in listed:
  num = int(num)
  if num == 0:
    mul = 0
    break
  if mul != -1:
    mul *= num
    if mul > 10**18:
      mul = -1
print(int(mul))

Submission status: Wrong Answer

Solution code:
listed = input().split()
mul = 1
for num in listed:
  num = int(num)
  if num == 0:
    mul = 0
    break
  if mul != -1:
    mul *= num
    if mul > 10:
      mul = -1
print(mul)

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
s=1
for i in a:
  s*=i
  if s>1e18:
    print(-1)
    exit()
print(s)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[*map(int,input().split())]
a=1
while A:
  a*=A.pop()
  if a > 10**18:
    a=-1
    break
else:
  if 0 in A:
    a=0
  print(a)

Submission status: Wrong Answer

Solution code:
import numpy as np

#A,B,C=(int(x) for x in input().split())
N=int(input())
A=list(map(int, input().split()))

arr_1d=np.array(A)
p = np.prod(arr_1d)

if p<=10**18:
  print(p)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input()
A = A.split(" ")
A = list(map(int, A))
result = 1
for i in range(N):
  result = result*A[i]
  if result > 10**18 or result < -10**18:
    result = -1
print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split()

if "0" in A:
    print(0)

else:
    ans = 1
        
    for n in range(N):
        ans = ans*int(A[n])

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

Submission status: Wrong Answer

Solution code:
import copy

def main():
    n = int(input())
    a = list( map( int, input().split()))
    sum = 1
    if 0 in a:
        print(0)
    else:
        for i in a:
            sum = sum * i
            if sum > 1000000000000000000:
                print(-1)
                break
        print(sum)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

n = int(input())
An = [int(x) for x in input().split()]
An.sort(reverse=True)

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

j = 10 ** 18
ans = 1
for i in range(n):
    if ans > j:
        print(j)
        quit()
    ans *= An[i]


if ans > j :
    print(-1)
    
else :
    print(ans)

Submission status: Wrong Answer

Solution code:
n= int(input())
s=1
li = list(map(int,input().split()))
for i in range(n):
	s=s*li[i]
	if (s>1000000000000000000):
		s=-1
		break
print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

limit = 10 ** 18
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import deque
from sys import stdin

n=int(stdin.readline().rstrip())
li=list(map(int,stdin.readline().split()))
L=deque(li)
ans=1
for i in range(n):
    x=L.popleft()
    ans*=x
    if ans>10**18:
        print(-1)
        exit()
    elif ans==0:
        print(0)
        exit()
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

Number = int(input())
A = list(map(int, input().split()))
answer = np.prod(A)
if answer >= 1000000000000000000:
    print('-1')
else :
    print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = list(map(int, input().split()))

s = np.prod(a)

if (s > pow(10, 18)):
  print(-1)
else:
  print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(str,input().split()))
pr= 1
for i in l:
    i = int(i)
    pr= pr* i
if len(str(pr))>18:
    print(-1)
else:
    print(pr)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split()

if "0" in A:
    print(0)

else:
    ans = 1
        
    for n in range(N):
        ans *= int(A[n])

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
  if (a[i] == 0):
    print(-1)
    sys.exit()
s = np.prod(a)

if (s > pow(10, 18)):
  print(-1)
else:
  print(s)

Submission status: Wrong Answer

Solution code:
listed = input().split()
mul = 1
for num in listed:
  num = int(num)
  if num == 0:
    mul = 0
    break
  if mul != -1:
    mul *= num
    if mul > 10**18:
      mul = -1
print(mul)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
pr= 1
for i in l:
    pr= pr* i
if len(str(pr))>18:
    print(-1)
else:
    print(pr)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

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

sum = a[0]


if 0 in a:
    print('0')

for i in range(1, N):
    sum = sum * a[i]
    if sum > 10**18:
        print('-1')
        exit()

print(sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
ans=1
for i in range(N):
    ans=ans*A[i]
    if ans>10**18:
        ans=-1
        break
    elif ans==0:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
import copy

def main():
    n = int(input())
    a = list( map( int, input().split()))
    sum = 1
    if 0 in a:
        print(0)
    else:
        for i in a:
            if sum * i > 1000000000000000000:
                print(-1)
                break
            sum = sum * i
        print(sum)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
b =1

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

Submission status: Wrong Answer

Solution code:
n=int(input()) 
a=list(map(int,input().split())); 
ans=1; 

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

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

sum = a[0]


if 0 in a:
    print(0)

for i in range(1, N):
    sum = sum * a[i]
    if sum > 10**18:
        print('-1')
        exit()

print(sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input()
A = A.split(" ")
A = list(map(int, A))
result = A[0]
for i in range(1,N):
  result = result*A[i]
  if result > 10**18 or result < -10**18:
    result = -1
print(result)

Submission status: Wrong Answer

Solution code:
import numpy as np
 
N = input()
s = input().split()
k = [int(_) for _ in s]
p = np.prod(k)
if 0 in k:
    print(0)
 
if p < 10**18:
    print(p)
else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
anser = 1
if 0 in A:
    print(0)
for i in A:
    anser *= i
    if anser > 10 ** 18:
        print("-1")
print(anser)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list( map( int, input().split()))
    sum = 1
    if 0 in a:
        print(0)
    else:
        for i in a:
            if sum * i > 1000000000000000000:
                print(-1)
            sum = sum * i
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a=int(input())
b=list(map(int,input().split()))

c=1
for i in b:
    c*=i
if(c<10**18):
    print(c)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))
ans = 1
for i in range(N):
  ans *= A[i]
  if ans > 1000000000000000000:
    print("-1")
    break
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
ans=1
for i in range(N):
    ans=ans*A[i]
    if ans>10**18:
        print(-1)
        exit
    elif ans==0:
        print(0)
        exit
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

Number = int(input())
A = list(map(int, input().split()))
answer = np.prod(A)
if answer > 1000000000000000000:
    print('-1')
else :
    print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

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

sum = a[0]


if 0 in a:
    print(0)

for i in range(1, N):
    sum = sum * a[i]
    if sum > pow(10, 18):
        print('-1')
        break

print(sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.sort()
A.reverse()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, *A = map(int, read().split())
answer = 1

for i in A:
  answer*= i 
  if answer > 10**18:
    # 0の掛け算にならないように
    answer = answer +1
    break

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

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
A=[int(i) for i in input().split()]
p=1
for i in A:
  if i==0:
    print(-1)
    sys.exit()
for i in A:
  p=p*i
  if p>1000000000000000000:
    print(-1)
    sys.exit()
print(p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

 
for i in A:
    ans *= i
    if ans <= 10**18:
        break

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

Submission status: Wrong Answer

Solution code:

n = int(input())
An = [int(x) for x in input().split()]

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

j = 1000000000000000000
ans = 1
for i in range(n):
    if ans > j:
        print(j)
        quit()
    ans *= An[i]


if ans > j :
    print(-1)
    
else :
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
res = 1
A.sort()
for i in range(N):
    res *= A[i]
    if res > (10 ** 18) or res == 0:
        print(-1)
        exit()
print(res)

Submission status: Wrong Answer

Solution code:
from collections import deque
n=int(input())
a=deque()
a=list(map(int,input().split()))
b=0
s=1
for i in range(n):
  l=a.pop()
  if l == 0:
    s=0
    break
    
  s=s*l
  
  if len(str(s)) >= 19:
    if s==10**18 and i == n-1:
      break
    s=-1
    break
    
print(s)

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 1
if 0 in A:
    print(0)
    exit()

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

Submission status: Wrong Answer

Solution code:
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]
  print(i)
if ans >= 10**18:
  ans = -1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

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

sum = a[0]

if a.count(0)>=0:
    print('0')
    exit()


for i in range(1, N):
    sum = sum * a[i]
    if sum > pow(10, 18):
        print('-1')
        break

Submission status: Wrong Answer

Solution code:
def main():
  n = int(input())
  A = input()
  v = 1;
  for a in A.split(' '):
      d = int(a)
      v *= d
      if (v > 1e18):
          print(-1)
          return
  print(v)

main()

Submission status: Wrong Answer

Solution code:
from functools import reduce
from operator import mul
import sys

input = sys.stdin.readline

n = int(input())
An = [int(x) for x in input().split()]

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

j = 1000000000000000000
ans = 1
for i in range(n):
    if ans > j:
        print(j)
        quit()
    ans *= An[i]


if ans > j :
    print(-1)
    
else :
    print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
result=1
for i in a:
    result*=i
    if 10**18<result:
        result=-1
        break
print(result)

Submission status: Wrong Answer

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, gcd
from copy import deepcopy


def main():
    n = int(input())
    a_list = tuple(map(int, input().split()))
    num = 1000000000000000000
    ans = 1
    for i in range(n):
        if i == 0:
            ans = 0
            break
        ans *= a_list[i]
    
    if ans <= num:
        print(ans)
    else:
        print(-1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy

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

val = numpy.prod(A)

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

Submission status: Wrong Answer

Solution code:
num = int(input())
nums = list(map(int,input().split()))
ans = 1
for j in nums:
    ans = ans * j
if(len(str(ans))>=18):
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
 
N = input()
s = input().split()
k = [int(_) for _ in s]
if 0 in k:
    print(0)
    
p = np.prod(k) 
if p <= 10**18:
    print(p)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
input = sys.stdin.readline
 
n = int(input())
a = list(map(int,input().split()))
ans = 1

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

Submission status: Wrong Answer

Solution code:
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)
            exit()
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque
n=int(input())
a=deque()
a=list(map(int,input().split()))
b=0
s=1
for i in range(n):
  l=a.pop()
  s=s*l
  if len(str(s)) >= 19:
    if s==10**18 and i == n-1:
      break
    s=-1
    break
  elif l==0:
    s=0
    break
    
if len(str(s))>19:
  print(-1)
else:
  print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = input().split()
a = 1
b = 0
if "0" in s:
    print("0") 
for i in range(N):
    b += len(s[i])
if b  >18 :
    print("-1")
else:
    for i in range(N):
        a *= int(s[i])
    if a <= 10 ** 18:
        print(a)
    else:
        print("-1")

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
a=[int(i) for i in input().split()]
b = np.prod(a)


if b>pow(10,18):
    print(-1)
else:
    print(b)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
s = 1
for v in x:
    if v == 0:
        print(0)
        exit
    s = s * v

if 10 ** 18 <= s:
    print("-1")
else:
    print(s)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = sorted(list(map(int,input().split())))

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

Submission status: Wrong Answer

Solution code:
from functools import reduce
from operator import mul
import sys

input = sys.stdin.readline

n = int(input())
An = [int(x) for x in input().split()]

if 0 in An:
    print(0)

j = 1000000000000000000
ans = 1
for i in range(n):
    if ans > j:
        print(j)
        quit()
    ans *= An[i]


if ans > j :
    print(-1)
    
else :
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(a) for a in input().split()]

if 0 in A:
    print(0)

else:
    if len(A)%2!=0:
        ans = A[0]
        del A[0]
    else: 
        ans = 1
        
    for n in range(N//2):
        ans = ans*A[n]
        ans = ans*A[-n-1]

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

Submission status: Wrong Answer

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

s = 0

for i in A:
    ans *= i
    if ans > 10 :
        t = ans // 10
        s += t
        ans %= 10
if s >= 18:
    print(-1)
else:
    print(ans * (10 **s))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys

kaisu = int(input())
num = list(map(int,input().split(' ')))
print(num)
val = 1
for i in range(0, kaisu):
    if(num[i] == 0):
        print('0')
        sys.exit()

for j in range(0, kaisu):
    val = val * num[j]
    print(val)
    if(val > 1000000000000000000):
        print('-1')
        sys.exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[*map(int,input().split())]
a=1
while A:
  a*=A.pop()
  if a > 1000000000000000000:
    print(-1)
    break
else:
  print(a)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
li = list(map(int,input().split()))
a = np.array(li)
if a.prod() > 10**18:
    print(-1)
else:
    print(a.prod())

Submission status: Wrong Answer

Solution code:
n = int(input())

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

Submission status: Wrong Answer

Solution code:
import re

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

answer = 1

for i in a:
  answer*= i 
  if answer > 10**18 and i == 0:
    answer = -1
    break



print(answer)

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = input()   
l = list(map(int,arr.split(' ')))
sum = 1
for i in l:
  if len(str(i)) + len(str(sum)) < 18:
    sum *= i
  if sum >= 1e18:
    break
if sum < 1e18:
  print(sum)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
As = list(map(int,input().split()))
sum = 1
for i in As:
    sum *=i
    if sum>10**18:
        sum = -1
        break
print(sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
B = [int(i) for i in input().split()]

if 2 <= N <= 10**5 and N == len(B):
    if 0 in B:
        S = 0
    else:
        S = 1
        for i in range(len(B)):
            S *= B[i]
            if S > pow(10, 18):
                print("-1")
                break
    print(S)

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
a=[int(i) for i in input().split()]
b = np.prod(a)


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

Submission status: Wrong Answer

Solution code:
listed = input().split()
mul = 1
maxi = 10**18
for num in listed:
  num = int(num)
  mul *= num
  if num == 0:
    mul = 0
    break
  if num > maxi**18:
    mul = -1
    break
print(mul)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
a = 1
if 0 in A:
    print(0)
    exit()
for i in A:
    a *= i
    if a >= 10**18:
        print('-1')
        exit()
print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
list = list(map(int, input().split()))
no = 0 
ans = 1
c = 0
if list.count("0") >0:
  print("0")
  exit()
else:
  for i in range(N):
    ans = ans * list[no]
    c = c + len(str(list[no]))
    no += 1
    if c >= 19:
      print("-1")
      exit()
    else:
      continue
print(ans if ans <= 10**18 else "-1")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(input().split())
ans = 1
lim = 100000000000000000000
lim_n = 19
overflag = False
n = sum([len(i) for i in A])

if lim_n >= n:
    overflag = True

for i in A:
    ans *= int(i)

if overflag is True and "0" not in A:
    print('-1')
else:
    print(ans)

# print(lim_n)
# print(n)
# print(ans)

Submission status: Wrong Answer

Solution code:
listed = input().split()
mul = 1
maxi = 10**18
for num in listed:
  num = int(num)
  mul *= num
  if num == 0:
    print(0)
  if num > maxi**18:
    mul = -1
    break
print(mul)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N = int(input())
L = list(map(int, input().split()))
ans = 1

for n in range(N):
 ans = L[n]*ans
 if ans >= 1000000000000000001: ans = -1
 if ans == -1: break

for n in range(N):
 if L[n] == 0: ans = -1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
list = list(map(int, input().split()))
no = 0 
ans = 1
c = 0
if list.count("0") >0:
  print("0")
  exit()
else:
  for i in range(N):
    ans = ans * list[no]
    c = c + len(str(list[no]))
    no += 1
    if c >= 25:
      print("-1")
      exit()
    else:
      continue
print(ans if ans <= 10**18 else "-1")

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
a=[int(i) for i in input().split()]
b = np.prod(a)


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

Submission status: Wrong Answer

Solution code:
listed = input().split()
mul = 1
maxi = 10**18
for num in listed:
  num = int(num)
  mul *= num
  if num == 0:
    print(mul)
  if num > maxi**18:
    print(-1)
print(mul)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
result = 1
flag = 0
for a in A:
    if a == 0:
        flag = 1
        result = 0
        break
    else:
        result = result * a
        if result > pow(10, 18):
            flag = 1
            result = 0
if flag == 1 and flag != 1:
    print(-1)
else:
    print(result)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=map(int,input().split(' '))
s=1
if 0 in l:
    s=0
else:
    
    for i in l:
        s=s*i
if s>10**18:
  print("-1")
else:
  print(s)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N = int(input())
L = list(map(int, input().split()))
ans = 1

for n in range(N):
 ans = L[n]*ans
 if ans >= 1000000000000000001: ans = -1
 if ans == -1: break

print(ans)