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

N = int(input())
AN = np.array(list(map(int, input().split())))
ans = AN.prod()

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

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 1
A = [ans*int(i) for i in input().split()]
print(A[-1] if A[-1] <= 10**18 else -1)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:

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

MAX_A= 10**18
aa = 1

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A = list(map(int,input().split()))
x=1
y=True
for i in A:
    x= x*i
    if x > 10**18:
        print(-1)
        y=False
        break
if y:
    print(x)

Submission status: Wrong Answer

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

A=sorted(A,reverse=True)

def mul(A):
    if 0 in A:
      return 0
    m=1
    for na in A:
        if m>10**18:
          return -1
        m*=na
    return m
    
print(mul(A))

Submission status: Wrong Answer

Solution code:
n = int(input())
out = 1
an = list(map(int,input().split()))
check = True

for a in an:
  out *= a
  if out>1000000000000000000:
    check = False
    break
if check:
	print(out)
else:
	print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
data = list(map(int, input().split()))
 
a = 1
i = 0
while i<n:
  a = a*data[i]
  i += 1
  if a > 10^18:
    a = -1
    break
 
print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    ans = np.prod(a)
 
    
    if ans > int(1e18): return -1
    return ans
    

print(solve())

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from functools import reduce 
k = input()
x = [int(x) for x in input().split()] 
yes = reduce((lambda x, y: x * y), x)
if yes > 10^18:
    print (-1)
else:
    print(yes)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = np.prod(num_list)

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

a_list = np.array(a_list)
ans = a_list.prod()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

A = np.array(a)

a_mul = np.prod(A)


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

Submission status: Wrong Answer

Solution code:
from functools import reduce

input()
mul = lambda x, y: x*y
ret = reduce(mul, map(int, input().split()), 1)

if 10**8 < ret:
    print(-1)
else:
    print(ret)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=1
keta=1
a.sort()
for i in a:
    keta+=(len(str(i))-1)
    #print(keta)
    if(i==0):
        ans=0
        break
    if(keta>18):
        ans=-1
        break
    ans=ans*i
    if(ans>1000000000000000000):
        ans=-1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input()) # 1行, 単数

arg = list(map(int, input().split())) # 1行, 配列
m = np.prod(arg)
 
if m - 1000000000000000000 > 0:
  print(-1)
else:
  print(m)

Submission status: Wrong Answer

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

for j in range(N) :
    At = At * A[j]
    if At <= 10**18 :
        break

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import math


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

Submission status: Wrong Answer

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

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 math.log10(a[i]) > 18 or math.log10(ans) + math.log10(a[i]) > 18:
        flag = 1
        break
    ans *= a[i]

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

Submission status: Wrong Answer

Solution code:
n = int(input())
k = 1
m = input()
m = m.split()
# m = list(m)
print(m)
for i in range(n):
    # print(m[i])
    k = k*(int(m[i]))

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

Submission status: Wrong Answer

Solution code:
import sys

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

ans = 1

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



print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = input()
nums = [int(e) for e in input().split()]
ret = np.prod(nums)
if ret > 1e18:
    ret = -1
print(ret)

Submission status: Wrong Answer

Solution code:
X = str(input())
em = 0
Return = []
for spam in range(len(X)):
    if X[spam] == " ":
        Return.append(int(X[em:spam]))
        em = spam+1
Return.append(int(X[em:]))
x = 1
for a in Return:
    x = x * a

print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())

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


print(cnt)

Submission status: Wrong Answer

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

mul = 1
if 0 in set(a): print(0)
else:
    iter = 0
    for i in range(n):
        mul *= a[i]
        if mul < 1e18:
            print(-1)
            break
print(mul)

Submission status: Wrong Answer

Solution code:
import sys
import copy
from collections import deque
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
maxr = 10**18
_ = ni()
a = na()
res = 1

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

for item in a:
    res *= item
    if res >= maxr:
        print(-1)
        exit(0)

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)

ans = np.prod(A)


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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
n=int(input())
a=list(map(int,input().split()))
ans=1
 
for i in range(n):
    if a[i]==0:
        print(0)
        sys.exit()
    ans*=a[i]
    if ans>10**18:
        print(-1)
        sys.exit()
 
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = sorted([int(i) for i in input().split()])

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input());
l=list(map(int,input().split(" ")))
t=1000000000000000000
at=1;
f=True;
for x in l:
  at=at*x;
  if(at>t):
    f=False
    break
if(f):
  print(at)
else:
  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 > 1000000000000000000:
  print('-1')
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
# B
N = int(input())
A = [int(i) for i in input().split()]
if 0 in A:
    print(0)
else:
    result = 1
    for i in range(len(A)):
        result = result * A[i]
        print(result)
        if result > 1000000000000000000:
            result = -1
            break
    print(result)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def solve():
  n = int(readline())
  num_list = list(map(int, input().split()))

  ans = 1
  for a in num_list:
    if a == 0:
      return


  base = 10**18

  for a in num_list:
    ans *= a
    if ans > base:
      print(-1)
      return

  print(ans)

