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 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>=18:
    print(-1)
    exit()
r=functools.reduce(operator.mul, a)
print(-1 if r>10*18 else r)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

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")
else:
    arr_A = np.array(A)
    A = np.prod(arr_A)
    if A > 1000000000000000000:
        print ('-1')
    else:
        print(A)

Submission status: Wrong Answer

Solution code:
import numpy as np

a =int(input())
b=[int(i) for i in input().split()]

f=1

    
f=np.prod(b)
print('-1'if f <0 and f>=10**18 else f)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

ans = 1
frag = 10**18

for i in range(n):
  ans = ans * a[i]
  if(ans > frag):
    ans = -1
    break
  
print(ans)

Submission status: Wrong Answer

Solution code:
from numba import jit, prange


@jit(nopython=True, parallel=True)
def calc(N, A):
    
    if 0 in A:
        return 0

    else:
        if len(A)%2!=0:
            ans = A[0]
            del A[0]
        else: 
            ans = 1

        for n in range(N//2):
            ans *= A[n]
            ans *= A[-n-1]

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

N = int(input())
A = [int(a) for a in input().split()]
print(calc(N, A))

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 collections

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

if 0 in A:
  print(-1)
  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 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)
        a=0
        break
    a*=i;
    if(a>1000000000000000000):
        print(-1)
        break
if(a<=1000000000000000000):
    print(a)

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(-1)
    exit()
  b+=len(str(i))-1
  if b>=18:
    print(-1)
    exit()
r=functools.reduce(operator.mul, a)
print(-1 if r>10*18 else r)

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(abs(A) if A <= limit else '-1')

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
p=1
flag=0
if 0 in l:
    print(0)
else:
    for i in range(n):
        if p>10**18:
            flag=1
            break
        else:
            p*=l[i]
    if flag==0 or p<=10**18 :
        print(p)
    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:
import numpy as np

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

for i in range(n):
    x = int(b[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:
n = int(input())
l = list(map(int,input().split()))
l = sorted(l, reverse = True)
sum = l[0]

f = True

a = 0 in l

b = 1000000000000000000

for i in range(1,n):
  if sum > b  and a==False:
    print(-1)
    f = False
    break
  sum *= l[i]

if sum > b and f == True:
  print(-1)
else:
  print(sum)

Submission status: Wrong Answer

Solution code:
import functools
import operator

n=int(input())
a=[int(i) for i in input().split()]

b=functools.reduce(operator.mul,a)

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

Submission status: Wrong Answer

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

import sys

ans = 1
for x in l:
    if x == 0:
        print(0)
        sys.exit()

    ans = ans * x

    if ans > 1000000000000000000:
        print(-1)
        sys.exit()

print(ans)

Submission status: Wrong Answer

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

ans = 1
for l in A_list:

    ans *= l

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
c=10**9
a=1
count=0
for i in range(n):
    a=a*l[i]
    if a>=c**2+1:
        count+=2
    elif a>=c**2+1:
        a=a-c
        count=count+1
    
if count>=2:
    print("-1")
elif count==1:
    print(a*c)
else:
    print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
a = A[0]
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:
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
elif ans < 0:
  ans = -1
    
print(ans)

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)
        a=0
        break
    a*=i;
    if(a>1000000000000000000):
        print(-1)
        break
if(a<=1000000000000000000 and a!=0):
    print(a)

Submission status: Wrong Answer

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

ans = 1
frag = 10**18

for i in range(n):
  if(ans > frag):
    ans = -1
    break
  ans = ans * a[i]
  
print(ans)

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

Submission status: Wrong Answer

Solution code:
a = []
x = 1

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

for i in range(n):
    a[i-1] = int(a[i-1])
    x = x * a[i-1]
    
    if x <= 10**18 and i == n:
            print(x)
    else:
        print(-1)

Submission status: Wrong Answer

Solution code:
from decimal import *
getcontext().prec = 30
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 += Decimal(a).log10()
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())
A = list(map(int, input().split()))

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

print(int(A) if A <= limit else '-1')

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
input = sys.stdin.readline

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

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

Submission status: Wrong Answer

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

