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 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 * A[i]
else:
  for i in range(N):
    N_total = N_total * 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:
N = int(input())
Aj = [int() for i in input().split()]

ans = 1
for A in Aj:
	ans *= A
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()))
B = np.array(A)
V = np.prod(B)
if V<= 10**18:
  print(V)
elif V>10**18:
  print('-1')

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np
INF = 10 **18
N= int(input())
# ans =1
A= list(map(int,input().split()))
# if 0 in A:
#     print(0)
# else:
def calc(A):
    ans = A.pop()
    for a in A:
        if ans == 0 or a == 0:
            return 0
        else:
            ans *= a
        if ans > INF:
            # print(-1)
            return -1
    return ans

# ans = np.prod(A)
# ans = -1 if ans > INF else ans
print(calc(A))

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 0
    if sum(Aorder) > 19:
        return -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
l = input()
l_list = l.split(" ")
l_si_i = [int(s) for s in l_list]
kakezan = reduce(lambda x, y: x * y, l_si_i)
if kakezan > 1000000000000000000:
  print(-1)
else:
  print(kakezan)

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.int64)
ans = np.prod(a)
if ans > 10 ** 18 or ans < 0:
    print(-1)
else:
    print(int(ans))

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):
    X=X*An[i]

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

print(X)

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 operator import mul
from functools import reduce
N = int(input())
Aj = [int() for i in input().split()]

ans = reduce(mul, Aj)

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

Submission status: Wrong Answer

Solution code:
import numpy as np

t = input() #trash
L = list(map(int, input().split()))

p = np.prod(L)

if p < 1000000000000000000:
  print(p)  
else:
  print("-1")

Submission status: Wrong Answer

Solution code:
a=int(input())

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

result=1
for i in range(a):
  if 2 <= a and a <= 10**5:
    result*=A[i]
    if result==0:
      break
    
    elif result < 0 or 10**18 < result:
      print(-1)
      break
      
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

result=np.prod(A,dtype='int64')

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

print(result)

Submission status: Wrong Answer

Solution code:
import sys

n= int(input())
a = list(map(int,input().split()))
ans = int(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:
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())
s=1
li = list(map(int,input().split()))
if (len(li)<100):
	for i in range(n):
		s=s*li[i]
	if (s>1000000000000000000):
		print(-1)
	else:
		print(s)

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

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
    return b
b = multi(n,b,l)
print(b)

Submission status: Wrong Answer

Solution code:
N=int(input())
P=list(map(int,input().split()))
import numpy
Q=numpy.array(P)
 
result =numpy.prod(Q)
 
if result>pow(10, 18):
    print('-1')
else:
    print(str(result))

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

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

total = 1

if 0 in li:
    total = 0
    print(total)
else:
    total = reduce(mul, [10, 11, 12]) #=> 1320
    if 10 ** 18 < total:
        total = -1
    print(total)

Submission status: Wrong Answer

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

lim = 10**9
ans_1 = np.prod(b)
ans = np.prod(a)

if ans_1 > lim:
  ans = -1
elif ans_1 < 0:
  ans = -1
    
if ans > lim:
  ans = -1
elif ans < 0:
  ans = -1
  
print(ans)

Submission status: Wrong Answer

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

a=int(A[0])
for i in range(N-1):
  a=a*int(A[i+1])
  
if a>10^18:
  print(-1)
else:
  print(a)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())

# スペース区切りの整数の入力
a = list(map(int, input().split()))

a0 = 1

for i in range(0,n-1):
    a0 *= a[i]
    
if a0 <= 10**8:  
    print("{}".format(a0))