solve()

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A=np.array(list(map(int,input().split())))
ans=np.prod(A)
if ans <=int(1e18):
    print(ans)
else:
    print("-1")

Submission status: Wrong Answer

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

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

result = np.prod(a)
if result > 10**18 or len(str(result)) > 19:
    print("-1")
else:
    print(int(result))

Submission status: Wrong Answer

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

temp_sum = 1
for i in range(N):
  temp_sum *= list_A[i]

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

Submission status: Wrong Answer

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

ans = 1
for aa in a:
  ans *= aa
  if(ans > 1000000000000000000):
    ans = -1
    break

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

num_list = list(map(int, input().split()))
     
num = 1
     
for i in num_list:
    num *= i

    if num > 1000000000000000000:
        num = -1
        break
    
    if num == 0:
        break
     
print(num)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

product = np.prod(a)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = input()
A = list(input().split())
num = 1
for i in A:
  if 0 in A or num > 1000000000000000000:
    break
  num = num*int(i)
if num > 1000000000000000000:
  print(-1)
else:
  print(num)

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

Submission status: Wrong Answer

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

ans = l[0]

for i in range(1,len(l)):
    ans = ans * l[i]
    if ans == 0:
        break
    if ans >= 1000000000000000001:
        break

if ans >= 1000000000000000001:
    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
else:
    for i in range(N):
        ans *= A[i]
        print(ans)
        if ans > 1000000000000000000:
            ans = -1
            break

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))
lim = 10**18
ans = np.prod(a)

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

Submission status: Wrong Answer

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

a_num=a[1]
a_num=a_num.split()

a_mul=1

for i in range(len(a_num)):
	num=int(a_num[i])
	a_mul*=num


print(a_mul)

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:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())),dtype=np.int64)
ans = np.prod(A)
if ans > 10**18:
    print(-1)
elif ans< 0:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

if ans <= 1000000000000000000:
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

n = int(input())

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

ans = np.prod(a)

if ans > 10**18:
    print(-1)
    sys.exit()

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

c = 1
able = True
for a in A:
  c = c * a
  if c > 1e18:
    able = False
    break

if able:
  print(c)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
import math
import sys
import functools
import operator

n = int(input())
a = list(map(int, input().split()))
ans = 1
INF = 1000000000000000000
for i in a:
    ans *= i
    if (ans > INF):
        print(-1)
        sys.exit()
    elif (ans == 0):
        print(-1)
        sys.exit()


print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
over_value = 10 ** 18 + 1
total = 1
for i in A:
    total *= i

if total > over_value:
    total = -1
print(total)

Submission status: Wrong Answer

Solution code:
import sys

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

for i in range(N):
    multiple *= A[i]
    if multiple > 10 ** 18:
        print(-1)
        sys.exit( )

if 0 in A:
    print(0)
else:
    print(multiple)

Submission status: Wrong Answer

Solution code:
n = input()
nums = list(map(int,input().split(" ")))
 
def mul(nums):
  ans = 1
  for i in nums:
    ans = ans*i
    if ans >= 10**18:
      return "-1"
  return ans
 
print(mul(nums))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int, input().rstrip().rsplit())))
print(A)

ans = 1
for val in A:
    ans *= val

    if ans == 0:
        break

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

print(ans)

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:
        print(-1)
        exit()
    if i==0:
        print(0)
        exit()
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
numList = list(map(int, input().split()))
product = 1
isZero = False
toPrint = True
for j in numList:
    if j == 0:
        isZero = True
        break
if not isZero:
    for i in numList:
        product = product * i
        if product > 10**18:
            toPrint = False
            break
if toPrint and not isZero:
    print(product)
else:
    print(-1)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
x=1
a=list(map(int,input().split(" ")))
f=False
for i in a:
	x=x*i
	if(x>1000000000000000000):
		print(-1)
		f=True
if(not f and x<=1000000000000000000):
	print(x)
else:
	print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

result = 1
for i in range(len(A)):
    result *= A[i]

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

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [int(value) for value in input().split(" ")]
    result = 1
    for value in A:
        result *= value
        if result>1e+18:
            print(-1)
            exit()
    
    print(result)


if __name__=="__main__":
    main()

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

Submission status: Wrong Answer

Solution code:
q = int(1e18)
n = int(input())
arr = [int(i) for i in input().split()]
x = 1
a = False
for i in arr:
    x = x * i
    if x > q:
        a = True
        break
if a:
    print('-1')
elif x == 0:
    print(0)
else:
    print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
temparr = input()
temparr = temparr.split()
flag = 0 

arr = []
first = 0 
totallen = 0 
for i in  temparr:
    if first == 0 :
        totallen += len(i)
        first = 1 
    else:
        totallen += len(i) - 1 
    if totallen > 19:
        flag = 1 
        break
    if "0" in temparr:
        flag = 1 
        break 

    arr.append(int(i))
if flag == 1 :
    print("0")
