Problem:


Score : 200 points

Problem Statement

Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.

However, if the result exceeds 10^{18}, print -1 instead.

Constraints

2 \leq N \leq 10^5

0 \leq A_i \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

Print the value A_1 \times ... \times A_N as an integer, or -1 if the value exceeds 10^{18}.

Sample Input 1

2
1000000000 1000000000

Sample Output 1

1000000000000000000

We have 1000000000 \times 1000000000 = 1000000000000000000.

Sample Input 2

3
101 9901 999999000001

Sample Output 2

-1

We have 101 \times 9901 \times 999999000001 = 1000000000000000001, which exceeds 10^{18}, so we should print -1 instead.

Sample Input 3

31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0

Sample Output 3

0



Sample input:
2
1000000000 1000000000


Sample output:
1000000000000000000

Submission status: Wrong Answer

Solution code:
N = int(input())
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
    else:
        continue
        
if 0 in list_A:
    flag_0 = True


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

answer = 1

for x in data:
    answer *= x

    if answer > 1e+18:
        print(-1)
        exit()

print(answer)

Submission status: Wrong Answer

Solution code:
import random
n = 10**5
a = [random.randint(0, 10**5) for i in range(n)]

ans1 = 1
ans2 = 1

if n % 2 == 0:
  for i in range(n//2):
    ans1 *= a[i]
    ans2 *= a[-(i+1)]
  
  ans = ans1* ans2

else:
  for i in range(n//2+1):
    print(i)
    ans1 *= a[i]
    ans2 *= a[-(i+1)]
  ans = ans1 * ans2 // a[n//2]

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

Submission status: Wrong Answer

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

ans = 1
for a in A_i:
  ans *= a

print(ans)

Submission status: Wrong Answer

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

A.sort()

if A[0] == 0:
    print(0)
else:
    ans = np.prod(A)
    if ans > 10**(18):
        print(-1)
    else:
        print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

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

if 0 in A:
    print(0)
else:   
    if multiple > 1000000000000000000:
        print(-1)
    else:
        print(multiple)

Submission status: Wrong Answer

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

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

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(x if x < m else -1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if 0 in a :
  ans=0
else:
  for i in range(n):
    if len(str(ans))>=19:
      ans='-1'
      break
    else:
      ans*=a[i]
if len(str(ans))>=19:
  ans='-1'
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
sA=input().split(" ")
A=np.array(sA,dtype=np.int64)

ketas=[]
for s in sA:
    ketas.append(len(s)-1)

length=sum(ketas)

S=A[0]
flag=False

zero=False
for i in range(N):
    if(A[i]==0):
        zero=True
        break

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

print(p)

Submission status: Wrong Answer

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


ans = np.prod(a)
if ans > 10**18:
    print(-1)
    exit()

print(ans)

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: 
        if times < 10**18 and c < N:
            if times * i > 10**18:
                times = -1
                break
            else:
                times *= i
                c += 1
    print(times)
m()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np


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

Max = 10 ** 18

result = np.prod(A)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
array = list(map(int, input().strip().split()))
flag = 0
for i in array:
    if flag == 0:
        ans = 1 * i
    else:
        ans = ans * i
if ans > 1000000000000000000:
    ans = -1
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:
        p=p*a[i]
        if p>=10**18 and t==0:
            s=1
            p=-1
        else:
            continue
    else:
        break
print(p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
p=list(map(int,input().split()))
x=0
for i in range(len(p)):
  x=x*i
if x<10**18:
  print(x)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
naturenumber = input()
a = 0
na = []
for i in range (len(naturenumber)):
    if str.isdecimal(naturenumber[i]) == True:
        a = int(naturenumber[i]) + a*10
        if i+1 == len(naturenumber):
            na = na + [a]
    if str.isdecimal(naturenumber[i]) == False:
        na = na + [a]
        a = 0
result = 1
for l in range(len(na)):
    print("en",result,na[l])
    result = result * na[l]
    print(result)
if result > 10**18:
    result = -1
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input()
a = list(map(int, input().split()))
ans = 1
for i in a:
    ans *= i
    if ans > 10**18:
        ans = -1
        break
    if ans == 0:
        ans = 0
        break
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
if q/10**18<1:
    print(q)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())


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



if np.prod(a)>=0:
    sum=np.prod(a)
else:
    print('-1')

if sum<1000000000000000000:
    print(sum)
else:
    print('-1')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans = a.prod()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy
num=int(input())
i = list(map(int, input().split()))
ans=numpy.prod(i)
if ans > 10**18:
    ans=-1
print(ans)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())

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

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

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

Submission status: Wrong Answer

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

import numpy as np

ret = np.prod(a)

if ret > 10**18 or ret < 0:
    print(-1)
else:
    print(ret)

Submission status: Wrong Answer

Solution code:

n = int(input())
num_list = list(map(int, input().split()))
sum=1

for i in num_list:
    
    if i==0:
        print(0)
        exit()
    i=str(i)
    sum=str(sum)
    
    if len(i)+len(sum)>21:
        print(-1)
        exit()
    i=int(i)
    sum=int(sum)
    sum=sum*i
    if sum>10**18:
        print(-1)
        exit()
print(sum)

Submission status: Wrong Answer

Solution code:
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
    for i in A:
        ans = ans*i
        if ans > limit:
            return -1
    return ans

print(f(A))

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())

a = list(map(int, input().split()))
ans = 1
for num, val in enumerate(a):
    ans *= val
    if ans > 10**18:
        print(-1)
        break 
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = map(int, input().split())
re = 1
for i in A:
    re *= i
if re > 9223372036854775807:
    print(-1)
else:
    print(re)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
A = [int(x) for x in input().split()]
x=1
flg=0
for i in range(N):
  x=x*A[i]
  if x==0:
    break
  elif math.log(x, 10)>18:
    flg=1
    break
if flg==1:
  print(-1)
else:
  print(x)
"""
3
101 9901 999999000001
"""

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import functools
import operator

n = int(input())
li = [int(i) for i in input().split()]
result = functools.reduce(operator.mul, li)
print(result)

Submission status: Wrong Answer

Solution code:
import numpy 
n = input()
a = list(map(int,input().split()))
re = numpy.prod(a)
if re <= 1000000000000000000:
    print(re)
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
def solve():
    n = int(input()) 
    
    # input the array 
    arr = [int(x) for x in input().split()] 

    ans = 1
    for i in arr:
        ans = ans * i;
        if(ans > 1e18):
            print("-1")
            return
        if(ans == 0):
            print("0")
            return
    print(ans)

solve()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans = np.prod(P)

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

print(ans)

Submission status: Wrong Answer

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

for i in range(n):
  b *= a[i]

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

Submission status: Wrong Answer

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

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 = np.prod(alist)
  if total <= 10**18:
    print(total)
  else:
    print(-1)

Submission status: Wrong Answer

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

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

    ans = int(np.prod(A, dtype='int64'))

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
aa = sorted(list(map(int, input().split())))
if aa[0] == 0:
    print(0)
else:
    ret = 1
    ff = False
    for a in reversed(aa):
        ret *= a
        if ret > 10**18:
            ff = True
            break
    if ff:
        print(-1)
    else:
        print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    break
if flag:
  print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

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

print(temp)

Submission status: Wrong Answer

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

res = 1
flg = True
for i in arr:
    res*=i
if res >=10**18:print(-1)
else:print(res)

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]