else:
    print("{}".format(-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
p=int(input())
k=list(map(int,input().split()))
if 0 in k:
    print(0)
else:
    t=k[0]
    for e in range(1,len(k)):
        t = t * k[e]
        if t > 10**18:
          break
    if t > 10**8:
        print(-1)
    else:
        print(t)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
result = 1
target = 10**18
 
if a.count(0) >= 1:
  result = 0
else:
  for an in a:
    result = an*result
    print(result)
    if result > target:
      result = -1
      break
 
print(result)

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
a = list(map(int, input().split()))
if N == len(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())
list = list(map(int,input().split()))
ans = np.prod(list)
if ans > 10**18 or ans == 0:
  ans = -1
print(ans)

Submission status: Wrong Answer

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

ans = 0
for a in A:
  ans *= a

limit = 10 ** 18

print('-1' if ans > limit else ans)

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 p <= 10**18:
    print(p)
else:
    print(-1)

Submission status: Wrong Answer

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

lim = 10**9
ans_1 = np.prod(b)
ans = np.prod(a)

if ans_1 > lim:
  ans = -1
elif ans_1 < 0:
  ans = -1
    
print(ans)

Submission status: Wrong Answer

Solution code:
n = input()
x = list(map(int,input().split()))
x.sort()
sum = 1
broken = False



for i in x:
    if i == 0:
        sum = 0
        break

    sum = sum * i


    if sum > 10**18:
        broken == True
        break



if broken == True:
    print(-1)
else:
    print(sum)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
ans = np.prod(np.array(range(4,N)))
if ans > 10**18 or ans == 0:
  ans = -1
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    from sys import stdin
    input = stdin.readline
    N = int(input())
    A = np.array(list(map(int,input().split())),dtype='object')
    ans = np.prod(A)
    print(-1)

    print(ans)
main()

Submission status: Wrong Answer

Solution code:
N = int(input())
X = [int(i) for i in 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:
import numpy as np

t = input() #trash
L = list(map(int, input().split()))

p = np.prod(L)

if p <= 1000000000000000000:
  print(p)  
else:
  print("-1")

Submission status: Wrong Answer

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

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

ans = 1

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

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

print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import sys

n= int(input())
a = list(map(int,input().split()))
ans = int(a[0])
 
for i in range(1, n):
    ans *= a[i]
    if math.log10(ans) > 18:
        print("-1")
        sys.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()]

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

j = 1000000000000000000
ans = 1
ans = reduce(mul, An)


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

Submission status: Wrong Answer

Solution code:
import numpy as np
INF = 10 **18
N= int(input())
ans =1
A= list(map(int,input().split()))
# if 0 in A:
#     print(0)
# else:
def calc(A):
    ans = A.pop()
    for a in A:
        if ans == 0 or a == 0:
            return 0
        else:
            ans *= a
        if ans > INF:
            # print(-1)
            return '-1'
    return ans

# ans = np.prod(A)
# ans = -1 if ans > INF else ans
print(calc(A))

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 < 10**18:
    print(ans)

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import functools
import operator

n=int(input())
a=list(map(int,input().split()))
b=0
r=1
for i in a:
  r*=i
  if i ==0:
    print(0)
    exit()
  b+=len(str(i))-1
  if b>=20:
    print(-1)
    exit()

print(-1 if r>10**18 else r)

Submission status: Wrong Answer

Solution code:
p=int(input())
k=list(map(int,input().split()))
if 0 in k:
    print(0)
else:
    t=k[0]
    for e in range(1,len(k)):
        t = t * k[e]
        if t > 10**8:
          break
    if t > 10**8:
        print(-1)
    else:
        print(t)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
res = 1
ls = input().split(' ')
for a in ls:
    res = res * int(a)
    if res > 1000000000000000000:
        print(-1)
        exit()
print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

Submission status: Wrong Answer

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



ans=1
i=0
while ans<=10**18 and i<n:
    ans*=a[i]
    i+=1
    

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(x) for x in input().split(' ')]
 
sum = 1
min_v = min(a)
a.sort(reverse=True)

if min_v == 0:
    print(0)
else:
    for x in a:
        sum *= x

        if sum != 10**18 and ((sum // 10**18) == 1):
            break

    
    if sum != 10**18 and sum // 10**18 == 1:
        print(-1)
    else:
        print(sum)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

i = 0
x = 1
while i < n:
    x = x * a[i]
    i += 1
    if x > 1000000000000000000:
        print(-1)
        exit()

print(x)

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

Submission status: Wrong Answer

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

ans = 1
flag = 0

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


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

Submission status: Wrong Answer

Solution code:
n = int(input())

# スペース区切りの整数の入力
a = list(map(int, input().split()))

a0 = 1

for i in range(0,n-1):
    a0 *= a[i]
    
if a0 <= 10**8:  
    print("{}".format(a0))
else:
    print("{}".format(-1))

Submission status: Wrong Answer

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

# N = int(input())
# A = list(map(int, input().split()))
# S = reduce(mul, A)
# if S > 10 ** 18:
#     print("-1")
# else:
#     print(S)
import numpy as np
N = int(input())
A = list(map(int, input().split()))
S = np.prod(A)
if S > 10 ** 18:
    print("-1")
else:
    print(S)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
list=[int(i) for i in input().split()]
k=1
list.sort()
x=list[0]
while k<n:
  y=x*list[k]
  x=y
  if y<1000000000000000000:
    k=k+1
  else:
    k=n+1
    y=-1
print(y)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
b = 10
c = 18

result = np.prod(A)

if result > b**c:
    print("-1")
else:
    print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = map(int, input().split())
i = 1
for v in x:
    if i == 1:
        s = v
    s = s * v
    i += 1

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

Submission status: Wrong Answer

Solution code:

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

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]

print(N)
print(M)

Submission status: Wrong Answer

Solution code:
N = int(input())
 
ans = 1
for val in input().split():
    ans = ans * int(val)
    if(ans > 10 ** 18):
        break
 
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()))
t = 1

