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:
from math import *
from heapq import *

def mi():
    return map(int, input().split())
def ii():
    return int(input())
def li():
    return list(mi())
def gcd(a,b):return a if(not b) else gcd(b,a%b)
def qw(a,b,p):
    '''quick pow'''
    ans = 1
    while b:
        if b & 1:
            ans = ans * a % p
        a = a * a % p
        b >>= 1
    return ans
def is_prime(x):
    if(x < 2): return 0
    for i in range(2,int(sqrt(x)+1)):
        if(x % i == 0) : return 0
    return 1

n = ii()
a = li()
ans = 1
for i in range(0,n):
    ans = 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()))
m=1

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

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

Submission status: Time Limit Exceeded

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

count = input()

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

result = 1

for item in lst:
    result = result * item

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a_list=list(map(int, input().split()))
multi_sum=1
LIMIT=10**18
for a_i in a_list:
    multi_sum*=a_i

if multi_sum > LIMIT:
    multi_sum=-1
print(multi_sum)

Submission status: Time Limit Exceeded

Solution code:
from math import log10

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

sum = 1



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

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

Submission status: Time Limit Exceeded

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

if 0 in a:
    ans = 0
else:
    for i in range(1, n):
        ans *= a[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()))

s = A[0]
for i in range(1, n):
  s *=A[i]

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

Submission status: Time Limit Exceeded

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

sum = 1
i = 0
while i < len(A):
    if 0 in A:
        sum = 0
        break
    sum *= A[i]
    i+=1
    if sum > 1000000000000000000:
      break

if sum > 1000000000000000000:
    sum = -1

print(sum)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
array=input().split(" ")
sum=1
for i in range(N):
  sum=sum*int(array[i])
if sum>1000000000000000000:
	sum=-1
    

print(sum)

Submission status: Time Limit Exceeded

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

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:
n = int(input())
a = [int(i) for i in input().split()]

ans = 1
for i in range(n):
    
    ans *=a[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()))

answer1=1
answer2=0
for i in range(n):
  answer1=answer1*a[i]
  answer2=answer2*a[i]
  if answer1>=10**18:
    answer2=answer2+(answer1//(10**18))
    answer1=answer1%(10**18)
    
if answer2>=1 and answer1!=0:
  print(-1)
else:
  print(answer2*(10**18)+answer1)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

a_str = input()
a = a_str.split(' ')
total = 1

for i in a:
    total *= int(i)

if total <= 1e+18:
    print (total)
else:
    print('-1')

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

ans = 1

for i in an:
    
    ans *= i
    
else:
    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 e in a:
  ans *= e
if ans > 10 ** 18:
  print('-1')
  exit()

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

res = 1

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

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

if res == -1:
    for i in a:
        if a == 0:
            res = 0
            break

print(res)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
prod = 1
z = [int(i) for i in input().split()]
for x in z:
    prod = prod * x
    if prod > 1000000000000000000:
        prod = - 1
print(prod)

Submission status: Time Limit Exceeded

Solution code:
n = 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:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
from operator import mul
from functools import reduce
N = I()
A = LI()
ans = reduce(mul, A)
if ans > 10**18:
    ans = -1
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 > 1000000000000000000:
    print(-1)
    sys.exit()
    
  if a == 0:
    print(0)
    sys.exit()
  
  ans *= a
 
if ans > 1000000000000000000:
  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 l:
    ans*=i
if ans>10**18: print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

n = input()

nums = list(map(int,input().split(" ")))
 
ans = reduce(lambda x,y: x*y, nums)

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

Submission status: Time Limit Exceeded

Solution code:
import sys

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

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

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

else : print(a)

Submission status: Time Limit Exceeded

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

MAX=10**18
ans = 1
fover=False
for A in As:
    ans *= A
    if ans > MAX:
        fover=True

if ans == 0 or fover==False:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

if __name__ == '__main__':
    str = input().strip()
    str = input().strip()

    arr = [int(e) for e in str.split()]

    total = 1
    for e in arr:
        if e == 0:
            total = 0
            break
        total *= e

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

    print(total)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = input()
ans = 1
s = list(map(int, input().strip().split()))
for i in s:
    ans = ans*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()))
a = 1
for i in l:
    a *= 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()))
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())

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

total = a[0]

for i in range(1,N):
    total *= a[i]
    if  10 ** 18 < total and 0 not in a:
        print(-1)
        exit()
print(total)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
res = 1
a = map(int, input().split())
for x in a:
    res *= x
if res > 1e18:
    res = -1
print(res)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline

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

m = 1
j = 0

if 0 in AS:
    print(0)
    j = 1

for i in AS:
    m = m * i
    if m > 10**18 and j == 0:
        print(-1)
        j = 1
        break
    elif m == 0:
        break
    else:
        continue

if j == 0:
    print(m)

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:
  b = b * a

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

