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

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

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

Submission status: Wrong Answer

Solution code:
import sys

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

Submission status: Wrong Answer

Solution code:
input_num = int(input())
line = input().split(" ")
output = 1
zero_flg = False
over_flg = False
for i in range(input_num):
    if int(line[i]) == 0:
        zero_flg = True
        break
    output = output * int(line[i])
    if output > 10 ** 18:
        over_flg = True
        break
    
if zero_flg:
    print("0")
elif over_flg:
    print("-1")
else:
    print(output)

Submission status: Wrong Answer

Solution code:
n = int(input())
out = 1
an = list(map(int,input().split()))
check = True

for a in an:
  out *= a
  if out>10**18:
    check = False
if check:
	print(out)
else:
	print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
lt = list(int(x) for x in input().split())
seki = np.prod(lt)
if seki < 10 ** 18:
  print(seki)
else:
  print('-1')

Submission status: Wrong Answer

Solution code:
n = map(int, input().split())
a = 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 sys
n=int(input())
l=list(map(int,input().strip().split()))
l.sort()
if(l[0]==0):
	print(0)
	sys.exit()
prod=1
MAX = 1000000000000000000
l.sort(reverse=True)
for i in l:
	prod*=i
	if(prod>MAX):
		print(-1)
# else:
if(prod>MAX):
	print(-1)
print(prod)

Submission status: Wrong Answer

Solution code:
import math

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

flag_zero=0
sum = 0
for i in range(n):
  if a[i]==0:
    flag_zero=1
  else:
    sum += math.log10(a[i])

if flag_zero == 1:
  print(0)
elif sum >= 18:
  print(-1)
else:
  sum = 1
  for i in range(n):
    sum *= a[i]
  if sum > 10**18:
    print(-1)
  else:
    print(sum)

Submission status: Wrong Answer

Solution code:
n = input()
cut = 10**18
nums = list(map(int,input().split(" ")))
 
def mul(nums):
  ans = 1
  for i in nums:
    ans = ans*i
    if ans > cut:
      return "-1"
  return ans

print(mul(nums))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

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


prod = 1
overflow_flag = False

for a in As:
    prod *= a

    if prod > 10*18:
        overflow_flag = True
        break

if overflow_flag or prod > 10**18:
    print("-1")
else:
    print(prod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a=input()
b=input().split(" ")
sum1=1

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = list(map(int, input().split()))
res = 1
for i in lis:
    if res > 10**18:
        res = 10**18 + 1
    else:
        res *= i
print(res if res <= 10**18 else -1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, result = eval(input()), 1
List = list(map(int, input().split()))
for i in List[:N]:
    result *= i
    
print(result)

Submission status: Wrong Answer

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

#List にしたい時
#intの場合
huga = list(map(int, input().split()))
ans = 1
for number in huga:
    ans = ans * number
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

sum = a[0]

for i in range(1,len(a)):
    sum = sum * a[i]
    if sum > 10**18:
        break
    elif a[i] == 0:
        sum = 0
        break

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()))
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()))
list.sort(A)
ans = 1
for a in A:
    ans *= a
    if ans > 1e18:
        ans = -1
        exit()
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(float,input().split( )))
ans = 1
for a in A:
    ans *= a
if ans >= 1e18:
  ans = '-1'

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
n=int(input())
a=list(map(int,input().split()))
ans=1
for i in range(n):
    if a[i]==0:
        print(0)
        sys.exit()

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

Submission status: Wrong Answer

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

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

    else:
        print(ans)

Submission status: Wrong Answer

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

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 = [int(e) for e in input().split()]
ans = 1
if 0 in a:
    print(0)
else:
    for i in range(n):
        ans *= a[i]
        if ans > 10:
            print(-1)
            break  
    else:
        print(ans)

Submission status: Wrong Answer

Solution code:
n = input()
ans = 1
s = list(map(int, input().strip().split()))
if 0 in s:
    print(0)
    exit()
for i in s:
    if ans>10**18:
        print(-1)
        exit()
    ans = ans*i

print(ans)

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Ans=1

for A in range(N):
    NewAns=Ans*As[A]
    Ans=NewAns
if Ans<10**18:
    Ans=-1

print(Ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

ans = 1

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

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

Submission status: Wrong Answer

Solution code:

import numpy as np
n=int(input())

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

Submission status: Wrong Answer

Solution code:
x = int(input())
y = list(map(int,input().split()))
z = 0
a = 0
for i in range(x):
  if z < x - 1:
    a = y[z] * y[z+1]
    z = z + 1
exit()

print(a)

Submission status: Wrong Answer

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

X = 1

for i in range(N):
    if a[i] == 0:
        X = 0
    elif N > 70:
        X = -1
    else:
        X = X * a[i]
        if X > 1000000000000000000:
            X = -1

print(X)

Submission status: Wrong Answer

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

if 0 in a:
  total = 0
else:
  for i in a:
    total *= i
    print(i, total)
    if total > 10 ** 18:
      total = -1
      break
print(total)

Submission status: Wrong Answer

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

ans = 1

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

Submission status: Wrong Answer

Solution code:
N=int(input())

arr=[eval(i) for i in input().split()]
#print(N,": ",arr)
res=1
for i in arr:
    res=res*i
    if res>10**18:
        res=-1
        break

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split(' ')))
res = 1
zer = False
for b in a:
    if b == 0: zer = True