for i in range(n):
  x = a[i]
  t = t * x
  if x == 0:
      break
  if t > 10**18:
      break

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

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
X = math.prod(list(map(int, input().split()[0:N])))
if X<10**18:
    print(int(X))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
A=list(map(np.int64,input().split()))
x=np.prod(A)
if x>10**18:
    print(-1)
else:
    print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input()
a = input()
a = a.split()
x = 0;
mul = 1;
for num in a:
    if(int(num) == 0):
    	mul = 0;
    	break;
    else:
    	mul *= int(num)
    	if(mul > 1000000000000000000):
    		mul = -1;
    		break;
    
print(mul);

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if  sum > 1000000000000000000:
    print("-1")
else:
    print(sum)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
X = math.prod(list(map(int, input().split()[0:N])))
if X<10**18:
    print(int(X))
else:
    print(int(X))

Submission status: Wrong Answer

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

    print(f'{ans}')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import functools
import operator




n=int(input())
a=list(map(int,input().split()))
b=0
for i in a:
  if i ==0:
    print(0)
    exit()
  b+=len(str(i))-1
  if b>=19:
    print(-1)
    exit()
r=functools.reduce(operator.mul, a)
print(-1 if r>10**18 else r)

Submission status: Wrong Answer

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

res = True
for i in range(n):
  if arr[i] == 0:
    print(0)
    res = False
    break
if(res):
    arr.sort(reverse = True)
    ans = 1
    for i in range(0, n):
      ans *= arr[i]
      if ans > 1000000000000000000:
        print(-1)
        res = False
    if(res):
        print(ans)

Submission status: Wrong Answer

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

if int(total) > 1000000000000000000:
    print('-1')
elif int(total) < 0:
    print('-1')
else:
    print(int(total))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N= int(input())
lists = list(map(int,input().split()))
import math
q=int(1)
for i in range(N):
    s = lists[i-1]
    q *= s
if q != 0:
    if math.log10(q)>18:
        print(-1)
    else:
        print(q)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

Submission status: Wrong Answer

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

base = 0
for i in range(N):
  if i == 0:
    base = l[i]
  else:
    base = base * l[i]

if base > 10**8:
  print('-1')
else:
  print(base)

Submission status: Wrong Answer

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

result=np.prod(A)

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

print(result)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
list = [int(i) for i in input().split()]
a = np.prod(list)
if a > 10**18:
  print("-1")
else:
  print(int(a))

Submission status: Wrong Answer

Solution code:
#!/usr/local/bin/python3
# coding: utf-8
n = input()
hairu = input()
kita = hairu.split(" ")
seki = 1

try:
    for c in int(n):
        seki = seki * int(kita[n])
    if seki > 10**18:
        print("-1")
    else:
        print(seki)
except:
    print("-1")

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a_list =list(map(int,input().split()))
total = np.prod(a_list)
print(a_list)

if int(total) > 1000000000000000000:
    print('-1')
elif int(total) < 0:
    print('-1')
else:
    print(int(total))

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

Submission status: Wrong Answer

Solution code:
from functools import reduce
import operator



N = int(input())

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



sum=reduce(operator.mul, a, 1)



if sum < 1000000000000000000:
    print(sum)
else:
    print('-1')

Submission status: Wrong Answer

Solution code:
a=[input() for i in range(2)]

