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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = input()
B = input().split()

if 2 <= int(N) <= 10**5 and int(N) == len(B):
    S = int(1)
    for i in range(len(B)):
        if 0 <= int(B[i]) <=10**18:
            S *= int(B[i])
        else:
            print("choose right value")
    if S > 10**18:
        print("-1")
    else:
        print(S)
else:
    print("choose right value")

Submission status: Time Limit Exceeded

Solution code:
_ = input()
data = list(map(int, input().split()))
p = 1
for d in data:
  p *= d

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

Submission status: Time Limit Exceeded

Solution code:
import sys
n=int(input())
List=list(map(int,input().split()))
if 0 in List:
    print(0)
    sys.exit()
ans=1
for i in range(len(List)):
    ans*=List[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()))
# print(a)
ans = 1
for i in a:
    ans = ans* i

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

Submission status: Time Limit Exceeded

Solution code:
import sys

from operator import mul
from functools import reduce


def main():
  input = sys.stdin.readline
  N = int(input())
  a= tuple(map(int , input().split()))
  ans=reduce(mul, a)
  if ans > 10**18:
    print(-1)
  else:
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul
l = int(input())
x = list(map(int, input().split()))
# print(x)
result = reduce(mul, x)
if 10 ** 18 < result:
  result = -1
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 > 1e18: print("-1")
else: print(ans)

Submission status: Time Limit Exceeded

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

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

out = reduce(mul, A)

if out <= 1e18:
  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 ans > 10 ** 18:
    ans = -1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
p=list(map(int, input().split()))
i=0
ans=1
while(n>0):
	ans*=p[i]
	i+=1
	n-=1
if(ans>1000000000000000000):
		print(-1)
else:
		print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input()) 
arr = [int(x) for x in input().split()] 
newpatient = 1
total = 1
flag =0;
for x in arr:
    total*=x
    if(total>1000000000000000000):
        t=1
        flag=1;
    
if(total>1000000000000000000):
    total=-1;
    
if(flag==1 and total!=0):
    total=-1;
    
print(total)

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
b = input().split(" ")
i = 0
s = 1
while i < a :
    s = s * int(b[i])
    i = i + 1
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())
lis = list(map(int, input().split()))
 
ans = reduce(mul, lis)
 
if ans > 10**18:
    print("-1")
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N= int(input())
listA = list(map(int, input().strip().split()))
seki=1
n=0

while n<N:
  seki=seki*listA[n]
  n= n+1

if(seki>10**18):
  seki=-1

print(seki)

Submission status: Time Limit Exceeded

Solution code:

def prd():
  ans = 1
  for i in range(N):
    ans = ans*A[i]
    
  if ans > 10**18:
    print(-1)
  else:
    print(ans)
    
if __name__ == '__main__':
  N = int(input())
  A = list(map(int, input().split()))
  prd()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
At = 1
C = 0
for p in range(N) :
    C = C + A[p]

if C > 18 :
    for j in range(N) :
         At = At * A[j]

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

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

Submission status: Time Limit Exceeded

Solution code:
n = input()
del n
X = str(input())
em = 0
Return = []
for spam in range(len(X)):
    if X[spam] == " ":
        Return.append(int(X[em:spam]))
        em = spam+1
Return.append(int(X[em:]))
x = 1
for a in Return:
    x = x * a
if len(str(x-1)) >= 19:
    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 A:
    ans = ans * i
if ans > pow(10, 18):
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import operator
from functools import reduce

count = int(input())
list = list(map(int, input().split()))
sum = reduce(operator.mul, list, 1)

if sum > 1000000000000000000:
    sum = -1

print(sum)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

Max = 1000000000000000000
n = int(input())
al = [int(x) for x in input().split()]
result = functools.reduce(operator.mul, al)
if result > Max:
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
input()
lis = [int(i) for i in input().split()]
result = functools.reduce(operator.mul, lis)
if result <= 10**18:
    print(result)
else:
    print("-1")

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

if __name__ == '__main__':
    n = input()
    inputline = input()
    parsed_input = inputline.split(" ")
    total = 1
    for i in range(int(n)):
        total = total * int(parsed_input[i])

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

Submission status: Time Limit Exceeded

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

N = int(input())
A = list(map(int, input().split()))
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
input = sys.stdin.readline
input()
A = input().split()
if "0" in A:
    print(0)
    quit()
ans = 1
for a in A:
    ans*=int(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()))
a = 1
for i in li:
        a *= i
if a >= 10**18+1:
    print('-1')
else:
    print(a)

Submission status: Time Limit Exceeded

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

if m <= pow(10, 18):
    print(m)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
n = int(input())
arr = list(map(int,input().split()))
def multiply(arr):
    return reduce(lambda x, y: x * y, arr)
