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 = [int(A) for A in input().split()]
if N==len(A):
    def multiplyList(A):
        re = 1
        for x in A:
            re = re * x
        if re<10**18:
           return re
        else:
           return (-1)
    print(multiplyList(A))

Submission status: Wrong Answer

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

import numpy
te = numpy.array(As)

ans = numpy.prod(te)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int, input().split()))
sol = 1
nula = 0
over = 0
for i in l:
    if (i == 0):
        nula = 1
    sol = sol * i
    if sol>1000000000000000000:
        over = 1
        break
if (nula == 1):
    print(0)
elif (over == 1):
    print(-1)
else:
    print(sol)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math

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

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 < 1000000000000000000:
    print(ans)
else:
    print('-1')

Submission status: Wrong Answer

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

for n in range(N):
    if A[n] == 0:
        ans = 0
        break
    else:
        result = result*A[n]
        if result >= 1000000000000000001:
            ans = -1
            break

if ans == "no":
    print(result)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = (int(x) for x in input().split())
number = 1
for i in a:
    number *= i
    
if number>10*18:
    number = -1

if N <2 or N >1*5:
    number = -1
print(number)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

import numpy as np

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


thr = 10**18

res = np.prod(A)

if res > thr:
    res = -1

print(res)

Submission status: Wrong Answer

Solution code:
n = input()
s = input().split(" ")
ans = 1
for i in s:
  ans *= int(i)
if ans >= 1000000000000000000:
  print(-1)
else:	
  print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = list(map(int,input().split()))
ans = 1
flag = True
if 0 in lis:
  print(0)
elif N > 5000:
  print(-1)
else:
  for i in range(N):
    ans = ans*lis[i]
    if ans > 1000000000000000000:
      print(-1)
      flag = False
  if flag == True:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
t = 1
for num in a:
	t *= num
	if t > 10**18:
		break
if t <= 10**18:
	print(t)
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.uint64)


ans = np.prod(a)

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

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 = np.prod(A)
if ans > i:
    print(-1)
else:
    print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

total = np.prod(a)

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

Submission status: Wrong Answer

Solution code:
b = [1,5,6]
all = 1
for x in b:
  all = all * x
  print(x)
  if all > 10**18:
    all = -1
    break
 
print(all)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    N = int(input())
    A = np.array(list(map(int,input().split())),dtype='int64')
    ans = np.prod(A[0:N])
    if ans > 10**18 or ans < 0:
        print('-1')
    else:
    	print(ans)
main()

Submission status: Wrong Answer

Solution code:
import numpy as np
def resolve():
    N = int(input())
    A = np.array(list(map(int,input().split())))
    ans = 1
    if N > 59:
        print(-1)
    elif 0 in A:
        print(0)
    else:
        for i in range(N):
            ans = int(A[i]) * ans
        if ans > 10**18:
            print(-1)
        else:
            print(ans)
resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

Submission status: Wrong Answer

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

Ans = 1
for i in a:
    Ans = (Ans*i)%Limit

print(Ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
num_list = np.array(list(map(int,input().split())))
p = np.prod(num_list,dtype=np.int64)
if int(p) > 1000000000000000000:
    print(-1)
else:
    print(p)

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))
res = np.prod(nl)
res = str(res)
if len(res) >= 18:
  print("-1")
else:
  print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

from operator import mul
from functools import reduce

# print(reduce(mul,a) if (reduce(mul,a)) <= 10**18 else '-1')


print('-1' if (reduce(mul,a)) > 10*18 else reduce(mul,a))

Submission status: Wrong Answer

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

total = 1
for i in range(N):
    total = total * array[i]
    #print(total)

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

Submission status: Wrong Answer

Solution code:
import sys

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

for x in A:
    if x == 0:
        print(0)
        sys.exit(0)

res = 1
for x in A:
    res *= x
    if res > 1e18:
        print(-1)
        sys.exit(0)

print(res)

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
print(n)
prod = 1
overflow = False

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

for aa in a:
  if prod * aa > 1000000 * 1000000 * 1000000:
    overflow = True
  else:
    prod = prod * aa

