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: Time Limit Exceeded

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

thre = 10**18

a.sort()
#print(a)

tmp = a[0]
for i in range(1,n):
  tmp*= a[i]
  if(tmp == 0):
    break

if(tmp > thre):
  print(-1)
else:
  print(tmp)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = 1
flag = 0
for i in range(n):
    ans = ans * a[i]
    if a[i] == 0:
        ans = 0
        break


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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
res = 1
for a_i in a:
    if 0 == a_i:
        print(0)
        exit(0)
    elif res > 10 ** 18:
        res = -1
    else:
        res *= a_i

print(-1 if res > 10 ** 18 else res)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce
N = int(input())
nums = list(map(int, input().split()))
if reduce(mul, nums) <= (10**18):
    print(reduce(mul, nums))
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
import collections

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

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

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

Submission status: Time Limit Exceeded

Solution code:
count = int(input())
nums = input().split(" ")

product = 1

for i in range(count):
    product *= int(nums[i])

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for a in A:
  ans *= a
  
if ans > 10**18:
  print('-1') 
else:
  print(ans)

Submission status: Time Limit Exceeded

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

for i in range(n):
  x*=a[i]
  
print(x if x<=1000000000000000000 else "-1")

Submission status: Time Limit Exceeded

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

for j in range(N) :
    At = At * A[j]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce
n = int(input())
a = map(int,input().split())
s = list(a)
p = reduce(mul, s)
if p>10**18:
  print(-1)
else:
  print(p)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int,input().split()))
ans=1
limit=10**18
for x in A:
  ans=ans*x

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

Submission status: Time Limit Exceeded

Solution code:
# cook your dish here
m=int(input())
n=[int(x) for x in input().split()]
ans=1
for i in n:
    ans*=i
if(ans>1000000000000000000):
    print('-1')
else:
    print(ans)

Submission status: Time Limit Exceeded

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

result = 1
for i in a:
  result = result * i

if result > 1000000000000000000:
  print('-1')
else:
  print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