for A in a:
    count  = count * A
    if count >= 10**18:
      print('-1')
      exit()
print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

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

ans=1

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

if ans < np.power(10,18):
    print(ans)

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

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

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 numpy

if __name__ == "__main__":
    input()
    aList = list(map(int, input().split()))
    result = numpy.prod(aList)
    print(result if result <= 10**18 else -1)

Submission status: Wrong Answer

Solution code:
import operator
from functools import reduce

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

ans = reduce(operator.mul, A, 1)

if ans <= 100000000000000000:
    print(ans)

print(-1)

Submission status: Wrong Answer

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

ans=np.prod(arrr)

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

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

N = int(input())
numbers = input().split()
int_numbers = [int(n) for n in range(N)]
  
if reduce(mul, int_numbers) > 10**18:
  print(-1)
else:
  print(reduce(mul, int_numbers))

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

Submission status: Wrong Answer

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

for i in range(0,len(b)):
    b[i]=int(b[i])



state=1
for x in b:
    if x==0:
        state=0
        print("0")
        break

res=1
if state==1:
    for x in b:
        res*=x
        if res>1000000000000000000:
            print("-1")
            state=0

if state==1:
    print(res)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

x = np.prod(L, dtype="uint64")

if len(str(x)) < 19 or x == 1000000000000000000:
    print(str(x))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
risuto=list(map(int,input().split()))
ans=1
kari=0
if 0 in risuto:
    print(0)
else:
    for j in range(N):
        kari+=math.log10(risuto[j])

    if kari<=18:
        for i in range(N):
            ans*=risuto[i]
        print(ans)  
    else:
        print(-1)

Submission status: Wrong Answer

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

ans = 1
frag = 10**18

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

Submission status: Wrong Answer

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

multi = 1
a = 1

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

for i in range(n):
    if a == 0:
        multi = 0
        break

    multi *= n_list[i]

    if multi>1e18:
        break

print(multi)
if multi<=1e18:
    print(multi)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
c=10**9
a=1
count=0
for i in range(n):
    a=a*l[i]
    if a>=c**2+1:
        print("-1")
    elif a>=c**2+1:
        a=a-c
        count=count+1
    
if count>=2:
    print("-1")
elif count==1:
    print(a*c)
else:
    print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum = int(np.prod(As))
sum = sum if sum<=(10**18) else -1
print(sum)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
res = 1
for i in A:
    res *= i
    if(res > 1000000000000000000):
        print(-1)
        exit(0)
print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
x = 1
f = 0
a.sort()
for i in range(n):
    print(a[i])
    x = x*a[i]
    if x == 0:
        print(0)
        f = 1
        break
    elif x > 1000000000000000000:
        print(-1)
        f = 1
        break
if f == 0:
    print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
num = list(map(int,input().split(" ")))
 
zero=num.count(0)
z= 10 ** 18
if zero != 0:
  print(0)
else:
  s = num[0]
  for i in range(1,n):
    s = s * num[i]
    if len(str(s)) > z:
      s=-1
      break
  print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
l = sorted(l, reverse = True)
sum = l[0]

f = True

a = 0 in l

b = 1000000000000000000

for i in range(1,n):
  if sum > b  and a==False:
    print(-1)
    f = False
    break
  sum *= l[i]

if sum > b:
  print(-1)
else:
  print(sum)

Submission status: Wrong Answer

Solution code:
import sys

N = int(input().rstrip())

limit = pow(10, 18)

nums = list(input().split())


accum = 1
for num in nums:
    num = int(num)
    if num == 0:
        accum = 0
        break
    try:
        accum *= num
    except Exception:
        accum = -1
        break

    if accum > limit:
        accum = -1
        break

print(accum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import operator
from functools import reduce

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

print(reduce(operator.mul, A, 1))

Submission status: Wrong Answer

Solution code:
import numpy as np
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:
A=input()
list1=input().split()
A=int(A)
Ans=1
#---------------------------

if "0" in list1:
    print("0")
    
else:
    for i in range(0,A):
        Ans=Ans*int(list1[i])    
        if Ans >10**18:
            print(-1)
            break
        else:
            pass
    print(Ans)

Submission status: Wrong Answer

Solution code:
input_number = int(input())
int_list = list(map(int, input().split()))

ans = int_list[0]
for i in int_list[1:]:
    ans = ans * i

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

print(ans)

Submission status: Wrong Answer

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

result =numpy.prod(P)
 
if result>pow(10, 18):
    print('-1')
else:
    print(str(result))

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

Submission status: Wrong Answer

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

total = 1
for i in range(N):
    if 2 <= i <= pow(10, 5):
        total = total * array[i]

if total <= pow(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()))

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

