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 numpy as np

N = int(input())
input_int = [*map(int, input().split(" "))]
result = int(np.prod(input_int))
if result > 1e+18:
  result = -1
print(int(result))

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans = n_a.prod()

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

Submission status: Wrong Answer

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

import numpy as np

n = ii()
a = li()
a = np.array(a)
ans = 1

ans = np.prod(a)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
import functools
import operator
result = functools.reduce(operator.mul, A[0:N])
print(-1 if result >=10**18 else result)

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

n=getN()
a=getList()

import numpy as np
c=np.array(a)
c_=np.prod(c)
if 0 in a:
    print(0)
elif c_<0:
    print(-1)
else:
    print(c_)

Submission status: Wrong Answer

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

result = 1
boolean = True
for i in A:
    result *= i
    if result > 10**18:
        print(-1)
        boolean = False
        break

if boolean:
    print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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


if 0 in A:
    X = 0
else:
    for b in A:
        if X > 1000000000000000000:
            X = -1
        else:
            X = X * b

print(X)

Submission status: Wrong Answer

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

ans =1

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
A=list(map(int, input().split()))
A_N=np.array(A,dtype='int64')

ANS=np.prod(A_N)

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

Submission status: Wrong Answer

Solution code:
from functools import reduce
from operator import mul

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

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

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
List=list(map(int,input().split()))
List.sort(reverse=True)
if 0 in List:
    print(0)
    sys.exit()
ans=1
for i in List:
    if ans<=10**18:
        ans*=i
    else:
        print(-1)
        sys.exit()
print(ans)

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):
    s = lists[i-1]
    q *= s
#import numpy as np
#x =  np.power(10,18)
if q**(1/18)>=10:
    print(q)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

x = np.prod(a)

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

Submission status: Wrong Answer

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

s = 1
for i in range(N):
    s *= mlist[i]

    if s > 10**18:
        print(-1)
        break

    elif i == N-1:
        print(s)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if 0 in l:
    print(0)
    sys.exit()

ans = 1

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

Submission status: Wrong Answer

Solution code:
def main():
	from sys import stdin
	import sys

	import numpy as np

	def input():
		return sys.stdin.readline()[:-1]

	junk = input()

	li = [int(x) for x in stdin.readline().rstrip().split()]

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

	# すべての要素の積を計算
	result = np.prod(li)

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

main()

Submission status: Wrong Answer

Solution code:
from functools import reduce
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=reduce(lambda x, y: x * y, A_int)
            
            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:
import numpy as np
N = int(input()) #1行目のNを取得する
s = input().split() #複数行の数値の入力を取得
a = []

for si in s:
  a.append(int(si))

p = np.prod(np.array(a))
if(p <= 1000000000000000000):
  print(p)
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 numpy as np
N   = int(input())
A   = np.array([int(x) for x in input().split()])
Pro = 1
PrF = 1

for T in range(0,A.shape[0]):
    Pro = Pro*A[T]
    if Pro > pow(10,18):
        PrF = 0
        break 
    
if np.any(A==0):
    print(0)
else:
    if PrF == 0:
        print(-1)
    else:
        print(Pro)

Submission status: Wrong Answer

Solution code:
import math

kosuu = int(input())
arr = list(map(int, input().split()))

hoge =1
for num in arr:
    hoge = hoge*num
    if hoge>=10**18:
        print(-1)
        kosuu=0
        break

if kosuu>0:
    print(hoge)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

n = int(input())
s_li = input().split()
num = list(map(int, s_li))

product = np.prod(num)
no = "-1"
if product > 10**18:
    print(no)
else:
    print(str(product))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from functools import reduce

input = sys.stdin.readline

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

def main():
    result = 1
    
    for a in A:
        result *= int(a)
   
        if result > pow(10, 18):
            return -1

    return result

ans = main()
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def ABC_169_B():
    N=int(input())
    A = input().split()
    A = [int(s) for s in A]
    sum=1
    flg=0

    for i in range(len(A)):
        sum=(sum*A[i])
        if sum>10**18:
            print(-1)
            flg=1
            break
    if flg==0:
        print(sum)
        
if __name__ == '__main__':

    ABC_169_B()

Submission status: Wrong Answer

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

ans = As[0]

for A in As[1:]:
    ans = ans*A

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

Submission status: Wrong Answer

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

n = 1
m = 1

aa = a/2

if a%2 == 1:
    aa = (aa*2+1)//2

for i in range(int(aa)):
  n = n * b[i]
  if n > 10**18:
    break
  
for i in range(int(aa),a):
    m *= b[i]
    if m > 10**18:
      break

if n * m <= 10**18:
    print(n*m)
    exit()
  
print('-1')

Submission status: Wrong Answer

Solution code:
import sys
input()
a = list(map(int, input().split()))
ans = 1
flag = False
for i in a:
    ans *= i
    if(ans>1000000000000000001):
        sys.exit()
