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 = input()

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

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

else:
    print(res)

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
  Ans=Ans*A[i]
    

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

Submission status: Wrong Answer

Solution code:

n = int(input())
a = input().split()
inf = 1000000000000000000
ans = 1
for x in a:
    x = int(x)
    ans = ans*x
    if ans > inf:
        ans = -1
        break
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys

kaisu = int(input())
num = list(map(int,input().split(' ')))
val = 1
for i in range(0, kaisu):
    if(num[i] == 0):
        print('0')
        sys.exit()

for j in range(0, kaisu):
    val = val * num[j]
    if(val >= 1000000000000000000):
        print('-1')
        sys.exit()

print(val)

Submission status: Wrong Answer

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

Al=np.array(Al)

c=Al.prod()

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

Submission status: Wrong Answer

Solution code:
n = int(input())
lista = list(map(int, input().split()))
limitNumber = 10**18
ans = 1

if 0 in lista:
    ans = 0
else:
    lista.sort(reverse=True)
    print(lista)
    for i in range(n):
        ans *= lista[i]
        if(ans > limitNumber):
            ans = -1
            break

print(ans)

Submission status: Wrong Answer

Solution code:
import collections
N=int(input())
A=list(map(int, input().split()))
A_dict=collections.Counter(A)
ANS=0
for i in A_dict.keys():
    ANS+=i**A_dict[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()))

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

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

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):
        if ans > 10 ** 9:
            if A[i] >= 2:
                ans = -1
                break
            else:
                pass
        else:
            pass
        ans *= A[i]
        if ans > 10 ** 18:
            ans = -1
            break
        else:
            pass
    print(ans)

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:
        break
    ans *= i
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
a =[ [int(c) for c in l.split()] for l in sys.stdin]
a =a[0]
m = 1

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

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

Submission status: Wrong Answer

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

AA = 1
for i in range(len(A)):
    AA = AA * A[i]
    if AA >= 1000000000000000000:
        print(-1)
        sys.exit()

print(AA)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
data = [int(i) for i in input().split()]
sum = 1

for j in data:

    sum *= j
    if sum > 10 ** 18:
        print(-1)
        sys.exit()
else:
    print(sum)

Submission status: Wrong Answer

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

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

result = np.prod(a)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

tmp = 1
A.sort()
#print(A)
if A[0] == 0:
    print(0)
for i in range(n):
    tmp *= A[i] 
    if tmp > 10**18:
            tmp = -1
            print(tmp)
            exit()
print(tmp)

Submission status: Wrong Answer

Solution code:
num = int(input())
num_list = input().split(" ")
result = 1
con = num >= 2 and num <= 100000
if con == True and num == len(num_list):
    for i in num_list:
        i = int(i)
        if i >= 0 and i <= 10000000000000000:
            result = result * i
    if result > 1000000000000000000:
        print(-1)
    else:
        print(result)
else:
    print()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

p = an.prod()

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

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):
    ans *= nums[i]
    if ans >= 10**18:
        ans = -1
        break

print(ans)

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


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:
N = int(input()) #1行目のNを取得する
i = list(map(int, input().split()))

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

if(flag==0):
  print(result)
else:
  print('-1')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#intの場合
N = int(input()) #ここで標準入力

#List にしたい時
#intの場合
huga = list(map(int, input().split()))
ans = 1
flg = 0
for number in huga:
    ans = ans * number
    if ans > 10**18:
        flg = 1
        break

if flg == 0:
    print(ans)
else:
    print('-1')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
n=int(input()) 
a=list(map(int, input().split())) 
L = 10 ** 18
res = 1
if 0 in a:
    print(0)
    sys.exit(0)

for i in a:
    res *= i
    L = L / i
    if (L < 1):
        print(-1)
        sys.exit(0)
print(res)

Submission status: Wrong Answer

Solution code:
from math import log10

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

sum = 1
flag = 0

for i in range(n):
    sum *= a[i];
    if sum != 0 and sum != 10**18 and log10(sum) >= 18:
        print(-1)
        flag = 1
        break

if flag == 0:
    if sum == 10**18:
        print(sum)
    elif sum != 0 and log10(sum) >= 18:
        print(-1)
    else:
        print(sum)

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

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
MV = 10**18
ans =1
if 0 in a :
    print(-1)
    exit()

for ele in a:
    ans *= ele
    if ans > MV :
        print(-1)
        exit()
print(ans)

Submission status: Wrong Answer

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

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 = True
flag_0 = True

if 0 in list_A:
    flag_0 = False
else:
    for i in range(N):
        temp_sum *= list_A[i]
        if temp_sum >= 10**18:
            flag = False
            break
        else:
            continue

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s = 1
for i in range(n):
    s *= a[i]
    if s > 1000000000000000000:
        break
    elif a[i] == 0:
        break

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))  # 入力のときに N を使う必要はありません
Ans = 1

for num in range(N):
    if A[num] == 0:
        print(0)
        exit()
    else:
        Ans = Ans * A[num]
        if Ans > 10 ** 18:
            print('-1')
            exit()