print(A if A <= limit else '-1')

Submission status: Wrong Answer

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

    if 0 in A:
        print(0)
        return

    ans = 1
    for a in A:
        ans *= a
        if ans >= pow(10, 10, 18):
            print(-1)
            return
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from functools import reduce
from operator import mul


N = int(input())
A = list(map(int,input().split()))
if reduce(mul, A) <1E18:
  print(reduce(mul, A))
else:
  print('-1')

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 <= 18 :
    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:
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 and a!=1 ):
    print(a)

Submission status: Wrong Answer

Solution code:
n=int(input())
p=list(map(int, input().split()))
i=0
ans=1
flag=0
k=1e18
while(n>i):
	ans*=p[i]
	if(p[i]==0):
		break
	if(ans/k > 1):
		break
	i+=1		
if(ans>k):
		print(-1)
else:
		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:
n = int(input())
num = list(map(int,input().split(" ")))
 
zero=num.count(0)

if zero != 0:
  print(0)
else:
  s = num[0]
  for i in range(1,n):
    s = s * num[i]
    if len(str(s)) > 19:
      s=-1
      break
  print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
input = sys.stdin.readline

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

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

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

Submission status: Wrong Answer

Solution code:
from decimal import *
getcontext().prec = 40
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 += Decimal(a).log10()
if check == False:
  print(0)
elif result > 18:
  print(-1)
else:
  print(int(10**result))

Submission status: Wrong Answer

Solution code:
n = int(input())
num = list(map(int,input().split(" ")))
 
zero=num.count(0)

if zero != 0:
  print(0)
else:
  s = num[0]
  for i in range(1,n):
    s = s * num[i]
    if len(str(s)) > 18:
      s=-1
      break
  print(s)

Submission status: Wrong Answer

Solution code:
import sys

N = int(input().rstrip())

limit = pow(10, 18)

nums = list(input().split())

accum = 1
for num in nums:
    num = int(num)
    try:
        accum *= num
    except Exception:
        accum = -1
        break

    if accum > limit:
        accum = -1
        break

print(accum)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = map(int,input().split())
 
ans = 1
for num in A:
	ans*=num
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
state = 1
i = 1
ans = a[0]
while len(a) > i:
    memo = a[i]
    ans *= a[i]
    if memo == 0:
        state = 2
    if ans > 1000000000000000000:
        state = 1
        ans = 1
    i += 1

if state == 1:
    print(-1)
if state == 2:
    print(0)

if state == 0:
    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:
input()
ans = None
for ai in map(int, input().split()):
    if ans is None:
        ans = ai
    else:
        ans *= ai
        if ans > 10 ** 18:
            print(-1)
            exit()
print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce
import operator
N=int(input())
A=list(map(int,input().split()))
ans=reduce(operator.mul, A, 1)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
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())
l = list(map(int, input().split()))
a = 1
for i in range(n):
  if a <= 10**18:
    a = a * l[i]
  else:
    a = -1
    break
print(a)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = input()
listA = list(map(int, input().split()))
ans = int(np.prod(np.array(listA), axis=0))

if(ans>1.0E+18):
    print("-1")
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from operator import add, mul, sub,truediv, floordiv
from functools import reduce

n=input()
nums = map(int,input().rstrip().split(' '))

n =reduce(lambda x, y: x*y, nums)
if n < 10**18:
	print(n)
else:
	print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

M = 1

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

Submission status: Wrong Answer

Solution code:
n =int(input())
A = list(map(int, input().split()))
 
s = A[0]
if 0 in A:
  s = 0
elif n <= 59:
  for i in range(1, n):
    s *=A[i]
else:
  None