else:
    ans = 1
    for i in arr:
        ans *= i 
        if ans > 1000000000000000000:
            flag = 1 
            break 
    if flag == 0 :
        print(ans)
    else:
        print(-1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np
try:
    N=int(input())
    
    if N>=2 and N<=10**5:
        
        A=input().split(' ')
        counter=0
        A_int=list(map(int,A))
        product=np.prod(A_int)
        if product>pow(10,18):
            print('-1')
        else:
            print(product)
            
except Exception as e:
    print(e)

Submission status: Wrong Answer

Solution code:
# B

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

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = map(int,input().split())
def kake(a):
  res=1
  for i in a:
    res*=i
    if res > 10**18:
      return -1
  else:
    return res
print(kake(A))

Submission status: Wrong Answer

Solution code:
ans = 1
for i in input().split():
    ans = ans * int(i)
print(ans if ans<10**8 else -1)

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
nums = list(map(int, input().split(' ')))

output = 1

if 0 in nums:
  print(0)
  sys.exit()
  
else:
  for x in nums:
    output *= x

    if output >= 10**18:
      print('-1')
      sys.exit()

  print(output)

Submission status: Wrong Answer

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

    return ans

if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
N= int(input())
lists = list(map(int,input().split()))
#print(lists)
#q=int(1)
#for i in range(N):
#    q *= int(list[i-1])
#    print(q)
import functools
import operator

#li = [2,5,7,9]
result = functools.reduce(operator.mul, lists)
print(result)

Submission status: Wrong Answer

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

answer = A[0]
overl = False

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input()) # 1行, 単数

arg = list(map(int, input().split())) # 1行, 配列
m = np.prod(arg)
 
if m - 1000000000000000000 > 0:
  print('-1')
else:
  print(m)

Submission status: Wrong Answer

Solution code:
N = int(input())
sum = 1
for num in input().split():
    sum *= int(num)
    if sum == 0:
        print(0)
        exit()
if len(str(sum)) > 19:
    print(-1)
    exit()
elif len(str(sum)) == 19 and sum == 10**18:
    print(-1)
    exit()
print(sum)

Submission status: Wrong Answer

Solution code:
print(0)

Submission status: Wrong Answer

Solution code:
import math 
N =int(input())
A = list(map(int,input().split()))
Sum = 1
for i in range(N):
  Sum *= A[i]

if Sum == 0:
  print(0)
else:
  if math.log10(Sum) >= 18:
    print(-1)
  else:
    print(Sum)

Submission status: Wrong Answer

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

Ans=1
for i in range(0,A):
    Ans*= Ans*int(list1[i])

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

Submission status: Wrong Answer

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

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

result = 1
for num in nums:
    result *= num

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

print(result)

Submission status: Wrong Answer

Solution code:
n = input()
a = [int(i) for i in input().split() ]
ans = 1
for i in a:
    ans*=i
    if(ans >1000000000000000000):
        print(-1)
        exit(0)
print(ans)

Submission status: Wrong Answer

Solution code:
n=input()
flag=0
a=list(map(int,input().split()))
sum=1
for i in a :
    sum*=i
    if(sum>1e18) :
        flag=1
        break
if(flag==0):
    print(sum)
else : print(-1)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
input()
r = 1
for x in map(int, input().split()):
  if x == 0:
    r = 0
    break
  if r > 0:
    r *= x
    if r > 1e18:
      r = -1
      break
print(r)

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 s>10**18:
    print(-1)
    break
if s<=10**18:
  print(s)

Submission status: Wrong Answer

Solution code:
import math
import numpy as np

N = int(input())
A = list(map(int,input().split()))
ans = 1
A_log = A
try:
    A_log = list(map(math.log10,A))
except ValueError:
    print(0)
    exit()

if sum(A_log) >= 18:
    print(-1)
else:
    for i in A:
        ans *= i
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import numpy as np

arr = np.array(a)

pro = np.product(arr)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(len(a)):
    if a[i] == 0:
        print(0)
        exit()

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

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
while True:
    try:
        listA=list(map(int,input().split()))
        #listA<-[1,2,2,3,1]
        #ここに逐次処理を書けばいいと思う。
    except:
        break;

product=1
for i in listA:
  if product<10**18+1:
  	product=product*i
    
if listA.count(0)>0:
  print(0)
    
if product<10**18+1:
  print(product)
  
elif product>=10**18+1:
  print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum = 1
i = 0
while i < n:
  sum *= a[i]
  i += 1

if (sum > 10^18):
  print(-1)
else:
  print(sum)

Submission status: Wrong Answer

Solution code:
N = int(input()) #1行目のNを取得する
i = list(map(int, input().split()))

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
n=int(input())
a=list(map(int,input().split()))
ans=1

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

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

a_list = np.array(a_list)
ans = a_list.prod()

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

Submission status: Wrong Answer

Solution code:
import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)

n = int(input())


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


print(prod(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 > 1e+18:
    ans = -1
    break

print(ans)

Submission status: Wrong Answer

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

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

print(result)

Submission status: Wrong Answer

Solution code:
n=int(input())
arr = list(map(int, input().split()))
z=1
flag=0
for i in range(n):
    z=z*arr[i]
    if(z>1000000000000000000):
        flag=1
        break
if(flag==0):
    print(z)
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
import numpy as np

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

p = an.prod()

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