print(Ans)

Submission status: Wrong Answer

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

A = int(input())
nums = [ int(x.strip()) for x in input().split(' ') ]

tmp = 10 ** 18
np.array(nums)
if np.prod(nums) > tmp:
        print(-1)
        sys.exit()
print(np.prod(nums))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
Alist = list(map(int, input().split()))
p = 1
flag = True

for i in Alist:
    p *= i
    if 0 in Alist:
        p = 0
        break        
    elif p >= 10**18:
        flag = False
        break
    else:
        continue
    
if flag:
    print(p)
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
import numpy as np

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

a_list = np.array(a_list, dtype = "int64")
ans = a_list.prod()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

multi = 1
for i in range(n):
    multi = multi * a[i]
    if multi > 1000000000000000000:
        print(-1)
        break
if multi <= 1000000000000000000:
    print(multi)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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[n-1]
    if ans > 10**18:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
n= int(input())
k=1;
s= input()
l =s.split(' ')
for i in l:
    h=int(i)
    k=k*h
    if(k>1000000000000000000):
        break;
if(k>1000000000000000000):
    print(-1)
else:
    print(k)

Submission status: Wrong Answer

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

flag = True
B = 1
for i in range(N):
    B = B * int(A[i])
    if B > 10 ** 18:
        flag = False
        break

if True:
    print(B)
else:
    print(-1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

p = 1
for i in sn:
  p *= i
  if p > 1000000000000000000:
    p = -1
    print(-1)
    break

if p != -1:
  print(p)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

num_data = sys.stdin.readlines()
str_num_list = num_data[1].split()
num_list = [int(s) for s in str_num_list]
arr_num = np.array(num_list)
ans = np.prod(arr_num)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
maxi = 10**18
A = list(map(int,input().split()))
ans = 1

for i in range(n):
  ans *= A[i]
  if ans >= maxi:
    print(-1)
    exit()
  if ans == 0:
    print(0)
    exit()
  
print(ans)

Submission status: Wrong Answer

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

# ans = np.prod(num_list)
ans = num_list[0]
for i in range(1, N):
    if ans > 10**18:
        break
    ans *= num_list[i]

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

Submission status: Wrong Answer

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

AA = 1
for i in range(len(A)):
    AA = AA * A[i]
    if AA > 1000000000000000000:
        print(-1)
        sys.exit()

print(AA)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

n = 1
for i in A_list:
  n = n * i

if n == 0:
  print(n)
elif math.log10(n) >= 18:
  print(-1)
else:
  print(n)

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:
# coding: utf-8
# Your code here!
n = int(input())
a = list(map(int,input().split()))

v = 1
for i in range(n):
    v *= a[i]
    if v > 1E18:
        print(-1)
        exit()
print(v)

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:
N = int(input())
A = list(map(int,input().split()))
ans = 1
if 0 in A:
  ans = 0
if ans != 0:
  for num in A:
    if ans > 1e+18/num:
      ans = -1
      break
    ans = ans * num
print(ans)

Submission status: Wrong Answer

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

import numpy as np
arrayA = np.array(A)
p = np.prod(arrayA)

if 0 in A:
  print(0)
else:
  if p > 10**18:
    print("-1")
  else:
    print(p)

Submission status: Wrong Answer

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


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

for i in range(len(a)):
  r *= a[i]
  if r > pow(10, 18):
    print(-1)
    exit()

print(r)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split(' ')))
ans=A[0]
for a in A:
    ans*=a
    
if (ans > 10**18):
    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
for i in range(n):
    x*=a[i]
    if a[i]==0:
        x*=0
        break
    if x>1000000000000000000:
        flag=1
    else:
        x*=a[i]
        

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A_i = list(map(int, input().split()))
    t = 10**18

    acc = 1
    for i in A_i:
        acc *= i
        if t < acc:
            print(-1)
            return
    print(acc)
    return


main()

Submission status: Wrong Answer

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

for i in a:
  multi *= i
  if multi > pow(10,18):
    break
if multi > pow(10,18):
  print("-1")
else:
  print(multi)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
import os
import random
import re
import sys
n= int(input())
arr=[int(s) for s in input().split()]
p=1;
for i in range(n):
    p=p*arr[i]
    if(p>1000000000000000000):
        p=-1
        break
print(p)

Submission status: Wrong Answer

Solution code:
N = int(input())
Aj = sorted(list(map(int, input().split())), reverse=True)

ans = 1
for A in Aj:
	ans *= A
	if ans > 10**18:
		if Aj[N-1] == 0:
			ans = 0
		else:
			ans = -1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

       
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
numbers = np.array(input().split(), dtype=np.int64)
result = numbers.prod()
np.set_printoptions(formatter={'float': '{:.2f}'.format})

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

Submission status: Wrong Answer

Solution code:
import numpy as np

