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 = list(map(int, input().split()))
res = 1
for i in range(n):
  res = a_list[i]*res
if res > 1000000000000000000:
    print(-1)
else:
  print(res)

Submission status: Time Limit Exceeded

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

res=1
for i in ss:
    res*=i
    
if res>1000000000000000000:
    res=-1
print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = input()

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

acum = 1

for x in a:
    acum = acum * x

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

Submission status: Time Limit Exceeded

Solution code:
limit = 1E18

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

result = 1
for n in A:
  result = result * n

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

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 > pow(10,18):
  ans=-1
  
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:
n = int(input())


while True:
    try:
        listA=list(map(int,input().split()))
        #listA<-[1,2,2,3,1]
        #ここに逐次処理を書けばいいと思う。
    except:
        break;
        
resutl = 0
for index, item in enumerate(listA):
    if(index==0):
      resutl=item
    else:
      resutl=resutl*item
      
if(resutl>1000000000000000000):
  print(-1)
else:
  print(resutl)

Submission status: Time Limit Exceeded

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

for i in range(n):
    if a[i] == 0:
        print("0")
        exit() 

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

Submission status: Time Limit Exceeded

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

ans = 1

for a in range(0,N):
	ans = ans * int(A[a])
	if int(A[a]) == 0:
		ans = 0
		break

#for a in input().split:
#	ans = ans * a


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

print(ans)

Submission status: Time Limit Exceeded

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

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

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

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

n=int(input())
list_a=list(map(int, input().split()))
result=reduce(mul,list_a)
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 = A[0]
for i in range(N-1):
	ans *= A[i+1]
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()))

Con = 10**18

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


print(ans if ans<=Con else "-1")

Submission status: Time Limit Exceeded

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

result = 1

border = 10 ** 18

for i in A:
    result = result * i
    
if result > border:
    result = -1

print(result)

Submission status: Time Limit Exceeded

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

ans= 1

def main(A, ans):
  for i in range(N):
    ans = ans * A[i]
  if ans > 10**18:
    print(-1)
    return
  print(ans)
  
main(A, ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

n = int(input())
a = list(map(int,input().split()))
MAX = 10**18
a.sort()
if a[0] == 0:
    print(0)
else:
    mul = reduce(lambda ans,x:ans*x, a)
    if mul > MAX:
        print(-1)
    else:
        print(mul)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

prod = functools.partial(functools.reduce, operator.mul)
count = int(input())
list = list(map(int, input().split()))
sum = prod(list)

if sum > 1000000000000000000:
    sum = -1

print(sum)

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

for i in range(N):
    p = p * li[i]

if p > 1000000000000000000:
    print(-1)

else:
    print(p)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = int(1)
s = str(input())
ls = list(s.split())
for i in ls:
    x = int(i)
    ans *= x
    if ans > 1e18:
        ans = -1
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a= input().split()
level = pow(10, 18)
product = 1

for num in range(n):
  product *= int(a[num])

if product > level:
  print("-1")
else:
  print(product)

Submission status: Time Limit Exceeded

Solution code:
def main():
	
	k = int(input())
	h = list(map(int,input().split()))
	ans = 1
	avoid = 0
	for i in h:
		ans = i * ans

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


if __name__ == '__main__':
	main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
mul=1
limit=1000000000000000000
x=input().split()
for i in range (n):
    p=int(x[i])
    mul*=p
if(mul>limit):
  print(-1)
else:
  print(mul)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1

for a in A:
    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()))  # 入力のときに 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')
else:
    print(Ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = int(input())
A = [int(i) for i in input().split()]
ans = 1

for i in range(n):
    ans *= A[i]
    
if ans >pow(10,18):
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

a = [1, 2, 3, 4] # 適当なリスト

N = int(input()) # 1行, 単数
arg = list(map(int, input().split())) # 1行, 配列

m = reduce(mul, arg)
 
if m - 1000000000000000000 > 0:
  print(-1)
else:
  print(m)

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
ans = 1
n = list(map(int, input().split()))
for i in range(a):
    ans = ans * n[i]
    if n[i] == 0:
        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()))
result=1
for i in range(n):
    result=a[i]*result

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

print(result)

Submission status: Time Limit Exceeded

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

for i in range(len(a)):
    out*=a[i]

if out<1000000000000000001:
    print(out)