Submission status: Time Limit Exceeded

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

for i in range(n):
    x = x*a[i]
    
if x > 10**18:
    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):
    b = a.pop()
    ans *= b

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

Submission status: Time Limit Exceeded

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

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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a_list = [int(i) for i in input().split()]

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
num_list = input().rstrip().split(' ')
answer = 1
for i in range(num):
  answer = answer*int(num_list[i])

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

Submission status: Time Limit Exceeded

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

if ans < 0:
    ans = -1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
import sys
A = int(input())
nums = [int(x.strip()) for x in input().split(' ') ]

tmp = 10 ** 18
ans = 0

count = 0
for num in nums:
    if not count == 0:
        ans = ans * num
    else:
        ans = num
    count += 1
if ans > tmp:
        print(-1)
        sys.exit()
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = input().split(" ")
K = 1

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

Submission status: Time Limit Exceeded

Solution code:
max = 10**18
n = int(input())
A = list(map(int,input().split()))
ans = A[0]
for i in A[1:]:
    ans *= i

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

Submission status: Time Limit Exceeded

Solution code:
import sys
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def input(): return sys.stdin.readline().strip()
mod = 10**9 + 7
from math import pow

n = int(input())
arr =get_array()
sum = 1
for i in range(n):
    sum *= arr[i]
if sum > pow(10,18):
    print(-1)
else:
    print(sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
la = list(map(int, input().split()))
import functools
import operator

ans = functools.reduce(operator.mul, la)
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
if 0 in a:
    print(0)
    exit()
for i in range(n):
    p = p * a[i]
if p > 10**18:
    print(-1)
else:
    print(p)

Submission status: Time Limit Exceeded

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

for j in range (N):
  if L[j] > 10**18:
    print(-1)
    exit()

for i in range(N):
  A *= L[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()))
flag = 0
b = 1

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
line = input().split()

MAX = 1000000000000000000

ans = 1

for l in line:
    ans = int(l) * ans

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

n = int(input())

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

val = 1
flg = True
for num in nums:
    val = val * num

if val > 1e18:
    val = -1

print(val)

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
import functools
import operator

n = int(input())
a = list(map(int, input().split()))
sumans = functools.reduce(operator.mul, a)

INF = 1000000000000000000
if (sumans > INF):
    print(-1)
else:
    print(sumans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
An = input().split()

mult = 1
for i in range(N):
    mult = mult * int(An[i])

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

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

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

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for num in range(N):
    Ans = Ans * A[num]

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

else:
    print(Ans)

Submission status: Time Limit Exceeded

Solution code:
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 **18
N,*A = map(int, read().split())
ans = 1
for i in A:
  ans *= i
if ans <=INF:
  print(ans)
else:
  print(-1)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
n=int(input())
As = list(map(int, input().split()))
ans=1
for val in As:
    ans=val*ans

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

Submission status: Time Limit Exceeded

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

s = 1
ten18 = 10**18
over = False

for b in a:
  s *= b
  if s > ten18:
    #print(-1)
    over = True
  if b == 0:
    over = False
    break
  
if over:
  print(-1)
else:
  print(s)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
prod=1
arr=list(map(int,input().split()))
for i in arr:
    if i==0:
        prod=0
        break

    prod*=i

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

Submission status: Time Limit Exceeded

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

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

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:
from operator import mul
from functools import reduce
N = int(input())
a = list(map(int, input().split()))
c = reduce(mul, a)
if c > (10**18):
    print(-1)
else:
    print(reduce(mul, a))

Submission status: Time Limit Exceeded

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)
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 *= i
if ans > 10**18:
    print('-1')
else:
    print(int(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 > 1000000000000000000:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

n = 1


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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = reduce(mul, A) #結果=>120

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 a: ans*=i

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
res = 1
for i in range(N):
  res *= A[i]

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


print(res)

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
# a=int(input())
# a,b=map(int,input().split(" "))
A=[int(_) for _ in input().split(" ")]

if A[0] == 0:
    ans=0
    print(ans)
    exit()
else:
    ans=A[0]

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

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

Submission status: Time Limit Exceeded

Solution code:
input_line1 = input()
N = int(input_line1)
input_line2 = input()
numbers = input_line2.split()
num_sum = 1


for i in range(N):
    num_sum *= int(numbers[i])

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

print(num_sum)

Submission status: Time Limit Exceeded

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

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

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

ans = a[0]

for i in range(1,n):
    if a[i] == 0:
        print("0")
        exit()
    else:
        ans *= a[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()))

tmp = 1
for num in A:
    tmp *= num
if tmp <= 1e18:
    print(tmp)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
import sys
t = 10**18

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

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ln =list(map(int, input().split()))
a = 1
for i in ln:
    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()))
count = 1
for i in a:
  count *= i
if count > 1000000000000000000:
  print(-1)
else:
  print(count)