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

Submission status: Time Limit Exceeded

Solution code:
import math
C = int(input())
Lista = list(map(int, input().split()))
ans = 0

for i in range(C):
    if i == 0:
        ans = Lista[i]
    else:
        ans = ans * Lista[i]

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

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:
n = int(input())
a = map(int, input().split())
multi = 1

for i in a:
  multi *= i

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
#-*-coding:utf-8-*-
N = int(input())
A = [int(i) for i in input().split()]

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

res = A[0]



for i in range(N-1):
    res = res*A[i+1]
    if res > 10**18:
        res = -1

if 0 in A:
    res = 0

print(res)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)
N=int(input())
risuto=list(map(int,input().split()))
ans=prod(risuto)

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

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 == 10**18:
    print(sum)
elif sum != 0 and log10(sum) >= 18:
    print(-1)
else:
    print(sum)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce
n = input()
l = (int(e) for e in input().split(" "))
res = 1
res = reduce(mul,l)
if res > 1e+18:
    print("-1")
else:
    print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
#N, K = map(int, input().split())
# 文字列の入力
N = int(input())
#開業されたN個要素を受け付ける
#input_list = [int(input()) for i in range(N)]
input_list = list(map(int, input().split()))
ans = 1
#print(input_list)
#print( 0 in input_list)
if (0 in input_list):
    ans = 0
else:
    for input in input_list:
        ans = ans*input
        if ans > 1000000000000000000:
            ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
flag = 1
total = 1
alist = list(map(int, input().split()))

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

Submission status: Time Limit Exceeded

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

for j in data:
    sum *= j
if sum > 10 ** 18:
    print(-1)
else:
    print(sum)

Submission status: Time Limit Exceeded

Solution code:
from itertools import accumulate
from operator import add, mul
import sys 
input = sys.stdin.readline


n = int(input())

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


b = accumulate(a, mul)

c = list(b)


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

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 math
n = int(input())

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

prod = math.prod(l)
if prod > 10**18:
	print(-1)
else:
	print(prod)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N=int(input())


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

sum=a[0]

for i in range(1,N):
    sum = sum*a[i]

if sum<=1000000000000000000:
    print(sum)
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 *= A[i]
if x <= 10**18:
    print(x)
else:
    print("-1")

Submission status: Time Limit Exceeded

Solution code:
import math
def multiplyList(myList) : 
    result = 1
    for x in myList: 
         result = result * x  
    return result 
n=int(input())
l1=list(map(int,input().split()))
a=multiplyList(l1)
if a>10**18:
  print("-1")
else:
  print(a)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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 0 in A:
        print(0)
        exit()

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

print(x)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# cook your dish here
n=int(input())
arr=input().split(" ")

sum=1
for i in arr:
    sum=sum*int(i)

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

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:
n = int(input())
a = list(map(int, input().split()))
#print(a)
import functools
import operator

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

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    ans = 1
    for a in A:
        ans *= a
    if ans > L:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    N = int(input())
    A = [int(a) for a in input().split()]
    L = 10**18
    main()

Submission status: Time Limit Exceeded

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

f = True

a = 0 in l

for i in range(1,n):
  sum *= l[i]
  if sum > 10**18 and a==False:
    print(-1)
    f = False
    break

if f == True:
  print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

def main():

    test = int(input())
    inp = input().split(' ')

    p=1;
    for x in inp:
        p = p*int(x)
    
    if(p>10**18):
        print(-1);
    else:
        print(p);

        
        

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

ans = 1


for i in range(len(a)):
    if 0 in a:
        ans =0
        break
    ans = ans * a[i]
    if ans >10**18:
        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()))

k = 0
for i in range(N):
  if A[i] == 0:
    k = 1
  elif A[i] != 0 and A[i] > 10**18:
    k = 2
  else:
    k = 3

if k == 1:
  print(0)
elif k == 2:
  print(-1)
else:
  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:
import sys, io, os, re
import bisect
from pprint import pprint
from math import sin, cos, pi, radians, sqrt
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce

def array1(n): return [0] * n
def array2(n, m): return [[0] * m for x in range(n)]
def array3(n, m, l): return [[[0] * l for y in xrange(m)] for x in xrange(n)]

a = sys.stdin.readline().strip()
arr = map(int, sys.stdin.readline().strip().split())
mod = 10**18
x = reduce(lambda x, y: (x*y) if x*y <= mod else -1, arr)

print(x)

Submission status: Time Limit Exceeded

Solution code:
import math

A = 1
N = int(input())
array = input().split()
for i in range(N):
	A = (A * int(array[i]))
if A > math.pow(10,18):
	print(-1)
else:
  print(A)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

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

prod = functools.partial(functools.reduce, operator.mul)
ans = prod(A_list)

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=[int(i) for i in input().split(" ")]
mul=1
for a in A:
    mul*=a

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(val)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

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


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort()
mat = 1
upper = pow(10,18)
fl=1
for i in A:
    if i==0:
        fl=2
        break
    mat = mat * i
    if mat > upper:
        fl=3
if fl==2:
    print(0)
elif fl==3:
    print(-1)
else:
    print(mat)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
vals = list(map(lambda v: int(v), input().split()))
i = 0
sum = 1

while (i < len(vals)):
  sum = sum * vals[i]
  i = i + 1

if (sum > 10e17):
  print(-1)
  exit()

print(sum)

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
b = input().split()
c = 1
for i in range(a):
    c = c*int(b[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()))

MAX = pow(10, 18)

ans = A[0]


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

if ans > MAX:
    ans = -1