else:
    print(-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 A.count(0)>0:
        ans=0
        break
    if ans>10**18:
        ans=-1
        break
    

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = [int(x) for x in input().split()]
prod = 1
for x in A:
  prod *= x
if prod <= 10 ** 18:
  print(prod)
else:
  print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = int(A[N])

while N > 0:
    ans = ans * A[N-1]
    N = N-1

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

# A, B = tuple(map(int, input().split()))
N = int(input())
list_A = list(map(int, input().split()))

result = reduce(mul, list_A)
threshold = 10 ** 18

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

num = 1
for x in range(n):
    num *= a[x]
    if num == 0:
        break
    if 10**18 < num:
        if 0 in a[x:]:
            num = 0
        else:
            num = -1

print(num)

Submission status: Time Limit Exceeded

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

total = 1
for a in li:
  total *= a
  
if 10 ** 18 < total:
  total = -1
  
print(total)

Submission status: Time Limit Exceeded

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

    ans = 1
 
    for i in a:
        ans *= i
    
    if ans > int(1e18): return -1
    return ans
    

print(solve())

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
list = [int(i) for i in input().split()]
left = 1
right = 1
ans = 1
flag = True
for i in range(n):
    if i%2==0:
        right *= list[i]
    else:
        left *= list[i]

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

Submission status: Time Limit Exceeded

Solution code:
import sys
from operator import mul
from functools import reduce

t = 10**18


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

if li.count(0) >= 1:
    print(0)
    sys.exit()

ans = reduce(mul,li)

if ans > t:
    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 a:
    ans = ans*i
if ans > 1e18:
    print("-1")
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict, deque
from functools import reduce
from operator import mul
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
import math
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

n = inp()
A = inpl()
ans = reduce(mul, A)
if ans >= 1000000000000000001:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lst=list(map(int,input().split()))
product = 1

for i in lst:
    product*=i
if product<=10**18:
    print(product)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = 1
sw = 0
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        sw = 1
import collections
c = collections.Counter(a)

if sw == 1 and c[0] == 0:
    ans = -1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
cur=1
li=list(map(int,input().split()))
for k in li :
        cur*=k
        if cur>1e18:cur=-1
print(cur)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
L = []

N = int(input())

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

sum0 = 1

for n in range(0,N):
    sum0 = sum0 * str_list[n]
if sum0 > 10**18:
    print(-1)
else:
    print(sum0)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 1
str = input()
listr = str.split(' ')
for i in listr:
	x = int(i)
	ans = ans * x

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

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 == 0:
    break

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

for i in range(N):
    P = P * A[i]
    
if P <= 1e18:
    print(P)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
#a, b = map(int, input().split())
#x, y, z = map(int, input().split())
#a, b, h, m = map(int, input().split())
arr = list(map(int, input().split()))

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

Submission status: Time Limit Exceeded

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

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

if result > pow(10, 18):
    print(-1)
    exit(0)
print(result)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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 0 in a:
        sum = 0
        break
    elif sum > 10**18:
        break
    


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

Submission status: Time Limit Exceeded

Solution code:
N= int(input())
lists = list(map(int,input().split()))
#print(lists)
#q=int(1)
#for i in range(N):
#    q *= int(list[i-1])
#    print(q)
import functools
import operator

#li = [2,5,7,9]
result = functools.reduce(operator.mul, lists)
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()))
answer = 1

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580


def solve():
    N = int(input().rstrip())
    vec =list(map(int, input().split())) 
    X = 1
    for x in vec:
        X *= x
    
    if(X > 1000000000000000000):
        print(-1)
    else:
        print(X)
        
if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

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

result=1
for i in X:
  result*=i
  
if result>10**18:
  result=-1

print(result)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
temparr = input()
temparr = temparr.split()
flag = 0 

arr = []
first = 0 
totallen = 0 
for i in  temparr:
    if first == 0 :
        totallen += len(i)
        first = 1 
    else:
        totallen += len(i) - 1 
    if totallen > 19:
        flag = 2
        break
    if "0" in temparr:
        flag = 1 
        break 

    arr.append(int(i))
if flag == 2:
    print("-1")
elif flag == 1 :
    print("0")
else:
    ans = 1
    arr = sorted(arr)
    arr = arr[::-1]
    for i in arr:
        ans *= i 
        if ans > 1000000000000000000:
            flag = 1 
            break 
    if flag == 0 :
        print(ans)
    else:
        print(-1)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