for i in range(n//2):
    x = a[i]*a[-1-i]
    c = c*x
if n%2 != 0:
    c = c*a[n//2]

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
f = functools.partial(functools.reduce, operator.mul)
n = int(input())
a = list(map(int,input().split()))
ans = f(a)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l = input().split(" ")
tmp = 1
for item in l:
    tmp *= eval(item)
if tmp > (10**18):
    print(-1)
else:
    print(tmp)

Submission status: Time Limit Exceeded

Solution code:
def multiplyList(myList) : 
      
    # Multiply elements one by one 
    result = 1
    for x in myList: 
         result = result * x
         if result == 0:
             return 0
    return result

n = int(input())
l = list(map(int, input().split()))
res = multiplyList(l)
if(res > 10**18):
    print(-1)
else:
    print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
s = list(map(int,input().split()))
a = s[0]

if len(s) > 1:
    for i in range(1,N):
        if s[i] == 0:
            a=0
            break
        a = a * s[i]
        
if a > 10**18:
    a = -1
print(a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for x in a[1:]:
    ans *= x

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

Submission status: Time Limit Exceeded

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

ans = 1
for i in range(0, len(a)):
    ans = ans*int(a[i])

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

Submission status: Time Limit Exceeded

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

if out <= 1e18:
  print(out)
else:
  print('-1')

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = [int(i) for i in input().split()]
ans = 1
for i in range(n):
    ans = ans * A[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

def main():
    n = int(input())
    A = list(map(int, sys.stdin.readline().split()))

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

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

x = 1
for i in range(n):
    x *= a[i]
    
if x > 1000000000000000000:
    print(-1)
else:
    print(x)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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)
        break
    if i == N-1:
        if result > max:
            print("-1")
        else:
            print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lst = list(map(int,input().split()))
if N == len(lst) :
    output = 1
    for m in lst :
        output *= m
    if output <= 1000000000000000000 :
        print(output)
    else :
        print(-1)
else :
    exit()

Submission status: Time Limit Exceeded

Solution code:
N = input()
nums = [int(e) for e in input().split()]
ret = 1
for i in nums:
    ret = ret * i
if ret > 1e18:
    ret = -1
print(ret)

Submission status: Time Limit Exceeded

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

for i in a:
  multi *= i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

import functools
import operator

r = functools.reduce(operator.mul, a)

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

Submission status: Time Limit Exceeded

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

import functools
import operator

result = functools.reduce(operator.mul, A)

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
nums = list(map(int, input().split(' ')))
ans = 1
for num in nums:
    ans *= num

print(-1) if ans > 1e+18 else print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

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

ans = 1
for a in a_list:
  if a == 0:
    print(0)
    sys.exit()
  
  if a > 1000000000000000000:
    print(-1)
    sys.exit()
  
  ans *= a
 
if ans > 1000000000000000000:
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(j) for j in input().split()]
from collections import Counter

A_C =Counter(A)
A_C = sorted(A_C.items(),key=lambda x:x[0])

result = 1
for a in A_C:
    if a[0]==0:
        print(0)
        exit()
    result*=(a[0]**a[1])

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = list(map(int, input().split()))
c = 1
for b in a:
    c = c*b

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

print(c)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

multiplicacao = 1

asdsd = True

for x in numeros:
    multiplicacao *= x
    
    
if multiplicacao > 1e18:
    print(-1)
    
else:
    print(multiplicacao)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce
N = int(input())
a = list(map(int, input().split()))
l = (10**18)
if 0 in a:
    print(0)
    exit()
c = reduce(mul, a)
if c > l:
    print(-1)
else:
    print(reduce(mul, a))

Submission status: Time Limit Exceeded

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

ans = 1
flag = 0
for i in li:
  if i == 0:
    flag = 1
    break
  ans *= i

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul
n = int(input())
a_list = [int(x) for x in input().split()]
ans = reduce(mul, a_list)
print(ans if ans <= 10 ** 18 else -1)

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
i = input()
i = i.split()
list = []
for j in i:
    j = int(j)
    list.append(j)
result = 1
for j in list:
    result = result*j
if result<=1000000000000000000:
    print(result)
else:
    print("-1")

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = map(int,input().split())
def kake(a):
  res=1
  for i in a:
    res*=i
  if res > 10**18:
    return -1
  else:
    return res
print(kake(A))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 1
a = []
a = input().split(" ")

for i in range(n):
  ans *= int(a[i])
  
if ans > 10**18:
  print("-1")
else:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:


n=int(input())
l=list(map(int,input().split()))
res=1
f=1
for x in l:
    res=res*x
    if(res>1000000000000000000):
        
        f=0
    else:
        f=1
if(f==1):
    print(res)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

res = 1
for i in a:
    res *= i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if(A.count(0)!=0):
    print('0')
    exit()

for i in range(1,len(A)):
    b=b*A[i]

if(10**18<b):

    print('-1')
    exit()

print(b)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

import sys
input = sys.stdin.readline

n = input()
n_list = [int(i) for i in input().split()]
n_value = (reduce(mul, n_list))

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
x = list(map(int, input().split()))
ans=1
for i in range(N):
  ans *=x[i]

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

Submission status: Time Limit Exceeded

Solution code:
import math
n= int(input())

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

Submission status: Time Limit Exceeded

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

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

if(sum > 1000000000000000000):
    print(-1)
    exit(0)

print(sum)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    import sys
    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)
resolve()

Submission status: Time Limit Exceeded

Solution code:
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)
else:
    print(AA)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
from bisect import bisect_left
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
lst = list(readline().split())
mul = 1
for _ in lst :
  x = int(_)
  if(mul>10**18):
    mul = -1
    continue
  mul*=x

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

