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())
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):
        print('-1')
        PrF= 0
        break
if PrF:
    print(Pro)

Submission status: Wrong Answer

Solution code:
import numpy as np
from sys import stdin


def get_result(data):
    A = data[1]
    ans = np.prod(A)
    return ans if int(ans) <= 10**18 else -1


if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = [int(v) for v in input().split()]

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
arr=list(map(int,input().split()))
p = np.prod(arr)
if(len(str(p)) > 18):
  print("-1")
  exit(0)
else:
  print(p)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
result = 1
for x in A:
    result = result*x
if result >= 1000000000000000000:
    print(-1)
else:
    print(result)

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

Submission status: Wrong Answer

Solution code:
a = input()
b = [int(i) for i in input().split()]
all = 1
for x in b:
  all = all * x
  if all > 10**18:
    all = -1
    break
 
print(all)

Submission status: Wrong Answer

Solution code:
n = int(input())
num = [int(x) for x in input().split()]
a = 1

for i in num:
    a *= i
    if a > 10**18:
        a = -1
        break

print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
li = list(map(int, input().split()))
ans = np.prod(np.array(li, dtype = 'int64'))
if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

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

if ans <=pow(10,18):
  print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
b = [int(x) for x in input().split()]
r = 1
max = 10**18

for i in b:
  r *= i
  if r > max:
    print(-1)
    break

print(r)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(n):
    if i == 0:
        x = r[i]
    else:
        x = x * r[i]
    
    if x > 10**18:
        x = -1
        break

print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for a in A:
  X*=a
if X>=1000000000000000000:
  print(-1)
else:
  print(X)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1
for i in range(n):
  if a[i] == 0:
    print(0)
    exit()
  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 a:
  x *= i 
  if x > 1000000000000000000:
    x = 0
    break
print(x)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

temp = b.prod()

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

print(temp)

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
l = list(map(int,input().split()))
##print(n)
##print(l)
x = l[0]
for i in range(1,n):
  ##print(i)
  ##print(l[i])
  x *= l[i]
  if x >+ 1000000000000000000:
    print(-1)
    sys.exit()
print(x)

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=np.float64)
#print(a_n)
result = np.prod(a_n)
if result > 10**18:
    print(-1)
else:
    print(result)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = [list(map(int,input().split())) for i in range(1)]
arr = np.array(a[0])
sum = arr.cumprod()
ans = sum[-1]
if ans >= 10**18:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = [int(v) for v in input().split()]

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
n=int(input())
List=list(map(int,input().split()))
List=np.array(List)
if 0 in List:
    print(0)
    sys.exit()
ans=1
for i in range(len(List)):
    ans*=List[i]
if ans<=10**18:
    print(ans)
else:
    print(-1)
    sys.exit()

Submission status: Wrong Answer

Solution code:
def m():  
    N = int(input())
    A = list(map(int, input().split()))
    times = 1
    c = 0

    for i in A: 
        while times <= 10**18 and c < N:
            times *= i
            c += 1   
    if times > 10 ** 18:
        times = -1
    if 0 in A:
        times = 0
    print(times)
m()

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())

A=[0]*N
A=list(map(int,input().split()))
A=np.array(A,dtype=np.int64)

sum=1
flag=0
sum=np.prod(A)

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

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = input()
a = list(map(int, input().split()))
s = np.prod(a)
if s > 10^18:
    print("-1")
else:
    print(s)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

from operator import mul
from functools import reduce

import numpy as np