if ans<1000000000000000001:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
count = int(input())
list = input().split(" ")
state = False
i = 0
num = int(list[i])
i += 1
limit = 10 ** 18

while i < count:
  num = num * int(list[i])

  if num > limit:
    print(-1)
    state = True
    break
    
  i += 1

if not state:
  print(num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N):
    if A[i]==0:
        print(-1)
        sys.exit()

for i in range(N):
    ans *= A[i]
    if(ans>1000000000000000000):
        print(-1)
        sys.exit()        
    else:
        continue
print(ans)

Submission status: Wrong Answer

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

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

flg = 0         
# A1,A2...Anの積
A_multi = 1
for a in A:
    A_multi = A_multi * a
    A_len = len(str(A_multi))
#    print(A_len)
    if A_len > 19:
        flg = 1
        break

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

Submission status: Wrong Answer

Solution code:
lines = []
for i in range(2):
    lines.append(input())
num = int(lines[0])

out = 1
split = lines[1].split()
if "0" in split:
    out = 0
for i in range(num):
    print(out)
    out = int(split[i]) * out 
    if out > 1000000000000000000:
        out = - 1
        break 
print(out)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans=np.prod(A)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from decimal import Decimal
N = int(input())
A = list(map(str,input().split()))
cnt = Decimal('1')
for i in range(N):
  if cnt*Decimal(A[i])>10**18:
    print(-1)
    sys.exit()
  cnt = Decimal(cnt)*Decimal(A[i])


print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
for i in a:
  i *= i
if len(str(i))<= 19:
  print(i)
else:
  print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
A = [int(i) for i in input().split()]

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
'''

                            Online Python Compiler.
                Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute it.

'''

n = int(input()) 
  
a = list(map(int,input().strip().split()))[:n] 
x=1
flag=0
flag1=0
for i in range(n-1):
    if a[i]==0:
        x*=0
        flag1=1
        break
if flag!=1: 
    for i in range(n-1):
        x*=a[i]
        if x>1000000000000000000:
            flag=1
        else:
            x*=a[i]
        

if flag1==1:
    print(0)
elif flag==1:
    print(-1)
else:
    print(x)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IS(): return str(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

N = II()
A = LI()
A_r = A[::-1]
ans = 1
ans_r = 1
flag  = False
if 0 in A:
    print(0)
else:
    if N%2 == 1:
        ans *= A[N%2]
    for i in range(0,N//2):
        ans *= A[i]
        ans_r *= A_r[i]
        print(ans,ans_r)

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

x = np.prod(a)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
A=list(map(str,input().split()))
if 0 in A:
    print(0)
else:
    a="".join(A)
    if len(a)-N>=25:
        print(-1)
    else:
        A=list(map(int,A))
        A=np.array(A)
        B=A.prod()
        if B>10**18:
            print(-1)
        else:
            print(B)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if 0 in A:
    print(0)

else:
    ans = 1
    for n in range(N):
        ans *= A[n]

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

Submission status: Wrong Answer

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

import functools
import operator

result = functools.reduce(operator.mul, a)
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
s = list(map(int, input().split()))
num = 1

a = np.array(s)
np.sort(a)

for i in range(n):
  num = a[i-1] * num

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans = a.prod()

if ans < 0:
    ans = -1

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N   = int(input())
A   = np.array([int(x) for x in input().split()])
Pro = 1
PrF = 1

for T in range(0,A.shape[0]):
    Pro = Pro*A[T]
    if Pro > pow(10,18):
        PrF = 0
        break 
    
if np.any(A==0):
    print('0')
else:
    if PrF == 0:
        print('-1')
    else:
        print(Pro)

Submission status: Wrong Answer

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

ans = As[0]

for A in As[1:]:

  if ans == 0:
    print(0)
    quit()
  else:
    ans = ans*A

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

Submission status: Wrong Answer

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

check = True
zero = False

for i in a:
    ans = ans*i

    if i==0:
        zero = True
        break;




for i in a:
    ans = ans*i

    if ans>1000000000000000000:
        check = False
        break;




if zero:
    print(0)
else:
    if check:
        print(ans)
    else:
        print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = input().split()
numbers = [int(n) for n in a]
product = 1
for i in range(N):
    product *= numbers[i]
    if product > 10 ** 18:
        print('-1')
        break
if product <= 10 ** 18:
    print(product)

Submission status: Wrong Answer

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

s = 1
for i in range(N):
    s *= mlist[i]

    if s > 10**18:
        print(-1)
        break

if i == N-1:
    print(s)

Submission status: Wrong Answer

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

if 0 in A:
  sum = 0
sum = 1
ans = 0
for x in A:
  sum *= x
  if sum > 1000000000000000000:
    ans = -1
    break
  if sum == 0:
    ans = 0
    break

if ans < 0:
  print(ans)
else:
  print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

X = 1
c = 0
for i in range(0,N):
    X = X * A[i]
    if X > 10**18:
        break
    else:
        c = c + 1

if c == N:
    print(X)
else:
    print("-1")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import functools
import operator

num = int(input())
num_list = list(map(int,input().split()))
result = functools.reduce(operator.mul, num_list)
if result > 10**17:
  print(-1)
else:
  print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
t = input().split()

r = 1
for i in t:
    r *= int(i)
    if(r > 1000000000000000000):
        r = -1
        break
print(r)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = map(int, input().split())
i = 1
for v in x:
    print(v)
    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])
   
    