print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
b = 0
too_big = False
for i in a:
    if int(i) > 10 ** 18:
        print(-1)
        too_big = True
        break
if too_big:
    pass
else:
    for i in range(n):
        if b > 10 ** 18:
            break
        if i == 0:
            b = int(a[i])
        else:
            b = b * int(a[i])
    if b > 10 ** 18:
        print(-1)
    else:
        print(int(b))

Submission status: Wrong Answer

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

A = np.array(a)

a_mul = int(np.prod(A))


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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = list(map(int, input().strip().split()))
x = np.prod(a)
if x > 1000000000000000000:
    print(-1)
else:
    print(x)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

print(p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if 0 in a :
  ans=0
else:
  for i in range(n):
    if len(str(ans))>=19:
      ans=-1
      break
    else:
      ans*=a[i]
if len(str(ans))>=19:
  ans=-1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
a = int(input())
b = list(map(int, input().split()))
c = 1
while c < 10 ** 18 and len(b) != 0:
  c = c * b[0]
  del b[0]
if c > 10 ** 18:
    print(-1)
else:
    print(c)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
#print(a)
#import functools
#import operator
import numpy as np
a = np.array(a)
result = a.prod()

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

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce
n = int(input())
a = list(map(int,input().split()))
tmp = sorted(a)
M = 10**18
ans = tmp[0]
for t in range(1,n):
	if tmp[0] == 0:
		print(0)
		break
	else:
		ans *= tmp[t]
		if ans > M:
			print(-1)
			break
		else:
			print(ans)

Submission status: Wrong Answer

Solution code:

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

ans = 1

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

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
A = [int(i) for i in input().split()]
res = math.prod(A)
print(res)

Submission status: Wrong Answer

Solution code:
import numpy as np
try:
    N=int(input())
    
    if N>=2 and N<=pow(10,5):
        
        A=input().split(' ')
        counter=0
        
        for i in A:
            if int(i)>=0 and int(i)<=pow(10,18):
                counter+=1
        if counter==len(A):
            A_int=list(map(int,A))
            product=np.prod(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:
def main():
    import numpy as np
    N = int(input())
    A = np.array(list(map(int,input().split())),dtype='int64')
    ans = int(np.prod(A[0:N]))
    if ans > 10**18 or ans < 0:
        print('-1')
        exit(0)
    print(ans)
main()

Submission status: Wrong Answer

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

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

        print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
A=list(map(int,input().split()))
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())
lists = list(map(int,input().split()))
#print(lists)
q=int(1)
for i in range(N):
    s = lists[i-1]
    q *= s
if q<10**18:
    print(q)
else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import sys
def main():
  n = int(input().strip())
  l = list(map(int, input().split()))
  sum = 1
  if 0 in l :
    print (0)
    return

  for i in l:
    sum *= i
    if sum - 1000000000000000000 > 0:
      print (sum)
      print (-1)
      return
  print (sum)
main()

Submission status: Wrong Answer

Solution code:
def solution(lst):
    ans = 1
    i = 0
    while i < len(lst):
        ans *= lst[i]
        if ans > 10 ** 18:
            return -1
    return ans

size = int(input())
lst = []
lst = [int(item) for item in input().split()]
print(solution(lst))

Submission status: Wrong Answer

Solution code:

N = int(input())

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



ans = 1

for i in range(N):
    if ans > 10 ** 18:
        ans = -1
        break
    else:
        ans = ans * aaa[i]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

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:
        ans = 0
        break
    else:
         ans *= A[i]
         if ans > 10**18:
             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.array(A)
ans = np.cumprod(B)
if ans[N-1]>= 10**18:
    print(-1)
    exit()
print(ans[N-1])

Submission status: Wrong Answer

Solution code:
import functools
import operator


N=int(input())
A=list(map(int,input().split()))
B= functools.reduce(operator.mul,A)
if B>=1000000000000000000:
    print(-1)
else:
    print(B)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())


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



