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

mod = 10 ** 18
flag = True

if 0 in a:
    print(0)
    quit()
    
if n % 2 == 0:
    left = 1
    right = 1
    for i in range(n // 2):
        if left * right > mod:
            print(-1)
            quit()
        left *= a[i] % mod
        right *= a[-i] % mod
    ans = left * right % mod
    
else:
    left = 1
    right = 1
    for i in range(n // 2):
        if left * right > mod:
            print(-1)
            quit()
        left *= a[i] % mod
        right *= a[-i] % mod
    ans = left * right * a[n // 2 + 1] % mod

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

Submission status: Wrong Answer

Solution code:
a = int(input())
b = input().split()
c =[]
for i in range(a):
    d = int(b[i])
    c.append(d)
from operator import mul
from functools import reduce
P = reduce(mul, c)
if P>=10**18:
    print(-1)
else:
    print(P)
print(int(P))

Submission status: Wrong Answer

Solution code:
N = input()
A = input().split()[:int(N)]
an = 1

an = [an*int(num) for num in A]

if an[0] >= 10**18:
    print(-1)
else:
    print(an[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[*map(int,input().split())]
a=1
while A:
  a*=A.pop()
  if a>10000000000000000000:
    print(-1)
    break
else:
  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 >= 25:
      exit()
    else:
      continue
print(ans if ans <= 10**18 else "-1")

Submission status: Wrong Answer

Solution code:
N=int(input())
An=[]
An=input().split()
An=[int(n) for n in An]
X=1

for i in range(0,N):
    if X>10**18:
        X=-1
        break
    X=X*An[i]
print(X)

Submission status: Wrong Answer

Solution code:
import math
import sys
from decimal import *

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

getcontext().prec = 19

aa = [Decimal(b).log10() for b in a if a != 0]

ans = Decimal('0')

for c in aa:
    ans += c


if ans > 18.0:
    print(-1)
else:
    ans = 1
    for c in a:
        ans *= c
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy
n=int(input())
a=list(map(int,input().strip().split()))[:n]
ans=numpy.prod(a)
if(ans>1000000000000000000):
    print(-1)
else:
    print(ans)

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:
n = int(input())
a = list(map(int,input().split()))
ans = 1

b = sorted(a)

for i in range(n):
    if b[i]==0:
        break
    ans = ans * b[i]

    if ans > 10^18:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
import math
import sys
readline = sys.stdin.buffer.readline

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

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

if(ans<10e18):
    print(ans)

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import math as m

input()
l = list(map(int, input().split()))
c = 10**18
if 0 in l:
  print(0)
else:
  result = m.prod(l)
  if result >= c:
      result = -1
  print(result)

Submission status: Wrong Answer

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

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

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
if ans <= 1000000000000000000:
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int ,input().split()))
s = 1
for i in range(n):
    s *= a[i]

if len(str(s))>=19:
    print("-1")
else:
    print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
AN = list(map(int,input().split()))
ans = AN[0]
for num in range(1,N-1):
    ans = ans*AN[num]

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

Submission status: Wrong Answer

Solution code:
n=int(input())

sum=0
flag=0
fuck=0
a = list(map(int,input().strip().split()))[:n]
for i in a:
    if i==0:
        fuck=1
    #print(f)
    sum=sum*i
    if sum > 10**18:
        flag=1

if fuck == 1:
    print(0)
else:
    if flag==0:
        print(sum)
    else:
        print(-1)

Submission status: Wrong Answer

Solution code:
import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)
N = int(input())
A = [ int(x) for x in input().split() ]
prod = functools.partial(functools.reduce, operator.mul)
print(prod(A))

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

n = int(input())
h = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
#一行で入力された数値をリストに

ans = np.prod(h)
if ans > (1000000000000000000):
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())

a=[0]*n
a=list(map(int,input().split()))

x=np.prod(a)

if x>=pow(10,18):
    print('-1')
else:
    print(x)

Submission status: Wrong Answer

Solution code:
N=int(input())
if N>=2 and N<=10**5:
    array = list(map(int, input().strip().split()))
    if N==len(array):
        if array[0]>=0 and array[-1]<=10**18:
            mul=1
            for index,number in enumerate(array):
                mul*=array[index]
            if mul>=10**18:
               print(-1)
            else:
                print(mul)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = input().split()
c =[]
for i in range(a):
    d = int(b[i])
    c.append(d)
from operator import mul
from functools import reduce
P = reduce(mul, c)
if P>=10**18:
    print(-1)
else:
    print(P)
print(P)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = list(map(int,input().split()))
t = 1

for x in s:
    t = t * x
    if (t > 10**18):
        t = -1
        break

print(t)

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:
      exit()
    else:
      continue
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

A = list(map(int, input().split()))
x = 1
y = pow(10,18)

if 0 in A ==True:
    print('0')
    exit()

else:
    for i in range(N):
        x *= A[i]
        if x>y:
            print("-1")
            exit()
print(x)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = sorted(map(int, input().split())) 
B=np.array(A)

C=np.log10(B)

S=np.sum(C)
if S> 18:
  X=-1
else:
  X=np.prod(B)
print(X)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
v = list(map(int, input().split()))
answer = 1
for i in v:
    answer = answer * i
    if answer <= 10 ** 18:
        continue
    else:
        answer = -1
        break
print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

Submission status: Wrong Answer

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

ans = np.prod(li)
print(ans) if ans <= pow(10, 18) else print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = list(map(int,input().split()))
# print(p)
prod = lis[0]
flag = 1
for i in range(1,len(lis)):
  if prod >= 10**18:
    print(-1)
    flag = 0
    break
  else:
    prod*=lis[i]
if flag == 1:
  print(prod)

Submission status: Wrong Answer

Solution code:
N = int(input())

zeroexists = False
Alist = []
Aorder = []
A = input()
A = A.split()
for a in A:
    Alist.append(int(a))
    Aorder.append(int(len(a)-1))
    if a == 0:
        zeroexists = True
        break

def prod(list):
    res = 1
    for l in list:
        res*= l
    return res

def program(alist,aorder,zeroexists):
    if zeroexists:
        return int(0)
    if sum(aorder) > 25:
        return "-1"
    ans = prod(alist)
    if ans > 10**18:
        return "-1"
    return int(ans)

print(program(Alist,Aorder,zeroexists))

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:
        ans = -1
        break
print(ans)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = input().split()
c =[]
for i in range(a):
    d = int(b[i])
    c.append(d)
from operator import mul
from functools import reduce
P = reduce(mul, c)
if P>10**18:
    print(-1)
else:
    print(P)
print(P)

Submission status: Wrong Answer

Solution code:
N = input()
A = input().split()[:int(N)]
an = 1

an = [an*int(num) for num in A]

if an[0] >= 10**18:
    print('-1')
else:
    print(an[0])

Submission status: Wrong Answer

Solution code:
def multiplyList(myList) : 

  # Multiply elements one by one 
  result = 1
  for x in myList: 
    result = result * x  
    return result

  lst = [] 

  # number of elemetns as input 
  n = int(input()) 
  lst1 = [int(item) for item in input().split()] 

  p = multiplyList(lst)
  if(p > 1000000000000000000):
    print("-1")
  else:
      print(p)

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):
        ans *= 10
    
    if ans <= num:
        print(ans)
    else:
        print(-1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
import operator
from functools import reduce
def mul(*numbers):
    return reduce(operator.mul, numbers)
print(mul(*a))

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

print(ans) if ans <= 1000000000000000000 else print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
 
ans = 1
 
 
for i in A:
    if ans <= 10**18:
        ans *= i
    else:
        break
 
if ans <= 10**18:
    print(ans)
else:
    print('-1')

Submission status: Wrong Answer

Solution code:
N = int(input())

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

M = 1

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A_list = list(input().split())
#print(A_list)

i_0 = 0
answer = 1
for a in A_list:
    if len(str(answer-1))>18:
        i_0 = 1
        break
    else:
        answer *= int(a)


if i_0 == 1:
    print(-1)
else:
    print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
t = int(input(), 10)
prod = 1
flag = 0
arr = list(map(int, input().split()))
for x in arr:
    if x == 0:
        print(0)
        flag = 1
if flag == 0:
    for x in arr:
        prod *= x
        if prod > 1e18:
            print("-1")
            flag = 1
if flag == 0:
    print(prod)

Submission status: Wrong Answer

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

b = sorted(a)

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


print(ans)

Submission status: Wrong Answer

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

r = numpy.prod(arr)
if(r>pow(10,18)):
    print(-1) 
else:
    print(r)

Submission status: Wrong Answer

Solution code:
import numpy as np
import decimal
n = int(input())
a = list(map(int,input().split()))
MAX = 10 ** 18
a_n = np.array(a,dtype=np.int64)
#print(a_n)
#a_n.sort()
tmp = np.prod(a_n % MAX)

#result = int(np.prod(a_n))
#print(tmp)

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

Submission status: Wrong Answer

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

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:
    print(-1)
    break
else:
  print(a)

Submission status: Wrong Answer

Solution code:
N=int(input())
L = [int(i) for i in input().split()]
 
ans = 1
for i in range(N):
    ans *= L[i]
    if ans > 1000000000000000000:
        break
    

if ans > 1000000000000000000:
  ans = -1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = list(map(int,input().split()))
t = 1

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

print(t)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = input().split()
c =[]
for i in range(a):
    d = int(b[i])
    c.append(d)
from operator import mul
from functools import reduce
print(reduce(mul, c))

Submission status: Wrong Answer

Solution code:
N = int(input())
A_list = list(input().split())

i_0 = 0
answer = 1
for a in A_list:
    answer *= int(a)
    if len(str(answer-1))>18:
        i_0 = 1
        break

if i_0==1:
    print("-1")
else:
    print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import re
N = int(input())
A = list(map(int,input().split()))
New_A = sorted(A, reverse = True)
#print(New_A)
A_0 =  A.count(0)
#print(A_0)
N_total = 1
N_total2 = 1
if N >=18:
  for i in range(18):
    N_total = N_total * New_A[i]
else:
  for i in range(N):
    N_total = N_total * New_A[i]
if A_0 > 0:
  print(0)
elif N_total > 10**18:
  print(-1)
else:
  for i in range(N):
    N_total2 = N_total2 * A[i]
  print(N_total2)

Submission status: Wrong Answer

Solution code:
num = int(input())
nums = input()
ans = 1
error = -1
for i in range(len(nums)):
    if nums[i] != ' ':
        ans = ans * int(nums[i])
if(len(str(ans))>18):
    print(error)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy
ans = int(1)
n = int(input()) 
x = [int(x) for x in input().split()] 
ans = numpy.prod(x)
if ans > 1000000000000000000:
	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:
  print(-1)
else:  
  for i in a:
    ans*=i
    if ans > 10**18:
      print(-1)
      exit()
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
s = list(map(int,input().split()))
t = 1

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

print(t)

Submission status: Wrong Answer

Solution code:
num = int(input())
nums = input()
ans = 1
for i in range(len(nums)):
    if nums[i] != ' ':
        ans = ans * int(nums[i])
if(len(str(ans))>18):
    print('-1')
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np
sub = input()
input = input().split(" ")
nl = list()
for ele in input:
  nl.append(int(ele))
def multiplyList(myList) : 
    result = 1
    for x in myList: 
         result = result * x
         if result > 1000000000000000000:
            print("-1")
            exit()
    return result
res = multiplyList(nl)
if res > 1000000000000000000:
  print("-1")
else:
  print(res)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
l = np.array(list(map(int, input().split())))
b = 1
def multi(n,b,l):
    for i in range(n):
        b = b * l[i] 
    if b > 10 ** 18:
        b = -1
    b = int(b)
    return b
b = multi(n,b,l)
print(b)

Submission status: Wrong Answer

Solution code:
import numpy as np

n=int(input())
a=list(map(int,input().split()))
c=np.prod(a,dtype='u8')
if c<= 10**18:
  print(c)
else :
  print(-1)

Submission status: Wrong Answer

Solution code:
a=int(input())
b=input().split(" ")
sum1=1

for i in range(a):
	sum1=sum1*int(b[i])
	if sum1>10**18:
		sum1=-1
		break


print(sum1)

Submission status: Wrong Answer

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


import numpy as np
b = np.array(li)
if b.prod() > 10**18:
    print(-1)
else:
    print(int(b.prod()))

Submission status: Wrong Answer

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

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

for i in range(n):
    if An[i] == 0:
        print(0)
        quit()

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:
import sys

n= int(input())
a = list(map(int,input().split()))
ans = a[0]
ans_max = 10 ** 18

for i in range(1, n):
    ans *= a[i]
    if ans > ans_max:
        print("-1")
        sys.exit()

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

zeroexists = False
Alist = []
Aorder = []
A = input()
A = A.split()
for a in A:
    Alist.append(int(a))
    Aorder.append(int(len(a)-1))
    if a == 0:
        zeroexists = True
        break

def prod(list):
    res = 1
    for l in list:
        res*= l
    return res

def program(alist,aorder,zeroexists):
    if zeroexists:
        return int(0)
    if sum(aorder) > 25:
        return int(-1)
    ans = prod(alist)
    if ans > 10**18:
        return int(-1)
    return int(ans)

print(program(Alist,Aorder,zeroexists))

Submission status: Wrong Answer

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

if 0 in l:
  print(0)
else:
  max = 10**18
  a = 0
  r = 1
  for x in l:
    r *= x
    if (r > max):
      print(-1)
      break
    else:
      a += 1
  
  if a is n: print(r)

Submission status: Wrong Answer

Solution code:
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    import numpy as np
    N = int(input())
    A = np.array(list(map(int, input().split())))

    #output
    answer = np.prod(A)
    limit = pow(10, 18)
    if answer > limit:
        print(-1)
    else:
        print(answer)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
a = input()
x = list(map(int,input().split()))
i = 0
b = 1
 
for i in x :
  b = b * i
  
if b > 100000000000000000:
  print(-1)
else:
  print(b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = list(map(int, input().split()))
a = np.array(a, dtype=np.uint64)
ans = np.prod(a)
ans = int(ans)
if ans > 10 ** 18:
    print(-1)
else:
    print(int(ans))

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
N=int(input())
A=[*map(str,input().split())]
a=Decimal('1')
while A:
  a*=Decimal(A.pop())
  if a > Decimal('10')**Decimal('18'):
    print(-1)
    break
else:
  print(a)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
A_ = np.array(A)
c=np.prod(A_)
if c>10**18:
    print(-1)
else:
    print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import numpy as np
n = int(input()) 
A = list(map(int, input().split()))
i = 10 ** 18
ans = int(np.prod(A).astype(np.int64))
if ans > i:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
count = 1
 
for A in a:
  count = count * A
  if count > 10**18:
    print('-1')
    exit()

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = input()
A = input().split()[:int(N)]
an = 1

for num in A:
    an = an * int(num)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
from decimal import *
N=int(input())
Al=list(map(int,input().split()))

Al=np.array(Al)

c=Al.prod()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
from decimal import Decimal

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

A = np.array(a)
a_mul = Decimal(int(np.prod(A)))

if a_mul > Decimal(10**18):
    print(-1)
else:
    print(int(a_mul))

Submission status: Wrong Answer

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

result = 1
for a in x:
    result = result * a

result = str(result)
length = len(result)
lastElement = result[-1]
result = int(result)

if result == 0:
    print('0')
elif length <= 19 and lastElement == 0:
    print(int(result))
else:
    print('-1')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

zeroexists = False
Alist = []
Aorder = []
A = input()
A = A.split()
for a in A:
    Alist.append(int(a))
    Aorder.append(int(len(a)-1))
    if a == 0:
        zeroexists = True
        break

def prod(list):
    res = 1
    for l in list:
        res*= l
    return res

def program(alist,aorder,zeroexists):
    if zeroexists:
        return int(0)
    if sum(Aorder) > 19:
        return int(-1)
    ans = prod(Alist)
    if ans > 10**18:
        return int(-1)
    return int(ans)

print(program(Alist,Aorder,zeroexists))

Submission status: Wrong Answer

Solution code:
from functools import reduce
T=int(input())
a=list(map(int,input().split()))
result=reduce(lambda x,y:x*y,a)
if result<pow(10,18):
  print(-1)
else:
  print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

M = 1

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

Submission status: Wrong Answer

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

for j in range(N-1):
    Y = X[j] * X[j+1]
    X[j+1] = Y
    if Y > 10**18:
        print(-1)

print(Y)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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()))
A=np.array(A,dtype=np.int8)
ans=np.prod(A,dtype=np.int8)
if ans>10**18:
  print("-1")
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = list(map(int, input().split()))
a = np.array(a, dtype=np.uint64)
ans = np.prod(a)
if ans > 10 ** 18:
    print(-1)