border = 10 ** 18

N = int(input())
nums = list(map(int, input().split()))
result = reduce(mul, nums)

if result > border:
    print(-1)
    exit()
print(result)

Submission status: Time Limit Exceeded

Solution code:

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

    a_list = list(filter((1).__ne__, a_list))

    if 0 in a_list:
        print('0')
        return

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

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

Submission status: Time Limit Exceeded

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

x = 1


for i in A:
  x = x*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

limit = pow(10,18)

f = 0
for i in range(N):
    if A[i] != 0:
        ans *= A[i]
    else:
        print(0)
        exit()

    if ans > limit:
        f = 1

if f == 1:
    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, v in enumerate(A):
  if i >= N:
    break
  x *= A[i]

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

Submission status: Time Limit Exceeded

Solution code:
try:
    N=int(input())
    
    if N>=2 and N<=10**5:
        
        A=input().split(' ')
        counter=0
        
        for i in A:
            if int(i)>=0 and int(i)<=pow(10,18):
                counter+=1
        if counter==len(A):
            product=1
            for i in A:
                product*=int(i)
            if product>pow(10,18):
                print('-1')
            else:
                print(product)
            
except Exception as e:
    print(e)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
ans = reduce(lambda x,y:x*y,A)
if ans > 10 ** 18:
  print("-1")
else:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:

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

total = 1
flag = 0
for i in range(len(inputs)):
    total = total * inputs[i]

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

Submission status: Time Limit Exceeded

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

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


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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
li = list(map(int, input().split()))
ans=1
for i in li:
    ans*=i
if ans >1000000000000000000:
	print("-1")
else:
	print(ans)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator


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

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
c = list(map(int, input().split()))
import functools
import operator
q = functools.reduce(operator.mul, c)
if q > 1000000000000000000:
  print(-1)
else:
  print(q)

Submission status: Time Limit Exceeded

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
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:
def main():
    n = input()
    A = [int(i) for i in input().split()]
    ans = 1
    for a in A:
        ans *= a

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
from functools import reduce
from operator import mul

N= int(input().rstrip('\n'))
As =[int(x) for x in input().rstrip('\n').split()]
res = reduce(mul,As)
if res > 10**18:
  res = -1
print(int(res))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=map(int,input().split())
x=1
for a in A:
    x*=a

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

Submission status: Time Limit Exceeded

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

print(-1) if ans > 1e+18 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 ans > 10**18:
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

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

ans = 1
for x in l:
    if x == 0:
        ans = 0
        break
    ans = ans * x

if ans > 1000000000000000000:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

p = 1
for k in a:
    p *= k

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

Submission status: Time Limit Exceeded

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

Solution code:
n = int(input())
ans = int(1)
s = str(input())
ls = list(s.split())
for i in ls:
    x = int(i)
    ans *= x
if ans > 1e18:
    ans = -1
print(ans)

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
an = reduce(lambda x, y: x * y, A) 
  
if an > 10**18:
  print(-1)
  
else:
  print(an)

Submission status: Time Limit Exceeded

Solution code:
N,*A = map(int,open(0).read().split())
a = 10**18
ans = 1
if 0 in A:
    print(0)
    
else:
    for i in A:
        ans *= i
    if ans > a:
        print(-1)
        exit()
    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 *= a[i]
if ans > int(1e18):
    print(-1)
    exit()
print(ans)

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

As = list(map(int, input().split()))
result = 1
maxInt = 1000000000000000000
for a in As:
	result *= a
if maxInt < result:
	print(-1)
else:
	print(result)

Submission status: Time Limit Exceeded

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

ans = 1

over=False
zero=False
for num in data:
    ans*=num
    if(ans>1000000000000000000):
        over=True
    if(num == 0):
        zero=True

if ans>1000000000000000000:
    over=True

if zero:
    print("0")
elif over:
    print("-1")
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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 == 0:
    print(ans)
else:
    if ans > pow(10,18):
        print(-1)
    else:
        print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l = list(map(int, input().split()))
if 0 in l:
  print(0)
else:
  prod = 1
  for _ in l:
    prod *= _
  if prod > pow(10, 18):
    print(-1)
  else:
    print(prod)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
if __name__ == "__main__":

    N = int(input())

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

    mult = 1
    for i in P:
        mult *= i

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

Submission status: Time Limit Exceeded

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

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

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