print(mul)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
n=int(input())
nums = [int(e) for e in input().split()]
ans=1
for i in range(n):
  ans*=nums[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
N = int(input())
A = []
A  = list(map(int,input().split()))	
from operator import add, mul, sub,truediv, floordiv
from functools import reduce

i = reduce(lambda x, y: x*y,A)
if i > 1000000000000000000:
    print("-1")
else:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
#ABC169b

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

sum = 1

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
_ = int(sys.stdin.readline().strip())                 
xs = [int(x) for x in sys.stdin.readline().split(" ")]
r = 1                                                 
for x in xs:                                          
    r *= x                                            
if r > 10 ** 18:                                      
    print("-1")                                       
else:                                                 
    print(r)

Submission status: Time Limit Exceeded

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

for i in a:
	r *= i

if r <= 1e18:
	print(r)
else:
	print(-1)

Submission status: Time Limit Exceeded

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


Con = 10**18
# ans = functools.reduce(lambda a,b: a*b,A)
# print(ans if ans<=Con else "-1")

ans = math.prod(A)
print(ans if ans<=Con else "-1")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

ans = 1

for i in range(n):
    ans *= An[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

def main():
    n = int(input())
    a_list = map(int, input().split())

    result = 1

    for a in a_list:
        result = result * a

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

    print(result)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
n=int(input())
s=input().split()
if '0' in s:
  print(0)
  sys.exit()
l=map(int,s)
ans=math.prod(l)
if ans>10**18:
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
Alist=list(map(int,input().split()))
ans=1
for i in range(N):
  ans=ans*Alist[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

#print(A)

flag = 0
b = 1

for a in A:
  if a == 0:
    flag = 2

if flag == 0:
  for a in A:
    b = b * a

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

Submission status: Time Limit Exceeded

Solution code:
N, *a = map(int, open(0).read().split())

ans = 1
for x in range(N):
    ans = ans * a[x]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1
for a in A:
  ans *= a
  if ans == 0:
    break

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

import math
# N = 2
# ARR = [1000000000, 1000000000]

def calculate(n,arr):
    res = 1
    for i in range(n):
        # a1 = math.log(arr[i],10)
        # a2 = math.log(arr[i], 10)
        # if a1 + a2 > 18:
        #     res = -1
        #     continue
        res = res * arr[i]
        if res > 1000000000000000000:
            res = -1

    return res

print(calculate(N,ARR))

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

n = int(input())
a = list(map(int, input().split()))
ans = reduce(mul, a)
if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

ans = 1

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

Submission status: Time Limit Exceeded

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

def mul(A):
    m=1
    for na in A:
        if na==0:
            return 0
        m *= na
    if m>10**18:
       return -1
    return m
    
print(mul(A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
if __name__=="__main__":
    # Problem B
    N = int(input())
    A = [None]*N
    A = list(map(int, input().split(' ')))
    result = 1
    flag = False
    for x in A:
        result = result * x

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

Submission status: Time Limit Exceeded

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

ans = 1
can = 1
zero = 0

for i in range(N):
    if a[i]==0:
        zero = 1
        ans = 0

if(zero==0):
    for i in range(N):
        ans = ans * a[i]
        if(ans>1000000000000000000):
            can = 0

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

ans = 1
flag = True
a = list(map(int, input().split()))
for i in a:
    ans *= i
    if ans > 1000000000000000000:
        flag = False

if ans == 0:
    flag = True

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

Submission status: Time Limit Exceeded

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

import sys
sum = 1
for i in a:
    if i == 0:
        print(0)
        sys.exit()
    else:
        sum *= i

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

Submission status: Time Limit Exceeded

Solution code:
# A, B = tuple(map(int, input().split()))
N = int(input())
list_A = list(map(int, input().split()))
result = 1
for a in list_A:
    result = result * a
threshold = 10 ** 18

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

Submission status: Time Limit Exceeded

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 and 0 not in a:
    b = -1
    break
print(b)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce
n = int(input())
A = list(map(int, input().split()))
ans = reduce(mul, A)
if ans <= 10**18:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
while True:
    try:
        listA=list(map(int,input().split()))
        #listA<-[1,2,2,3,1]
        #ここに逐次処理を書けばいいと思う。
    except:
        break;

product=1
for i in listA:
  	product=product*i
    
if product<10**18+1:
  print(product)
  
elif product>=10**18+1:
  print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul

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

ans = reduce(mul, a_li)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

N = int(input())
A = [int(i) for i in input().split(' ')]
if 0 in A:
    print(0)
else:
    goal = reduce(mul, A)
    if goal <= 10**18:
        print(goal)
    else:
        print(-1)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import add
from operator import sub
from operator import mul

n = int(input())
li = list(map(int,input().split()))
c = reduce(mul, li)

if c <= 10**18:
    print(c)
else:
    print('-1')

Submission status: Time Limit Exceeded

Solution code:

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    ans = A[0]
    for i in A[1:]:
        ans *= i
    if ans > 1000000000000000000:
        ans = -1
    print(ans)

Submission status: Time Limit Exceeded

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

result = 1
for i in range(len(A)):
    result *= A[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *a = map(int, read().split())

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
se = 1
for n in range(N):
  se *= A[n]
if se >  10**18:
  print("-1")
else:
  print(se)