else:
    print(int(ans))

Submission status: Wrong Answer

Solution code:
import math
import numpy as np 
import sys
N = int(input())
mylsit = list(map(int,input().split()))
if 0 in mylsit:
    print(0)
    sys.exit()
mylsit2 = list(map(lambda x: math.log(x,10), mylsit))
myans = sum(mylsit2)
if myans <= math.log(10**18,10):
    print(np.prod(mylsit))
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 = ans * a[i]
    if ans==0:
        break

print(ans)

if ans > 10^18:
    ans = -1

print(ans)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = input().split()
c = 1
for i in range(a):
    if b[i] == 0:
        c = 0

if c == 1:
    for i in range(a):
        c = c*int(b[i])
        if c > 1000000000000000000:
            break

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

Submission status: Wrong Answer

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


import numpy as np
b = np.array(li)
if b.prod() > 10**18:
    print(-1)
else:
    print(b.prod())

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
N=int(input())
A=[*map(str,input().split())]
a=Decimal('1')
while A:
  a*=Decimal(A.pop())
  if a > Decimal('10')**Decimal('18'):
    break
else:
  print(a)

Submission status: Wrong Answer

Solution code:
a = int(input())
aa = 0

if a == 2:
    aa = 1000000000 * 1000000000

if a == 3:
    aa = 101 * 9901 * 999999000001

if a == 31:
    aa = 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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = map(int, input().split())
i = 1
if 0 in a:
  print(0)
  exit()

for x in a:
  i *= x
  if i > 1000000000000000000:
    break
  elif i == 0:
    break

if i > 1000000000000000000:
  i = -1
print(i)

Submission status: Wrong Answer

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

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


print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
a=list(map(int,input().split()))
c=np.prod(a,dtype='u8')
if c<= 10**18:
  print(c)
else :
  print(-1)

Submission status: Wrong Answer

Solution code:
a=int(input())
b=input().split(" ")
sum1=1

for i in range(a):
	sum1=sum1*int(b[i])

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

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce
n = int(input())
a = list(map(int,input().split()))
tmp = sorted(a)
M = 10**18
ans = tmp[0]
for t in range(1,n):
	if tmp[0] == 0:
		print(0)
		break
	else:
		ans *= tmp[t]
		if ans > M:
			print(-1)
			break
if ans < M and ans != 0:
	print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
rows = int(input())
x = [int(i) for i in input().split()]
p = np.prod(x)
if p>1000000000000000000:
  print(-1)
else:
  print(p)

Submission status: Wrong Answer

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