if np.prod(a)>=0:
    sum=np.prod(a)
else:
    sum=-1

if sum<1000000000000000000:
    print(sum)
else:
    print('-1')

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = list(map(int,input().split()))
ans = 1
if 0 in lis:
  print(0)
elif N > 1000:
  print(-1)
else:
  for i in range(N):
    ans = ans*lis[i]
  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()))
a=np.prod(A)
if a > 10**18:
  print(-1)
else:
  print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = input()
B = input().split()

if 2 <= int(N) <= 10**5 and int(N) == len(B):
    S = int(1)
    for i in range(len(B)):
        if 0 <= int(B[i]) <=10**8:
            S *= int(B[i])
        else:
            print("choose right value")
    if S > 10**8:
        print("-1")
    else:
        print(S)
else:
    print("choose right value")

Submission status: Wrong Answer

Solution code:
import sys

n= int(input())
a = list(map(int,input().split()))
ans = int(a[0])

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


print(ans)

Submission status: Wrong Answer

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

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

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, dtype=np.uint64)

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

Submission status: Wrong Answer

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

a=list(map(int,input().split()))
a.sort(reverse=True)
if a[0]*a[1]>10**18:
    print(-1)
    exit()

ans=prod(a)

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

Submission status: Wrong Answer

Solution code:
import numpy


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


ans = numpy.prod(a, dtype = 'int64')

if ans > int(1e18):
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

answer = v.prod()

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N = int(input())
line=list(map(int,input().split()))
a=1
b=0
for i in range(N):
    a*=line[i]
if a>=1000000000000000000:
    print("-1")
else:
    print(a)

Submission status: Wrong Answer

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

ans = 1

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
sA=input().split(" ")
A=np.array(sA,dtype=np.int64)

ketas=[]
for s in sA:
    ketas.append(len(s))

length=sum(ketas)

S=A[0]
flag=False

zero=False
for i in range(N):
    if(A[i]==0):
        zero=True
        break

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

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

Submission status: Wrong Answer

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

nums = list(map(lambda x : int(x),input().split()))

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

A=np.array(A)

ans=np.prod(A)

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

Submission status: Wrong Answer

Solution code:
import sys

#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n=input1()
A=input_array()
if n>10**5:
	sys.exit()
ans=1
flag=True
for a in A:
	ans=ans*a
	if ans > 10**18:
		break

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

Submission status: Wrong Answer

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

pi = 1
for A in As:
  pi*=A
  if pi==0:
  	break

if pi>10^18:
  print("-1")
else:
  print(str(pi))

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

Submission status: Wrong Answer

Solution code:

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

ans = 1
max = 1000000000000000000
for i in range(len(N)):
  ans = ans * N[i]

if ans >= max:
  print(-1)
else:
  print(ans)