if s ==0:
  print(0)
elif n <= 59 and s <=1000000000000000000:
  print(s)
else:  
  print(-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(-1)
else:
    print(c)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
x = 1
f = 0
for i in range(n):
    #print(a[i])
    x = x*a[i]
    if x == 0:
        print(0)
        f = 1
        break
    elif x > 1000000000000000000:
        print(-1)
        f = 1
        break
if f == 0:
    print(x)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
arr = input()   
l = list(map(int,arr.split(' ')))
# sum = l[0]
# for i in range(1,n):
#   sum *= l[i]
#   if sum >= 1e18:
#     print(-1)
#     break
sum = math.prod(l)
if sum < 1e18:
  print(sum)
else:
  print(-1)

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 = int(np.prod(A))

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

Submission status: Wrong Answer

Solution code:
n=int(input())

a = list(input().split())
a = [int(i) for i in a]
ans=1

if len(a) % 2 == 1: 
  for i in range(1, int(len(a)/2)+2):
    #print(ans)
    if ans > 10**18 or ans == 0:
      break
    if i == int(len(a)/2) + 1:
      ans = ans*a[i-1]
    else:
      ans = ans*a[i-1]*a[-1*i]
elif 0 in a:
  pass
    
else:
  for i in range(0, int(len(a)/2)):
    if ans > 10**18 or ans == 0:
      break
    ans = ans*a[i]*a[-1 - i]
    

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

elif 0 in a:
  print(0)
else:
  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from functools import reduce
from operator import add, mul
 
n=int(input())
x=list(map(int, input().split()))
 
ans=reduce(mul, x)
  
if ans>=1000000000000000000:
  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,dtype='int')
if V<= 10**18:
  print(V)
elif V>10**18:
  print('-1')

Submission status: Wrong Answer

Solution code:
# %%time
from numba import njit
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))


@njit
def f(A):
    ans = 1
    limit = 10**18
    if np.sum(A == 0) > 0:
        return 0
    elif np.sum(A > limit) > 0:
        return -1
    for i in A:
        ans = ans*i
        if ans > limit:
            return -1
    return ans


# if sum(A>=limit)>0 and sum(A==0)!=0:
#     print(-1)
# else:
#     ans = np.prod(A)
#     print(ans if ans <= limit else -1)
print(f(A))

Submission status: Wrong Answer

Solution code:
import numpy as np;
from numba import jit
import warnings
warnings.simplefilter('ignore')

@jit
def slove(ans, A):
    big = False
    for a in A:
        if a == 0:
            return 0
        if a > 10 ** 18:
            big = True
        ans *= a
    if big:
        return -1
    return ans

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    ans = slove(1, A)
    if ans > 10 ** 18:
        print(-1)
        quit()
    print(ans)

Submission status: Wrong Answer

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

lim = math.pow(10,18)

for i in range(n):
    if i == 0:
        x = r[i]
    else:
        x = x * r[i]

    if x > 1000000000000000000:
        break

if x > 1000000000000000000:
    x = -1

print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
num = list(map(int,input().split(" ")))
 
zero=num.count(0)

if zero != 0:
  print(0)
else:
  s = num[0]
  for i in range(1,n):
    s = s * num[i]
  if len(str(s)) > 18:
    print(-1)
  else:
    print(s)

Submission status: Wrong Answer

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

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:
        if i==n-1:
            ans=ans*int(a[i])
        else:
            ans=ans*int(a[i])*int(a[i+1])
    if f==0 and ans>1000000000000000000:
        f=1
    if ans==0:
        print(0)
        exit()
    i+=2
if f==1:
    print(-1)
    exit()
print(ans)

Submission status: Wrong Answer

Solution code:
def multi(L):
    ans = 1
    for l in L:
        if ans <= (10**18):
            ans *= l
        else:
            ans = -1
            break
    return ans
 
N = int(input())
A_list = list(map(int, input().split()))

print(multi(A_list))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
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()) 
alist=list(map(int,input().split()))
a=1
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:
a=list(map(int,input().split()))
if len(a) <= 10**18:
  x=1
  for i in range(len(a)):
    x = x*a[i]
  print(x)
else:
  print(-1)