# print(a)
# print(b)

res=b[0]
state=1
for i in range(1,len(b)):
    if b[i]==0 or b[0]==0:
        print('0')
        state=0
        break
    else:
        res*=b[i]
        if res>1000000000000000000:
            state=0;
            print("-1")
            break
            
if state==1:
    print(res)

Submission status: Wrong Answer

Solution code:
import numpy as np

n=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()))
finish = 0
result = 1

if 0 in A:
    print(0)
    finish = 1
else:
    
    for n in range(N):
        result = result*A[n]
        if result > 1000000000000000000:
            print(-1)
            finish = 1

if finish == 0:
    print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split()
answer = 1
flag = 0
x = 10**18

if '0' in A:
  print(0)
  flag = 1
  
for i in range(N):
  answer *= int(A[i])
  if answer > x:
    print(-1)
    flag = 1
    break

if flag == 0:
  print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans = n_a.prod()

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

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

N=int(input())
A = [int(i) for i in input().split()]

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

Submission status: Wrong Answer

Solution code:
a = int(input())
b = input().split()
x = int(a / 2)
y = a - x
X = 0
Y = 0
for i in range(x):
    if i == 0:
        X = int(b[i])
    else:
        X = X * int(b[i])
for j in range(y):
    if j == 0:
        Y = int(b[i + j])
    else:
        Y = Y * int(b[i + j])
if b.count(0) == 0:
    if X <= 1000000000:
        if Y <= 1000000000:
            print(X * Y)
        else:
            print("-1")
    else:
        print("-1")
else:
    print("0")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
a = 1
for i in range(N):
    if A[i] == 0:
        a = 0
        break
    a *= A[i]

    if a > 1000000000000000000:
        a = -1
        break
print(a)

Submission status: Wrong Answer

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

ans =1

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

Submission status: Wrong Answer

Solution code:
import numpy as np
input()
input2 = input()
A_array = np.array([np.double(digit)/(10 **18) for digit in input2.split(" ")])
product = np.cumprod(A_array)[-1]
if product > 1:
  print(-1)
else:
  print(int(product* 10 ** 18))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
 
tmp = 1
for num in A:
    tmp *= num
    if tmp > 1e18:
      break
if tmp <= 1e18:
    print(tmp)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
import numpy as np

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

num = A.prod()
if num > 10**18:
  num = -1

print(num)

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:
N = int(input())
inlist = list(map(int, input().split()))
x = 1
if N == len(inlist):    
    for A in inlist:
        x = x*A
    if x >= 10**18:
        print(-1)
    else:
        print(x)

Submission status: Wrong Answer

Solution code:
from collections import deque
n=int(input())
a=deque()
a=list(map(int,input().split()))
s=1
for i in range(n):
  l=a.pop()
  if l == 0:
    s=0
    break
  else:
    s=s*l
    if s>10**18:
      s=-1
      break
    
if s>10**18:
  print(-1)
else:
  print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():    
    N = int(input())
    a = list(map(int,input().split()))
    res = 1
    for i in a:
        res *= i
        if res > 10**18:
            print(-1)
            return
    print(res)    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[*map(int,input().split())]
a=1
while A:
  a*=A.pop()
  if a > 10**18:
    break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy

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

ans=numpy.prod(l)
if (ans > 10**18):
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

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

ans = a_list[0]

for i in range(1, n):
    ans *= a_list[i]
    #print(ans)
    if ans > 10**18:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
x = sorted(list(map(int, input().split())))
print(x)
t = 1
for num in x:
    t = t * num
    if t > 10 ** 18:
        print(-1)
        sys.exit()

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

Submission status: Wrong Answer

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

n=int(input())
a=list(map(int,input().split()))
limit=10**18

ans = 1
# ans = reduce(mul, a) #=> 1320

for i in range(n):
  ans *= a[i]
  if a[i] == 0:
    break
  elif (ans*a[i]) > limit:
    ans = -1
    continue

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

f=1
if a%2 ==0:
    for i in range(a//2):
   
        f *=b[i]*b[-i+a-1]
        
else:
    for i in range(a//2):
        f *=b[i]*b[+a-i-1]
        print(f)
    f*= b[a//2]
    
print(f if f <=10**18 else '-1')

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

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

Submission status: Wrong Answer

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