print(str(ans))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = input()
H = list(map(int,input().split())) 
result = 1

import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)
result = prod(H)
if result > 10**18:
    result = -1
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]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:


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

ans = reduce(mul,li)

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
list_a=list(map(int, input().split()))
result=1
for a in list_a:
  result = result*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()))
INF = 1000000000000000000
ans = 1
flag = 0

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

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

Submission status: Time Limit Exceeded

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

if(N%2==0):
    for i in range(int(N/2)):
        ans *= (A[i]*A[N-1-i])
else:
    for i in range(int(N/2)):
        ans *= A[i]*A[N-1-i]
    ans*=A[int((N-1)/2)]

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

Submission status: Time Limit Exceeded

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

result = As[0]
for i in range(n-1):
    result = result*As[i+1]

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

Submission status: Time Limit Exceeded

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

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

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

    if ans > pow(10,18):
        f = 1

if f == 1:
    print(-1)
else:
    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)
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=list(map(int, input().split()))
multi_sum=1
LIMIT=10**18

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
temp1 = input()
n = int(temp1)

temp2 = input().split(" ")

nums = [int(a) for a in temp2]


temp = nums[0]

limit = pow(10, 18)

for i in range(1, n):
    temp = temp * nums[i]

if temp <= limit:
    print(temp)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

import sys

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
N=int(input())
ans=1
numbers=input().split()
for j in range(N):
  num=int(numbers[j])
  ans=ans*num
  if ans==0:
    print(0)
    sys.exit()
if ans>1000000000000000000:
  print(-1)
  sys.exit()
print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
for i in A:
    if ans != 0:
        ans = ans * i
    else:
        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()))
x=1
for i in A:
  x*=i
if x>1000000000000000000:
  print('-1')
else:
  print(x)

Submission status: Time Limit Exceeded

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

res = 1
for i in range(n):
    res *= al[i]
    
if res > 10**18:
    print(-1)
    exit()

else:        
    print(res)

Submission status: Time Limit Exceeded

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

if sum>1000000000000000000:
    sum = -1

print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
line = input()

a_list = [0 for i in range(n)]
a_list = line.split(" ")
a_list = [int(a) for a in a_list]

ans = 1

for a in a_list:
    ans = ans * a
    if 0 in a_list:
        ans = 0
        break
    elif ans > 10 ** 18:
        ans = -1
        break

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

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

result = functools.reduce(operator.mul, a)
if result > 1000000000000000000:
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N = int(input())
As = list(map(lambda x: int(x), input().split(" ")))

LIMIT = 10**18

# result = np.prod(As)
#
# if result > LIMIT:
#     print(-1)
# else:
#     print(result)

result = 1
for a in As:
    result *= a
    # if result > LIMIT:
    #     result = -1
    #     break

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce
n = input()
l = [int(e) for e in input().split(" ")]
res = 1
res = reduce(mul,l)
if res > 1e+18:
    print("-1")
else:
    print(res)

Submission status: Time Limit Exceeded

Solution code:
from operator import add,mul,sub,truediv,floordiv
from functools import reduce

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

mul = reduce(lambda x,y:x*y, A)
if mul > 10**18:
    print('-1')
else:
    print(mul)

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

#print (N)

ans=1

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

#print (a)

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
input_int = [*map(int, input().split(" "))]
result = 1
for i in input_int:
  result *= i
if result > 1e+18:
  result = -1
print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
up = int("1"+"0"*18)

a = list(map(int, input().split()))
ans = a[0]

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

    if (ans > up):
        ans = -1
        break

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

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

else:
    print(p)

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
numbers = input().split()
n =[]
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:
N = int(input())
A = list(map(int, input().split()))
Ans = 1

for num in range(N):
    if A[num] == 0:
        print('0')
        exit()

    Ans = Ans * A[num]

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

else:
    print(Ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul


n = input()

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

res = reduce(mul, a)

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

else:
    print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = l[0]

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

if ans >= 1000000000000000001:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

N = int(input())
n_list = a = list(map(int,input().split()))
result = functools.reduce(operator.mul, n_list)
if result > 10 ** 18:
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N=int(input())
A = input().split()
ans=1
for i in range(N):
    ans=ans*int(A[i])
if ans<=10**18:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
#B
N = int(input())
A = input().split()
multi= 1
for i in range(N):
    multi *= int(A[i])
if multi > 10**18:
        print(-1)
else:
    print(multi)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

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

M=reduce(mul, A)

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

Submission status: Time Limit Exceeded

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

result = 1

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

Submission status: Time Limit Exceeded

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

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 i in range(N):
    ans*= A[i]

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



print(ans)

Submission status: Time Limit Exceeded

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

n = int(input())
s_li = input().split()
num = list(map(int, s_li))

product = 1

for i in range(n):
    product = product * num[i-1]

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

Submission status: Time Limit Exceeded

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

answer = 1
for i in range(N):
    answer = answer * v[i]

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# B

N = int(input())
AN = list(map(int, input().split()))
ans = 1
for A in AN:
    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()))
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 = 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:
a=int(input())
b=list(map(int,input().split()))
c=1
for i in range(a):
    c=c*b[i]
if c>10**18:
    print(-1)
else:
    print(c)

Submission status: Time Limit Exceeded

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

    pre=score

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N=int(input())


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

sum=a[0]

for i in range(1,N):
    sum = sum*a[i]

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

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = input()
a = A.split()
sum = 1
for i in range(N):
    sum *= int(a[i])
if sum > 10**18:
    print(-1)
else:
    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]
    
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 ans > 10 ** 18:
    print(-1)
else:
    print(ans)