mul = multiply(arr)
print("-1" if mul > (10**18) else mul)

Submission status: Time Limit Exceeded

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

ret = 1
for ai in a:
  ret = ret * ai
  if ret == 0:
    ret = 0
    break
    
if ret > 10 ** 18:
  ret = -1

print( ret)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

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

s=1

m=0

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

Submission status: Time Limit Exceeded

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


for i in range(n):
    if a[i] == 0:
        lis[i+1] += 1
    lis[i+1] += lis[i]
#print(lis)
for i in range(n):
    ans *= a[i]
    if lis[-1]-lis[i+1] == 0:
        if ans > int(1e18):
            print(-1)
            exit()
print(ans)

Submission status: Time Limit Exceeded

Solution code:
s = int(input())
n = list(map(int, input().split()))
  # sys.exit()
big = 10 ** 18

ans = 1
for i in range(s):
  if (0 in n) == True:
    ans = 0
    break
  ans *= n[i]
  if ans > big:
    ans = -1
    break
  if ans == 0:
    break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

N = int(input())

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

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

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

else :
    print(result)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ls = [int(x) for x in input().split()]
if 0 in ls:
    print(0)
    exit()
res = 1
for x in ls:
    res *= x
print(res if res <= 1000000000000000000 else -1)

Submission status: Time Limit Exceeded

Solution code:
t = int(input(), 10)
prod = 1
arr = list(map(int, input().split()))
for x in arr:
    prod *= x

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

Submission status: Time Limit Exceeded

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

ans = A[0]

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

if ans != 0:
    ans_size = int(math.log10(ans) + 1)
else:
    ans_size = 1

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
limit=10**18

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

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

Submission status: Time Limit Exceeded

Solution code:
from sys import exit
n = int(input())
a = list(map(int, input().split()))
 
f = 1
for i in range(n):
    f = f*a[i]
    if 0 in a :
        print(0)
        exit()
        
    elif  f>10**18:  
        print(-1)  
        exit()

print(f)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


# N = 3
# ARR = [1000000000, 0, 9]
#
# N = 31
# ARR =  [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]

import math

def calculate(n, arr):
    res = 1
    for i in range(n):
        if arr[i] == 0:
            res = 0
            break

        if res >0 :
            a1 = math.log(res, 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:
n =int(input())
x = list(map(int, input().split()))

ans=1
for i in range(n):
  ans=ans*x[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()))
ans = 1
flag = True
for i in range(n):
  ans *= A[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()]
max=1000000000000000000
pro=1
for i in range(0,len(a)):
  pro=pro*a[i]
if(pro>max):
  print(-1)
else:
  print(pro)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in vals:
	product *= i;

if product >= 1000000000000000001:
	print(-1,end=" ")
else:
	print(product,end=" ")

Submission status: Time Limit Exceeded

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

from math import log10

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

def pows(x, n):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = ans*x
    x = x*x
    n = n >> 1 #ビットシフト
  return ans

a= pows(10,18)

if total-a>0:
    print(-1)
else:
    print(total)

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]
    if answer>10**18:
        answer=-1
if a.count(0)>0:
    answer=0
print(answer)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
xs = list(input().split())
x = 1

for i in range(N):
    x = x * int(xs[i])
if x > 10 ** 18:
    x = -1
print(x)

Submission status: Time Limit Exceeded

Solution code:
import queue
N = int(input())

q = queue.Queue()

[q.put(int(_)) for _ in input().split()]

ans = 1
for i in range(N):
    ans = ans * q.get()

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from sys import stdin
input = stdin.readline



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

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

Submission status: Time Limit Exceeded

Solution code:

def main():
    n = int(input())
    a = list(map(int,input().split()))
    temp = 1
    for n in a:
        temp *= n
    if temp > (10 ** 18):
        temp = -1
    print(temp)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
iCnt = int(input()) 
inStrArr = input().split()
kk = int(1)
for wStr in inStrArr:
 kk = kk * int(wStr)

kkLim = int(10 ** 18)

if (kk <= kkLim) :
        print(kk) 
else :
        print('-1')

Submission status: Time Limit Exceeded

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

Ans=1

flag=False

for a in A:
    Ans=Ans*a
    if 0 in A:
        if flag==False:
            print(0)
            flag=True
        break
    elif Ans > 10**18:
        if flag==False:
            print(-1)
            flag=True
            break
    else:
        pass

if Ans <= 10**18:
    if flag==False:
        print(Ans)

Submission status: Time Limit Exceeded

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

print(total)

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

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math

n = int(input())
max = 1e+18
ans = 1
a = input().split()

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

if ans > max:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

if i > 1000000000000000000:
  i = -1
print(i)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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=input()
A = list(map(int, input().split()))
B=reduce(mul,A)
if  B<= 10**18:
    print(B)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