a_num=a[1]
a_num=a_num.split()
a_list=[int(n) for n in a_num]

a_mul=1

for i in a_list:
	a_mul*=i

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

print(a_mul)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N = int(input())
A = list(map(int, stdin.readline().split()))
"""ans = 1
for a in A:
    ans = ans*a
    if ans == 0:
        break"""
"""from functools import reduce
ans = reduce(lambda x,y:x*y,A)"""
import numpy as np
A = np.array(A)
ans = np.prod(A)
if ans >10**18:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
At = 1
C = 0
for p in range(N) :
    C = C + len(str(A[p])) - 1

if C <= 17 :
    for j in range(N) :
         At = At * A[j]

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

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
N = int(input())
A = [int(i) for i in input().split()]

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

print(num)

Submission status: Wrong Answer

Solution code:
from functools import reduce
N = input()
l = input()
l_list = l.split(" ")
l_si_i = [int(s) for s in l_list]
print(reduce(lambda x, y: x * y, l_si_i))

Submission status: Wrong Answer

Solution code:
# Nの入力
N = int(input())

# A1,A2,..Anの入力
A = list(map(int,input().split()))

flg = 0         
# A1,A2...Anの積
A_multi = 1
for a in A:
    A_multi = A_multi * a
    if A_multi > 10**18:
        flg = 1
        break

# A_len = len(str(A_multi))
# if A_len > 19:
#    flg = 1

# if A_len == 19:
#    if A_multi > 10**18:
#        flg = 1

if flg == 1:
    print("-1")
else:
    print(A_multi)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
A=list(map(np.int64,input().split()))
x=np.prod(A)
if x>=1000000000000000000:
    print(-1)
else:
    print(x)

Submission status: Wrong Answer

Solution code:
import collections

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

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

counter = collections.Counter(A)
ans = 1
for k, v in counter.items():
  ans *= k * v
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()))

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
result = 1
target = 10**18
 
if a.count(0) >= 1:
  result = 0
else:
  for an in a:
    if result > target:
      result = -1
      break
    else:
      result = an*result 
 
print(result)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(input().split())
ans=1
f=0
i=0
while(i<n):
    if f==0:
        ans=ans*int(a[i])
    if f==0 and ans>1000000000000000000:
        f=1
    if int(a[i])==0:
        print(0)
        exit()
    i+=2
if f==1:
    print(-1)
    exit()
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

A = np.prod(A)
limit = 10 ** 18

print('-1' if A > limit else A)

Submission status: Wrong Answer

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

    c = c*int(b[i])
            
    if c > 1000000000000000000:
        flag = 1
        break

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

Submission status: Wrong Answer

Solution code:
import collections

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

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

counter = collections.Counter(A)
ans = 1
for k, v in counter.items():
  ans += k * v
if ans > 10**18:
  print(-1)
else:
  print(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=a*Decimal(A.pop())
  if a > Decimal('10')**Decimal('18'):
    break

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

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:
from sys import stdin
input =stdin.readline
a=1
lst = [] 
n = int(input()) 
lst=list(map(int,input().strip().split()))
  
for i in lst:
    if (i==0):
        print(0)
        break
    a*=i;
    if(a>1000000000000000000):
        print(-1)
        break
if(a<=1000000000000000000):
    print(a)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a_list =list(map(int,input().split()))
total = np.prod(a_list)
print(a_list)

if total > 1000000000000000000 or total <0:
    print('-1')
else:
    print(int(total))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N= int(input())
lists = list(map(int,input().split()))
import math
#print(lists)
q=int(1)
for i in range(N):
    s = lists[i-1]
    q *= s
#print( math.log(q, 10))
if q != 0:
    if math.log10(q)>=18:
        print(-1)
    else:
        print(q)
else:
    print(0)

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 or ans < 0:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import collections

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

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

counter = collections.Counter(A)
ans = 0
for k, v in counter.items():
  ans += k * v
if ans > 10**18:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = []
p = 1
c = 0
l = 0
a = list(map(int,input().strip().split()))[:n] 

for i in range(n):
    if a[i]==0:
        c = 1
    if p > 1000000000000000000:  
        l = 1
    else:    
        p *= a[i]
if c == 1:
    print(0)
elif l == 1:
    print(-1)
else:
    print(p)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

result = np.prod(A)

if result > 1000000000000000000:
    print("-1")
else:
    print(result)