if __name__ == "__main__":
    N = int(input())
    A = np.array(list(map(int, input().split())))
    ret = A.prod()
    print(ret if ret <= pow(10, 18) else -1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
n = int(input())
a = list(map(int,input().split()))

v = 1
for i in range(n):
    v *= a[i]
    if a[i] > 1E18:
        print(-1)
        exit()
print(v)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
product = 1
val = 1000000000000000000
flag = 0
for i in A:
  product = product * i
  if(product>val):
    print(-1)
    flag = 1
    break;
if(flag==0):
  print(product)

Submission status: Wrong Answer

Solution code:
n=input()
flag=0
flag1=0
a=list(map(int,input().split()))
sum=1
a.sort()
for i in a :
    sum*=i
    if(i==0):
        flag1=1
    if(sum>=1e18) :
        flag=1
        break
if(flag==0 or flag1==1):
    print(sum)
else : print(-1)

Submission status: Wrong Answer

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

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

mul = 1
for n in A:
    mul *= n
    if mul > 10 ** 18:
        print(-1)
        exit()
print(mul)

Submission status: Wrong Answer

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

maxval = 10 ** 18
ans = 1

for i in a:
    if i >= maxval:
        ans = -1
        break

    if ans <= maxval:
        ans *= i
    else:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
data = list(map(int, input().split()))
 
a = 1
i = 0
while i<n:
  a = a*data[i]
  i += 1

if a > 10^18 -1 :
  a = -1
 
print(a)

Submission status: Wrong Answer

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

b = np.array(a)

ans = np.prod(b)

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
flag = 1
total = 1
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:
N = int(input())
A = list(map(int, input().split()))

ans = 1
for i in range(N):
    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()))
prod = 1
for x in a:
  prod *= x
  if prod:
    if prod > 10**18:
      print(-1)
      break
  else :
    print(0)
    break
else :
  print(prod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
def B(N,A):
    result = 1
    for i in A:
        result *= i
        if result > 10**18:
            return -1
    return result

print(B(N,A))

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import numpy as np
n = int(input()) 
A = list(map(int, input().split()))
i = 10 ** 18
ans = np.prod(A)
if 0 in A:
    print(0)
elif ans > i:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

kakeru = A[0]
for i in range(n):
    
    temp = A[i]
    kakeru = kakeru*temp
ans = int(kakeru/A[0])
if ans > 10**18-1:
    print("-1")
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
    _ = int(input())
    m = 10 ** 19
    a = np.array(list(map(int, input().split())))
    x = np.prod(a)
    print(x if x < m else -1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

if(flag==0):
  print(result)
else:
  print("-1")

Submission status: Wrong Answer

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

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 = int(input())
A = list(map(int, input().split()))

ans = 1
for i in range(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())
A = list(map(int, input().split()))

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
N = input()
A = list(map(int,input().split()))
B = False
total = 1
for a in A:
    if a == 0:
        print(0)
        sys.exit()
    elif a <=10**18:
        total *= a
    else:
        B = True
if B:
    print(-1)
else:
    print(total)

Submission status: Wrong Answer

Solution code:
n=int(input())
alis=list(map(int,input().split()))
p=alis[0]

for i in range(1,n):
  p*=alis[i]
  if len(list(str(p)))>18:
    
    sa=list(map(int,list(str(p))))
    
    if sum(sa)==1:break
    print(-1)
    exit()
print(p)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = input()

ls = list(map(int, input().split()))
ls_a = np.array(ls)
print(np.prod(ls_a))

Submission status: Wrong Answer

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

# A1,A2,..Anの入力
A = list(map(int,input().split()))
         
# A1,A2...Anの積
A_multi = 1
for a in A:
    A_multi *= a

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
MAX = 10**18
ret = 1
flag = True
if 0 in A:
    print(0)
else:
    for a in A:
        ret *= a
        if ret > MAX:
            print('-1')
            flag = False
            break
    if flag and ret < MAX:
        print(ret)

Submission status: Wrong Answer

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

ans = 1
for i in range(N):
    ans = ans * A[i]
    if 10**18 <= ans:
        ans= -1
        break
    else:
        pass
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
num = 1
flag = 0
c=list(map(int, input().split()))
for i in c:
    if i == 0:
        flag = 1
        print("-1")
if flag == 0:
    for i in c:
        num *= i
    if num > 1000000000000000000:
        print("-1")
    else:
        print(num)

Submission status: Wrong Answer

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

import numpy as np
arrayA = np.array(A)
p = np.prod(arrayA)

if 0 in A:
  print(0)
else:
  if p >= 10**18:
    print(-1)
  else:
    print(p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
ans = np.prod(A)
if 0 in A:
  ans = 0
if ans > 10**18 or ans < -1:
    ans = -1  
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)
B=A.prod()
if B<10**18:
    print(B)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
from functools import reduce
N = int(input())
lst = list(map(int,input().split()))
if N == len(lst) :
    output = reduce((lambda x,y: x*y),lst)
    if output <= 10**8 :
        print(output)
    else :
        print(-1)
else :
    exit()