if zer:
    print(0)
else:
    for b in a:
        res *= b
        if res > 1000000000000000000:
            print(-1)
    if res <= 1000000000000000000:
        print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

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

num = 1
for x in a[:]:
    num*=x
    if x == 0:
        num = 0
        break
    elif 10**18<num:
        num = -1
        break

print(num)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
ma = 10**18
ans = np.prod(a)
if ans > ma:
    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):
    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:
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(0)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 1
flg = False

for i in d:
  if cnt > 10**18:
    flg = True
    break
  else:
  	cnt *= i

if flg:
  print('-1')
else:
  print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
  n = int(input())
  li = list(map(int,input().split()))
  li.sort()
  ans = 1
  for i in range(n):
    ans *= li[i]
    if ans > (10 ** 18):
      print(-1)
      exit()
    print(ans)


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import numpy
n = int(input())
a = list(map(int, input().split()))
ans = 1
ans = numpy.prod(a)
# for i in range(n):
#     ans *= a[i]
if ans > pow(10, 18):
    print("-1")
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    if 0 in A:
        return 0
    prod = 1
    for i in range(N):
        if 10**18//prod <= A[i]:
            return -1
        prod *= A[i]
    return prod
print(solve())

Submission status: Wrong Answer

Solution code:
n=int(input())
mx=1000000000000000000
z=1

a=[int(i) for i in input().split()]
for i in a:
    z=z*i
    if z > mx : z=-1
    if  z==-1 :   break

if z>mx or z < 0 : z=-1
print(z)

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

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
A_list = list(map(int,input().split()))
answer = 0.
for a in A_list:
    if a!=0.:
        answer+=math.log10(a)
    else:
        answer=0.
        break
    #print(answer)

if answer > 18.:
    print(-1)
else:
    print(answer)

Submission status: Wrong Answer

Solution code:
import math 
N =int(input())
A = list(map(int,input().split()))
Sum = 1
for i in range(N):
  Sum *= A[i]

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

Submission status: Wrong Answer

Solution code:
N = int(input())
li = input().split()
a = 1
try:
  h = li.index('0')
  print(0)
  exit()
except:
  d =1

for i in range(N):
  a *= int(li[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()))
tar = np.prod(A)

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

Submission status: Wrong Answer

Solution code:
input()
r = 1
for x in map(int, input().split()):
  if x == 0:
    r = 0
    break
  r *= int(x)
  if r > 1e18:
    r = -1
    break
print(r)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

if ans <= 1000000000000000000:
    print(ans)

Submission status: Wrong Answer

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

Flag = True
ans = 1
for i in range(n):
  ans = ans * As[i]
  if (ans > 10**18):
    if (Flag):
      print(-1)
      Flag = False
      break
  
if (Flag):
  print(ans)

Submission status: Wrong Answer

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

list.sort(A, reverse=True)
mx = 1000000000000000000
mul = 1
for a in A:
    mul *= a
    if mul == 0:
        break
    elif mul > mx:
        mul = -1

print(mul)

Submission status: Wrong Answer

Solution code:

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

result = int(np.prod(A))

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

x = int(np.prod(a))

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

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:
        if int(i) >= 0 and int(i) <= 10000000000000000:
            result = result * int(i)
        else:
            break
    if result > 1000000000000000000:
        print(-1)
    else:
        print(result)
else:
    print()

Submission status: Wrong Answer

Solution code:
# your code goes here
from sys import stdin, stdout
n = int(input())
a = input().split()
res = 1
for e in range(n):
	res *= int(a[e])
	if res > 1000000000000000000:
		break
if res > 1000000000000000000:
	print(-1)
else:
	print(res)

Submission status: Wrong Answer

Solution code:
n=int(input())
h = list(map(int,input().strip().split()))[:n]

def func(n,h):
  if (n==0 ):
    return 0
  if(n==1):
    return h[0]
  if(h.count(0)>0):
    return 0
  ans=h[0]
  for i in range(1,n):
    if(ans>1000000000000000000):
      return -1
    if(ans<1000000000000000000):
      ans=ans*h[i]
  return ans

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

li = list(map(int,input().split()))	
x=reduce(mul, li)
if x>=10**18:
  print("-1")
else:
  print(x)

Submission status: Wrong Answer

Solution code:
def m():  
    N = int(input())
    A = list(map(int, input().split()))
    times = 1
    for i in A: 
        if times < 10**18:
            times *= i
        else:
            pass
    if times > 10**18:
        print(-1)
    else:
        print(times)