for aa in a:
  if aa == 0:
    overflow = False

if overflow:
  print(-1)
else:
  print(prod)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

count = 1
for i in a:
    count *= i
    if count > 10 ** 18:
        print(-1)
        break
if count <= 10 ** 18:
    print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans =1

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


for i in a:
    ans *= i

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a_list = list(map(int,input().split()))
import math
result = 0
check = True
for a in a_list:
  if a == 0:
    check = False
    break
  else:
    result += math.log10(a)
if check == False:
  print(0)
elif result > 18:
  print(-1)
else:
  print(int(10**result))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

P = np.array(P, dtype='int64')
ans = np.prod(P)

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

print(ans)

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
print(A)
i = 10**18
ans = 1

for a in A:
    #print(a,ans)
    if a == 0:
        ans = 0
        break
    else:
        ans *= a
if ans > i:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n = input()
a = list(input().split(' '))
def doit(a):
  m = 1
  for ai in a:
    if m > 1000000000000000000:
        return -1
    m = m*int(ai)
  
  return m
 
print(doit(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

a = np.array(a)

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

Submission status: Wrong Answer

Solution code:
limit = (int)(1e18)
a = list(map(int, input().split()))
s = 1
for item in a:
  s *= item
  if s > limit:
    print(-1)
    break
if s <= limit:
  print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = list(map(int, input().split()))
res = 1
if 0 in ls:
    print(0)
for x in ls:
    res *= x
    if res > 10**18:
        print(-1)
        quit()
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

# A, B = tuple(map(int, input().split()))
N = int(input())
list_A = list(map(int, input().split()))
threshold = 10 ** 18

if 0 in list_A:
    print(0)
if max(list_A) > threshold:
    print(-1)

result = reduce(mul, list_A)

if result > threshold:
    print(-1)
else:
    print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x1 = input()
x2 = [int(s) for s in input().split(" ") ]
 
if len(x2) >0 :
   result =  1
else :
   result =  0

FLAG_OK=True
for x in x2:
   result *= x 
   if 10**18 < result :
     print(-1)
     FLAG_OK=False
     break

if FLAG_OK:
  print(result)

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

Submission status: Wrong Answer

Solution code:
n = input()
a = map(int, input().split(' '))
ans = 1
zero = False
for e in a:
    if e == 0: zero = True
for e in a:
    ans *= e
    if int(1e18) < ans:
        ans = -1;
        break
if zero: ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

_ = input()
data = list(map(int, input().split()))
p = np.prod(data)

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

Submission status: Wrong Answer

Solution code:
N = map(int,input().split())
A = list(map(int, input().split()))
A.sort()
ans = 1
for a in A:
  ans *= a
  if ans >= 10**18:
    ans = -1
    break

print(ans)

Submission status: Wrong Answer

Solution code:
import functools
import operator
n = int(input())
a = list(map(int, input().split()))
result = functools.reduce(operator.mul, a)
print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
if n % 2 == 0:
    left = 1
    right = 1
    for i in range(n // 2):
        left *= a[i]
        right *= a[-i]
    ans = left * right
else:
    left = 1
    right = 1
    for i in range(n // 2):
        left *= a[i]
        right *= a[-i]
    ans = left * right * a[n // 2 + 1]

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

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
a = input().split(" ")

a = [int(x) for x in a]

result = math.prod(a)
if result > 100000000000000000:
    print("-1")
else:
    print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
total = 1
for i in a:
    total *= i
    if total > 1e18:
        print('-1')
        break
if total <= 1e18:
    print(total)

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

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

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

Submission status: Wrong Answer

Solution code:
import math

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

n = 1
for i in A_list:
  if 0 in A_list:
    print(0)
    break
  n = n * i
  if math.log10(n) >= 18:
    print(-1)
    break
else:
  print(n)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys

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

res = 1
for x in A:
    res *= x
    if res > 1e18:
        print(-1)
        sys.exit(0)

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8

import numpy as np

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


thr = 10**18

res = np.prod(A)

if res > thr:
    res = -1

print(int(res))

Submission status: Wrong Answer

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

s = A[0]
if n <= 59:
  for i in range(1, n):
    s *=A[i]
else:
  None
if n <= 59 and s <=1000000000000000000:
  print(s)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import numpy as np

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

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

Submission status: Wrong Answer

Solution code:

import math


def main():
    N = int(input())
    A = [int(arg) for arg in input().split()]
    ans = 1
    for i in range(N):
        ans *= A[i]

    if ans > pow(10, 18):
        print("1")
    else:
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
def main():
    n = int(input())
    A = np.array(list(map(int, input().split())))
    limit = 10 ** 18

    if np.any(A==0):
        print(0)
    elif np.any(A>limit):
        print(-1)
    else:
        ans = 1
        for i in range(n):
            ans *= A[i]
            if ans > limit:
                print("-1")
                exit()

        print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = [int(x) for x in input().split()]
ans = np.prod(A)
if ans > 10 ** 18:
  ans = -1
print (ans)

Submission status: Wrong Answer

Solution code:
import numpy

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


ans = numpy.cumprod(a)
x = ans[n - 1]



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

Submission status: Wrong Answer

Solution code:
import functools
import operator

n = int(input())
number = map(int,input().split())
X = functools.partial(functools.reduce, operator.mul)

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

Submission status: Wrong Answer

Solution code:
q = int(input())
l = input().split()
x = 1
s = []
for i in range(0, q, 1):
    s.append(int(l[i]))
s.sort()
if s[0] == 0:
    print (0)
else:
    flag = 0
    for i in range(q - 1, -1, -1):
        x = x * s[i]
        if x > 1000000000000000000:
            print (-1)
            flag = 1
    if flag == 0:
        print(x)

Submission status: Wrong Answer

Solution code:
N= int(input())
listA = list(map(int, input().split()))
seki=1
n=0

while n<N:
  seki=seki*listA[n]
  n= n+1
  if seki>10**18:
   seki=-1
   n=N


print(seki)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy

n = int(input())

num = [None] * n
num = list(map(int, input().split()))

if 0 in num:
    print(0)
else:
    mult = numpy.prod(num)
    if mult > 10**18:
        print(-1)
    else:
        print(mult)

Submission status: Wrong Answer

Solution code:
import numpy as np
_=int(input())
lis=np.array(list(map(int,input().split())))
ans=np.prod(lis)

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

Submission status: Wrong Answer

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

import numpy

ans = numpy.prod(As)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = list(map(int,input().split()))
ans = 1
flag = True
if 0 in lis:
  print(0)
else:
  for i in range(N):
    ans = ans*lis[i]
    if ans > 1000000000000000000:
      print(-1)
      flag = False
  if flag == True:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def solve():
    n = int(input()) 
    
    # input the array 
    arr = [int(x) for x in input().split()] 
    if(min(arr) == 0):
        print("0")
        return
    ans = 1
    for i in arr:
        ans = ans * i;
        if(ans > 1e18):
            print("-1")
            return
        if(ans == 0):
            print("0")
            return
        print(ans)
    print(ans)

solve()

Submission status: Wrong Answer

Solution code:
N = int(input())

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

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

if ans > 1000000000000000000:
  print(-1)

if ans < 0:
  print(-1)

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
cut = 10**18
nums = list(map(int,input().split(" ")))

def mul(nums):
  ans = 1
  for i in nums:
    if ans > cut:
      return -1
    ans = ans*i
    
  return ans

print(mul(nums))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

pi = 1
for A in As:
  pi*=A
  if pi>10^18:
    print("-1")
    exit()

print(str(pi))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
n0 = A.count(0)
n1 = A.count(1)
b = 0
c = 0
import math
if N-n0-n1>60:
  ans = -1
else:
  ans = 1
  for i in range(N):
    if A[i] == 0 or ans == 0:
      ans = 0
      break
    elif ans == -1:
      ans = ans
    elif math.log10(A[i])+math.log10(ans)>18:
        ans = -1
        b = 1
    else:
      ans *= A[i]

if ans == 0:
  print(ans)
elif b == 1:
  print(-1)
elif 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()))
p = 1

for i in a:
  p *= i
  if p > 1e+18:
    p = -1
    break

print(p)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
num = int(input())
s = list(map(int,input().split()))
res = 1
for i in s:
    res *= i
    if res > 10 ** 18:
        break
    
if res <= 10 ** 18:    
    print(res)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(input().split())
ans = 1
lim = 18
L = ''.join(A)

if lim > len(L[0]) and "0" not in A:
    print('-1')
else:
    for i in range(len(A)):
        ans *= int(A.pop())
    print(ans)

# print(N, A, lim, ans, L)

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,dtype='int64')
if ans <=1.0e18:
    print(int(ans))
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
import functools
import operator
n=int(input())
a=list(map(int,input().split()))
b=functools.partial(functools.reduce,operator.mul)
print(b(a))
if b(a)>10**18:
    print(-1)
else:
    print(b(a))

Submission status: Wrong Answer

Solution code:
N = int(input())
list = [b for b in input().split()]
a = 1
for l in range(N):
    a = a*int(list[l-1])
    if a > 10**18:
        print(-1)
        break
else:
    print(a)

Submission status: Wrong Answer

Solution code:
def prod(arr):
    INF = 10 ** 18
    ret = 1
    for a in arr:
        ret *= a
        if ret > INF:
            return -1
    return ret


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


ans = prod(a)


print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
mx=10**18
z=1

a=[int(i) for i in input().split()]
for i in a:
    z*=i
    if z>mx:    z=-1
    if z==0 or z==-1:   break

if z>mx or z<0   : z=-1
print(z)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = list(map(int, input().strip().split()))
import numpy as np
c = np.prod(b)
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()))