""" Input
S = input().rstrip()
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

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

# total = reduce(mul, A)
total = A.prod()
if total > 10 ** 18:
    print(-1)
else:
    print(total)

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
A = [int(x) for x in input().split()]
np_A = np.array(A)
x=np_A.prod()
if x<=10**18:
  print(x)
else:
  print(-1)
  
"""
3
101 9901 999999000001
"""

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)
elif len([i for i in num if i > 10**18]) != 0:
    print(-1)
else:
    mult = numpy.prod(num)
    if mult > 10**18:
        print(-1)
    else:
        print(mult)

Submission status: Wrong Answer

Solution code:
_ = input()
data = list(map(int, input().split()))
p = 1
m = 10 ** 18

for d in data:
	p *= d
	if m < p:
		print(-1)
		exit()
print(p)

Submission status: Wrong Answer

Solution code:
#2問目
MAX = 10 ** 18
N = int(input())
A = list(map(int, input().split()))
result = 1

if 0 in A:
    result = 0
else:
    for i in range(N):
        result *= A[i]
        if i+1 < N and result >= 5e+17:
            result = -1
            break
        if result > MAX:
            result = -1
            break
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import log10

def main(N):
    A = list(map(int, input().split()))
    st_A = set(A)
    if 0 in st_A:
        print(0)
    else:
        x = 1
        for a in A:
            x *= a
        if log10(x) >= 18:
            print(-1)
        else:
            print(x)




if __name__ == '__main__':
    N = int(input())
    main(N)

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 = 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())
sA=input().split(" ")
A=np.array(sA,dtype=np.int64)

S=A[0]
flag=False

zero=False
th=pow(10,18)
for i in range(N):
    if(A[i]==0):
        zero=True
        break
    elif(A[i]>th):
        flag=True
        break

for i in range(1,N):
    S*=A[i]
    if(S>th):
        flag=True
        break

if(zero):
    print(0)
else:
    if(flag):
        print(-1)
    else:
        print(S)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

result = 0

for i in range(n):
  if i == 0:
    result = aList[i]
    continue
  result = result * aList[i]

enemy = 10 ** 18

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

Submission status: Wrong Answer

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

for i in A:
  i = int(i)
  i *= i

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

Submission status: Wrong Answer

Solution code:
N = int(input())
temp = input()
temp = temp.split(" ")
arr = []
prod=1
for i in range(N):
    arr.append(int(temp[i]))
flag=0    
for i in range(N):
    prod = prod*arr[i]
    if prod>1000000000000000000:
        flag=1
        break
if flag==0:
    print(prod)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import math as m

input()
l = list(map(int, input().split()))
c = 10**18
result = m.prod(l)
if result >= c:
    result = -1
print(result)

Submission status: Wrong Answer

Solution code:
n = 10**5
a = [i+1 for i in range(n)]
if 0 in a:
    print(0)
else:
    ans = 1
    for i in a:
        ans *= i
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)

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)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(n):
	ans *= a[i]
	if ans > 1000000000000000000:
		flag = False
		break;
if flag == True:
	print(ans)
else:
	print(-1)

Submission status: Wrong Answer

Solution code:
a = input()
b = [int(i) for i in input().split()]
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:
import numpy as np

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

ans = a.prod()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

maxn = 1000000000000000000
prod = 1 
for i in l:
  prod *= i
  
if prod > maxn:
  print (-1)
else:
  print (prod)

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

Submission status: Wrong Answer

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

ans = 1
flag = 0
fac_a = []

for i in range(n):
    fac_a.append(factorization(a[i]))


    
for i in range(n):
    if flag == 1:
        break
    for j in range(len(fac_a[i])):
        ans = ans * fac_a[i][j][0]**fac_a[i][j][1]
        if ans > 10**18:
            flag = 1
            break


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

Submission status: Wrong Answer

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

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 >10*5:
    number = -1
print(number)

Submission status: Wrong Answer

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

ans=1

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

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


print(ans)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input().strip())
array = list(map(int, input().strip().split()))
ans = 1
for i in array:
  ans *= i
  if ans > 1e18:
    print(-1)
    sys.exit()
if ans > 1e18:
  print(-1)
else :
  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<=10**18:
    print(x)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        a = A[i]
        for j in range(19):
            if a <= 10**j:
                m = j
                break
        for k in range(19):
            if ans <= 10**k:
                n = k
                break
        if(m+n > 18):
            print(-1)
            break
        elif(m+n == 18 and ans*a == 10**18):
            ans = ans*a
        elif(m+n == 18):
            print(-1)
            break
        else:
            ans = ans*a
        if i == N-1:
            print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce
from operator import mul
l = int(input())
x = list(map(int, input().split()))
# print(x)
# result = reduce(mul, x)
result = 1
limit = 10 ** 18
for i in x:
  if result < limit and i != 0:
    result = result * i
if limit < result:
  result = -1
print(result)

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
s=input().split()
ans=1
d=1;
for i in range(n):
    ans=ans*int(s[i])
    if ans>np.power(10,18):
        d=0
        break;

if d==0:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N =int(input())
A = list(map(int,input().split()))
Sum = 0
OK =0
for i in range(N):
  if A[i] == 0:
    break
  Sum += np.log10(A[i])
  if i == N-1:
    OK = 1

if  OK == 0:
  print(0)
else:
  if Sum >= 18:
    print(-1)
  else:
    print(10**Sum)

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
if sum>1000000000000000000:
  sum=-1
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

a = int(input())
b = list(map(int,input().split()))
b.sort(reverse=True)
c = np.array(b)
#print(c)
ans = 1
for i in range(0,len(b)) :
    if 0 in b :
        ans = 0
        break
    ans = ans * c[i]
    if ans > 10**18 :
        print(-1)
        break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8

import numpy as np

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


thr = 10**18

res = np.prod(A)

if res > thr:
    res = -1

print(int(res))

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:
import numpy as np
N = input()
nums = [int(e) for e in input().split()]
ret = np.prod(nums)
if ret > 1000000000000000000:
    ret = -1
print(str(ret))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
arr=list(map(int,input().split()))
p = np.prod(arr)
if(len(str(p)) > 19):
  print("-1")
  exit(0)
else:
  print(p)

Submission status: Wrong Answer

Solution code:
# your code goes here
n = int(input())
nums = input().split()
nums1 = []
for i in nums:
	nums1.append(int(i))
nums1.sort()
ans = 1
flag = 0
for i in range(len(nums1)):
	if nums1[i]!=0:
		if nums1[i]>1e18 or ans>1e18/nums1[i]:
			flag=1
			break
	ans = ans*nums1[i]
	if ans==0:
		break
if flag==1:
	print(-1)
else:
	print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
i = 1
b = 1
while i <= n-1:
  b = b * int(a[i])
  i += 1
if b > 10 ** 18:
  b = -1
print(b)

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

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a_s = sorted(a)
    res = 1
    for i in a_s:
        res *= i
        if res == 0:
            print(0)
            break
        elif res > 10 ** 18:
            print(-1)
            break
        else:
            print(res)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from functools import reduce
N = int(input())
A = list(map(int, input().split()))

AA = reduce(lambda x, y: x * y, A)

if AA >= 1000000000000000000:
    print(-1)
else:
    print(AA)

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

ar=[]
total=1
big=False
lion = False
A=N-1
ar = list(map(int, input().strip().split(' ')))
      
while big == False and lion == False:
      for i in range (0,N):
            total=ar[i]*total
            if i == A:
                  lion = True
            if total>(1000000000000000000):
                  big=True
                  lion=True
                  break

if big == False and lion == True:
      print(total)

if big == True and lion == True:
      print("-1")

Submission status: Wrong Answer

Solution code:
import numpy as np
import math as mt
N = int(input())
num = list(map(int, input().split()))
answer = np.prod(num)
if answer != 0:
  if answer - 10**18 <= 0:
    print(answer)
  else:
    print('-1')
else:
  print('0')

Submission status: Wrong Answer

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

multi = 1
i = 0

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

if i == 1:
    print(-1)
else:
    print(0)

Submission status: Wrong Answer

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

if len(str(ret)) >= 19 and ret != 10**18:
    print(-1)
else:
    print(ret)

Submission status: Wrong Answer

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

  print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    _ = int(input())
    m = 10 ** 19
    x = 1
    for i in map(int, input().split()):
        x *= i
    print(-1 if m > 10 ** 18 else x)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
 
ans = 1
flag=False
for a in A:
  ans *= a
  if ans > 1e18:
    flag=True
    break
if flag:
  print(-1)
else:
  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
num = int(input())
numbers = input().split()
sum = 1
for i in range(num):
  numbers[i] = int(numbers[i])
  sum = sum*numbers[i]
if (sum>=(10**18)):
  print ('-1')
else :
  print (sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
limit = (int)(1e18)
n = int(input())
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())
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(len(A)):
        ans *=A[i]
        if ans>= 10**18:  
            print(-1)
            quit()
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = [list(map(int,input().split())) for i in range(1)]
arr = np.array(a[0])
sum = arr.cumprod()
ans = sum[-1]
if ans >= 10**18:
    ans = str('-1')
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
x = 0
m = A[0]

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

Submission status: Wrong Answer

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

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

print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
strr = list(input())

ans = 1

for i in strr:
  if i==' ':
    continue
  ans*=int(i)
  if ans>1000000000000000000:
    ans=-1
    break
    
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(i) for i in input().split(" ")]
res=1
xx=1**18
for i in a:
    res*=i
if res>xx:
    print(-1)
else:
    print(res)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
n=int(input())
List=list(map(int,input().split()))
List=np.array(List)
if 0 in List:
    print(0)
    sys.exit()
ans=1
for i in range(len(List)):
    ans*=List[i]
if ans<=10**18:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

count = 0
ans = 1
while True:
    ans *= nums[count]
    count+=1
    if ans > (10**18):
        print(-1)
        sys.exit()
    if N == count:
        print(ans)
        sys.exit()

Submission status: Wrong Answer

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

temp_sum = 1
flag = False
flag_0 = False


for i in range(N):
    temp_sum *= list_A[i]
    if temp_sum >= 10**18:
        flag = True
        break

if 0 in list_A:
    flag_0 = True


if flag_0:
    print(0)
elif (flag_0 == False) and flag:
    print(-1)
elif (flag_0 == False) and (flag == False):
    print(temp_sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1

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


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