m()

Submission status: Wrong Answer

Solution code:
n = int(input())
lim = 10**18
ans,exc = 1,False
for x in input().split():
  ans *= int(x)
  if ans > lim:
    exc = True
    print("-1")
if not exc:
  print(ans)

Submission status: Wrong Answer

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

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

result = 1
for num in nums:
    result *= num

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

Submission status: Wrong Answer

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

ans = 1
if A.count(0) > 0:
  ans = -1
else:
  for i in range(N):
      ans *= A[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()))

q = 1000000000000000000
b = 1
cek = True
for i in range(n):
	b = b * a[i] 
	if b > q :
		cek = False
		break
if cek :
	print(b)
else :
	print("-1")

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

Submission status: Wrong Answer

Solution code:
#A
n = int(input())
a = list(map(int, input().split()))
ans = 1
b = 0
for i in a:
    ans *= i
    if ans > 10 ** 18:
        ans = 0
        b = -1
if ans != 0 and b==-1 :
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys

num_data = sys.stdin.readlines()
num_list = num_data[1].split()
ans = 1
for i in range(int(num_data[0])):
  ans *= int(num_list[i])

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

Submission status: Wrong Answer

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

As = 1
for i in range(N):
    As = As*A[i]
    if 1000000000000000000 < As:
        print(-1)
        break

if 1000000000000000000 < As:
    print(As)

Submission status: Wrong Answer

Solution code:
import sys

n = sys.stdin.readline()
l = list(map(int, sys.stdin.readline().split()))
tmp = 1000000000000000000

ans = 1
for i in l:
    if i == 0:
        ans = 0
        break

    ans *= i
    if 1000000000000000000 < ans:
        break

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
cnt=1
a=list(map(int,input().split()))
for it in a:
  cnt*=it
  if cnt>1000000000000000000:
    print(-1)
    exit()
if cnt>1000000000000000000:
  print(-1)
else:
  print(cnt)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
lt = list(int(x) for x in input().split())
seki = np.prod(lt)
if seki < 10 ** 18:
  print(seki)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

import sys

minus_count = 0
for i in range(len(A)):
    if A[i] < 0:
        minus_count += 1
    if A[i] == 0:
        print(0)
        sys.exit(0)

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
AList = np.array([int(element) for element in input().split(" ")], dtype=np.int64)
result = np.prod(AList)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def mul2():
    n = int(input())
    nums = list(map(int,input().split()))
    limit = 10**8
    res = 1
    for num in nums:
        res *= num
        if res > limit:
            return -1
    return res

if __name__ == "__main__":
    print(mul2())

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a = 1
for i in map(int,input().split()):
	a *= i

if a>10e12:
	print(-1)
else:
	print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

x = np.prod(np.array(list(A)))
if int(x) > 10**18:
    print(-1)
else:
    print(int(x))

Submission status: Wrong Answer

Solution code:
import sys
largenum = 10**18
def main():
    n = int(input())
    a = list(map(int, input().split()))

    r = 1
    for i1 in range(n):
        r *= a[i1]
        if r > largenum:
            print('-1')
            sys.exit()
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
_ = int(input())

result = 1
num = list(map(int, input().split()))
flag = 0

for i in num:
    result = result * i
    if result > 1000000000000000000:
        flag = 1
        break

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
lim = 10**18

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

  
ans = 1
A.sort()
for i in range(len(A)):
  if ans > lim:
    print(-1)
    break
  ans = ans * A[i] 

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

Submission status: Wrong Answer

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

ans = 1
for a in A:
    ans *= a
    if ans >= 10**18:
        ans = -1
        break

print(ans)

Submission status: Wrong Answer

Solution code:
x = input()
y = [int(a) for a in input().split(" ")]
if 0 in y:
  print(0)
  exit(0)
res = 1
for i in y:
  res *= i
  print(res)
  if res > int(1e+18):
    print(-1)
    exit(0)
print(res)

Submission status: Wrong Answer

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

if 0 in A:
    print("0")
else:
    arr_A = np.array(A)
    A = np.prod(A)
    if A > 1000000000000000000:
        print ("-1")
    else:
        print(A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

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

total = 1

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

if total > 100000000000000000:
    print("-1")
else:
    print(total)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(n) for n in input().split()]
result = 1
max = 10**18

for i in range(N):
    result *= A[i]
    if result == 0:
        print(0)
    if i == N-1:
        if result > max:
            print("-1")
        if i == N-1:
            print(result)

Submission status: Wrong Answer

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

aa =[]
aa.append(1)
for j in range(n):
    aa.append(aa[j] * a[j])

print(aa[n])

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split()
res = 1
if N > 2 and N < 10**5:
    for x in A:
        if int(x) < 10**8:
            res*= int(x)
        else:
            res = -1
            break
else:
    res = -1

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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