t=int(input())
a=1
x=[int(x) for x in input().split()]
for i in range(0,t):
  	a*=x[i]
if(a>1000000000000000000):
  	print(-1,end="")
else:
	print(a,end="")

Submission status: Time Limit Exceeded

Solution code:
import sys
import math

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:
N = int(input())
A = input().split()
result = 1
line = pow(10,18)

for i in range(N):
  result *= int(A[i])
if result > line:
  result = -1

print(result)

Submission status: Time Limit Exceeded

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

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

ans = reduce(mul, 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()))
k=1
for i in l:
  k=k*i
if(k>1000000000000000000):
  print(-1)
else:
  print(k)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

ans = 1
n = int(input())
A = [int(i) for i in input().split()]
A = np.array(A,dtype='object')
ans = np.prod(A)
if ans ==0:
    print(0)
    exit()

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

if ans > 1000000000000000000:
    ans = -1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
tu = tuple(map(int,input().split()))
p = 1

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

if p > 1000000000000000000:
    print(-1)

else:
    print(p)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
nums = list(map(int,input().split()))
ans = 1
for j in nums:
    ans = ans * j
if(ans > 1000000000000000000):
    print('-1')
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
times = int(input())
nums = list(map(int, input().split()))
total = 1

for i in nums:
    total = total * i

if total < 1000000000000000001:
    print(total)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

#print(n)
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)
exit(0)

### C++と同じく、実行は、Opt + Ctl + N

'''
# -*- coding: utf-8 -*-
# get a integer
a = int(input())
# get two integers separated with half-width break
b, c = map(int, input().split())
# get a string
s = input()
# output
print('{} {}'.format(a+b+c, s))
'''

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
import math
N = int(input())
A = [int(i) for i in input().split()]
ans = functools.reduce(operator.mul, A)
if ans<= 10**18:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

for i in range(len(a)):
    if i == 0:
        answer = a[0]
    else:
        answer = answer * a[i]

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

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

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# このファイルはutf-8で書かれているため、日本語を書く場合は上の記述が必要


count_num = int( input())


text = input()


num_data = text.split(' ')

ans = 1
for i in num_data:
        ans = ans * int(i)

if ans > 1000000000000000000:
        ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

result = reduce(lambda x, y: x*y, listA)
if result > 10 ** 18:
	print(-1)
else:
	print(result)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
Atxt=input()
Ans=1
Flag=0
j=0
for i in range(N):
    B=int(Atxt.split(" ")[i])
    Ans*=B
    if (Ans==0):
        j=i+1
        break
    elif Ans>10**18:
        Flag=1
        Ans=-1
        j=i+1
        break
if Flag==1:
    for i in range(j,N):
        B=int(Atxt.split(" ")[i])
        if (B==0):
            Ans=0
            break
print(Ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
N = int(input())
A = deque(map(int, input().split()))
ans = 1
for i in range(N):
    ans *= A.pop()
if ans > 10 ** 18:
    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()))

prod = functools.partial(functools.reduce, operator.mul)
if 10 ** 18 < prod(A):
    print(-1)
else:
    print(prod(A))

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

Π = functools.partial(functools.reduce, operator.mul)

N = int(input())
s = list(map(int,input().split()))
t = Π(s)

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

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

total = 1
for n in A:
    total *= n
if total <= 10 ** 18:
    print(total)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
def main():
    #import numpy as np
    N = int(input())
    A = list(map(int,input().split()))
    #ans = int(np.prod(A))
    ans = 1
    for n in range(N):
        ans *= A[n]
    if ans > 10**18:
        print(-1)
        exit(0)
    print(ans)
main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
n_list = list(map(int, input().split()))

#n = int(input())
#n_list = list(map(int, input().split()))

multi = 1

for i in range(n):
    multi *= n_list[i]

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

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

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
alis=sorted(list(map(int,input().split())))
p=alis[0]
if p==0:
  print(0)
  exit()
for i in range(1,n):
  p*=alis[i]
  
if len(list(str(p)))>18:
  sa=list(map(int,list(str(p))))
    
  if sum(sa)!=1:
    print(-1)
    exit()
print(p)

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
numList = list(map(int, input().split()))
max = 1000000000000000000
flg = True
result = 1

for i in range(num):
    result *= numList[i]

if result > max:
    flg = False
if flg:
    print(result)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 1

nums = list(map(lambda x : int(x),input().split()))

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

from sys import stdin
input = stdin.readline


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())
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;
if ans > 0:
  ans = An[0]
  for i in range(1,n):
    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=list(map(int, input().split()))
multi_sum=1
LIMIT=1000000000000000000

if 0 not in a_list:
    for a_i in a_list:
        multi_sum*=a_i
        if multi_sum > LIMIT:
            multi_sum=-1
else:
    multi_sum=0

print(multi_sum)