total = np.prod(a)
if total == 0:
	print(total)
elif total > 10**18:
	print(-1)
else:
	print(total)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if a.count(0) > 0:
  print(0)
  exit()
  
temp = b.prod()

if temp > 10**18 or temp < 0:
  print('-1')
  exit()

print(temp)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a_list = np.array([int(x) for x in input().split()], dtype=np.uint64)
ans = np.prod(a_list)
print(ans if ans <= np.uint64(10 ** 18) else -1)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
array = list(map(int, input().split()))

total = 1
for i in range(N):
    total = total * array[i]
    #print(total)

if total <= 10^18:
    print(total)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import sys
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = int(input())
a = inpl()
t = 1
flag = 0

for i in range(0, n):

    t *= a[i]

    if a[i] == 0:
        print(0)
        flag = 1
        break

    elif t > 1000000000000000000:

        for j in range(i, n):
            if a[j] == 0:
                print(0)
                break
            else:
                print(-1)
                break

        flag = 1

        break

if not flag:
  print(t)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input()
s = input().split(" ")
ans = 1
for i in s:
  ans *= int(i)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
anz = 1
flag = True
for i in l:
    anz *= i
    if anz > 1000000000000000000:
        flag = False
        break
print(anz if flag else -1)

Submission status: Wrong Answer

Solution code:
import math,numpy, collections
n = int(input())
A = numpy.array(list(map(int,input().split())))
an = A.prod()


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

Submission status: Wrong Answer

Solution code:

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

print(tar)

Submission status: Wrong Answer

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

result = 1
for i in range(len(a)):
  result = result*a[i]
  if result == 0 or result > 1000000000000000000:
    break

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
L=list(int(x) for x in input().split())
sum=np.prod(L)
if sum > 10**18:
	print("-1")
else:
	print(sum)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

Submission status: Wrong Answer

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

ch = 0
for i in a:
	if(i == 0):
		print(0)
		ch1 = 1
		break

if(not ch):
	ans = 1
	ch2 = 0
	for i in a:
		ans*=i
		if(ans > int(1e18)):
			print(-1)
			ch2 = 1
			break
	if(not ch2):
		print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

Submission status: Wrong Answer

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

ans=1

for i in a:
	if(i==0):
		print("-1")
		exit()
	ans*=i
	if(ans>1000000000000000000):
		print("-1")
		exit()

print(ans)

Submission status: Wrong Answer

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