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 functools import reduce
n=int(input())
A=list(map(int,input().split()))
ans=reduce(lambda x,y:x*y,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()))
i=1
sum=A[0]
while A[0]<=10**18 and i<=N-1:
   sum*=A[i]
   i+=1
if sum>10**18:
   sum=-1
print(sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
data = input().split()
val = 1
for i in data:
  val = val * int(i)
  # print(val)
  # if val > 10**18:
  #   break

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in a:
    ans = ans*i
    if ans > 1000000000000000000:
        ans = -1
        exit
    elif ans == 0:
        exit

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
x = input()
nums = input()
num_list = list(map(int, nums.split(" ")))
max_value = 10 ** 18

ans = 1
for num in num_list:
    ans = ans * num

if ans > max_value:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())), dtype=object)

ans = np.prod(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()))

th=10**18
ans=1
flag=0
for i in a:
    if i==0:
        flag=1
        break
    ans*=i
if(flag==1):
    print(0)
elif ans<=th:
    print(ans)
else:
    print("-1")

Submission status: Time Limit Exceeded

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

result = 1

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

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

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

Submission status: Time Limit Exceeded

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

ans = As[0]

for A in As[1:]:
    ans = ans*A

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

Submission status: Time Limit Exceeded

Solution code:
count = int(input())
list = input().split(" ")
state = False
i = 0
num = int(list[i])
i += 1
limit = 10 ** 18

while i < count:
  num = num * int(list[i])   
  i += 1
if num > limit:
  print(-1)
else:
  print(num)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if(ans>1.0E+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*ans

if ans <= 1000000000000000000:
    print(ans)
    exit()

print(-1)

Submission status: Time Limit Exceeded

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

for i in range (0 , len(A)):
    a = a * A[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#B
from functools import reduce
n = int(input())
a = tuple(map(int,input().split()))
flg = True
MAX = 10 ** 18
cnt = 1
result = reduce(lambda ans, x:ans * x, a)
if result > MAX:
    flg = False
        

if flg:
    print(result)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

count = int(input())
list = list(map(int, input().split()))
sum = reduce(lambda x, y: x*y, list)


if sum > 1000000000000000000:
    sum = -1

print(sum)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

n=int(input())
array=list(map(int, input().split()))
result=functools.reduce(operator.mul,array)
if result>1000000000000000000:
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

Solution code:
#import numpy as np
N = int(input())
A = list(map(int,input().split()))
#output = np.prod(A)
AA=1
for i in range(N):
  #print(A[i])
  AA = AA * A[i]
a = pow(10,18)
print(AA if abs(AA) <= a else -1)

Submission status: Time Limit Exceeded

Solution code:
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    N = int(input())
    A = list(map(int, input().split()))

    #output
    answer = 1
    limit = pow(10, 18)

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

    if answer > limit:
        print(-1)
        exit()
    else:
        print(answer) 

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

n=int(input())
li=input().split()
li = [int(i) for i in li] 
result = (functools.reduce(operator.mul, li))
if result>10**18:
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

N = int(input())
A=list(map(int,input().split()))
s=1
if min(A) == 0:
  s = 0
elif max(A) > 10**18:
  s = -1
else:
  s = reduce(mul, A)
  if s > 10**18:
    s = -1
print(s)

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:
        ans = -1
        continue
    if a == 0:
        ans = 0
        break
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

x = functools.reduce(operator.mul, A)
y = 10**18


if x > y:
    print("-1")
else:
    print(x)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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 10 ** 18 < count:
    count = -1

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    _ = input()
    a = sorted(list(map(int, input().split())), reverse=True)
    if a[-1] == 0:
        print(0)
        return
    x = 1
    m = 10 ** 18
    for i in a:
        if i > m:
            print(-1)
            return
        if i < 2:
            continue
        x *= i
    print(-1 if x > 10 ** 18 else x)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
	import sys
	input = sys.stdin.readline
	k = int(input())
	h = tuple(map(int,input().split()))
	ans = 1
	for i in range(k):
		ans *= h[i]
	if ans <= 10 **18:
		print(ans)
	else:
		print(-1)
	
 
 
if __name__ == '__main__':
	main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
N = int(input())
A = [int(i) for i in input().split()]

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from fractions import Fraction
import numpy

n = int(input())
num = list(map(int, input().split()))
num = [ Fraction(i) for i in num ]

if 0 in num:
    print(0)
elif len([i for i in num if i >= 10**18]) != 0:
    print(-1)
else:
    mult = numpy.prod(num)
    if mult > 10**18:
        print(-1)
    else:
        print(int(mult))

Submission status: Time Limit Exceeded

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    # a = list(map(int, input().split()))
    ans = 1
    for i in  input().split():
        i = int(i)
        if i == 0:
            print(0)
            exit()
        ans *= i 
    if ans <= 1e18:
        print(ans)
    else:
        print(-1)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

f = True

a = 0 in l

b = 1000000000000000000

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

if f == True:
  print(sum)

Submission status: Time Limit Exceeded

Solution code:
_,a=open(0)
t=1
for b in a.split():t*=int(b)
print(-~t*(t<=10**18)-1)

Submission status: Time Limit Exceeded

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

result = 1
for i in range(N):
	result = result * int(a[i])

if result < 1000000000000000001 :
    print(result)
else:
	print("-1")

Submission status: Time Limit Exceeded

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

import functools
import operator

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

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

print(result)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import add, mul
N = int(input())
n = list(map(int,input().split(' ')))
ans = reduce(mul,n)
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()))

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

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

Submission status: Time Limit Exceeded

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

res = 1

for i in range(0,len(a),2):
    if i < len(a)-1:
        res = res * a[i] * a[i+1]
    else:
        res = res * a[i]

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

Submission status: Time Limit Exceeded

Solution code:
N =int(input())
L = list(map(int,input().split()))
A=1
for i in range(N):
    if 0 in L:
        print(0)
        break
    A = A * L[i]
    if i == N-1 and A <= 10**18:
        print(A)
    elif A > 10**18:
        break
if A > 10**18:
    print(-1)

Submission status: Time Limit Exceeded

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

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

if a[0] > 10 ** 18:
    print('-1')
else:
    print(a[0])

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

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

ans = 1

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

#for i in range(len(N)):
#    ans *= N[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()))
if n <= 100000:
    ans = 1
    for i in range(0, len(a)):
        ans = ans*int(a[i])

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
X = list(map(int, input().split()[0:N]))
Re = math.prod(X)
if Re > 10**18:
    print(-1)
else:
    print(Re)

Submission status: Time Limit Exceeded

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

ans = 1
flag = 0

for i in range(N):
    if A[i]== 0:
        print(0)
        exit(0)
    if len(str(ans))+len(str(A[i]))>20:
        flag = 1
    ans*=A[i]
    if ans > 1000000000000000000:
        flag = 1

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=map(int,input().split())
k=1
for s in l:
    k=s*k

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

Submission status: Time Limit Exceeded

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


input()
l = list(map(lambda x: int(x), str(input()).split(" ")))
r = 1
for i in l:
    r = r * i
if r > 10 ** 18:
    print(str(-1))
else:
    print(str(r))

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a_list = []

a_list = list(map(int,input().split()))
result = 1

for a in a_list:
    result *= a

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

Submission status: Time Limit Exceeded

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

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

if sum > 1000000000000000000:
    sum = -1

print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1
max = 1000000000000000000
for i in range(len(N)):
  ans = ans * N[i]

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

Submission status: Time Limit Exceeded

Solution code:
x1 = input()
x2 = [int(s) for s in input().strip().split(" ") ]
 
result =  1
for x in x2:
   result *= x 

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
A = int(input())
hoge=list(map(int, input().split()))
  
sum=1
i = 0
while i < A:
  sum = sum*hoge[i]
  i+=1

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

Submission status: Time Limit Exceeded

Solution code:
#coding:utf-8

N = int(input())

A = [int(i) for i in input().split()]

ans = 1

for i in A:
    ans = ans * i
    
if ans > (10 ** 18) :
    ans = -1
    

print("{}".format(ans))

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):
    s = lists[i-1]
    q *= s
import numpy as np
x =  np.power(10,18)
if q<=x:
    print(q)
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("-1")
else:
	print(x)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import functools
import operator

Π = functools.partial(functools.reduce, operator.mul)
N=int(input())
L=list(int(x) for x in input().split())
sum=(Π(L))
if sum > 10**18:
	print("-1")
else:
	print(sum)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n=int(input())
a=list(map(int,input().split()))
ans=1
for i in range(n):
    ans=ans*a[i]
if ans>10**18:
    anscheck=False
else:
    anscheck=True
print(ans if anscheck else -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())
array = list(map(int, input().split()))
ans :int = 1
i :int = 0
for i in array:
    ans *= i
if ans > 1000000000000000000:
    ans = -1
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:
import time
def main():
    N = int(input())
    A = input()
    ans = 1
    inf = 10**18
    t = time.time()

    for a in A.split():
        ans *= int(a)

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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from math import prod
N = input()
B = input().split()

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
aa = [int(x) for x in input().split()]
ans = 1
for a in aa:
    ans *= a
if ans > 1e18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
result = 1
for _a in a:
    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()))
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:
n = int(input())
a = list(map(int,input().split()))

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

if ans > 1000000000000000000:
  ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator


n=int(input())
li=input().split()
li = [int(i) for i in li] # ここでリストの中の値をint型へ変換しています。
result = (functools.reduce(operator.mul, li))
if result>10**18:
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(input().split())
ans = 1
lim = 10 ** 18


for i in range(len(A)):
    ans *= int(A[i])
if lim < ans and "0" not in A:
    print('-1')
else:
    print(ans)

# print(ans, lim)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import atexit, io, sys 
buffer = io.BytesIO() 
sys.stdout = buffer
  
# print via here 
@atexit.register 
def write(): 
    sys.__stdout__.write(buffer.getvalue())

n = raw_input()
n=int(n)
arr = [int(x) for x in raw_input().split()]
#print(arr)
ans=1
for i in range(0,n):
    ans*=arr[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()))

import numpy as np

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

a=1000_000_000_000_000_000

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input(""))
prod=1
list=(input("")).split()
for i in list:
    prod*=int(i)
if(prod>1000000000000000000):
    print(-1)
else:
    print(prod)

Submission status: Time Limit Exceeded

Solution code:

def prd():
  ans = 1
  for i in range(N):
    if A.count(0) >= 1:
      ans = 0
      break
    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:
import functools
import operator
N=int(input())
A=list(map(int,input().split()))
li = A
x = functools.reduce(operator.mul, li)
if x>1000000000000000000:
    print(-1)
else:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

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

for i in range(n//2):
    x = a[0]*a[-1]
    c = c*x
    a.pop()
    a.popleft()

if n%2 == 1:
    c = c*a[0]

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

if 0 in A:
  sum = 0
sum = 1
ans = 0
for x in A:
  sum *= x
  if sum > 1000000000000000000:
    ans = -1
  if sum == 0:
    ans = 0
    break

if ans < 0:
  print(ans)
else:
  print(sum)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=list(map(int,input().split()))
mod=1000000000000000000
ans=1
p=1
l.sort()
for i in range(0,n):
  x=l[i]
  p=p*x
  if(x==0):
    ans=0
    break
if(p>mod):
    ans=-1
if(ans!=0 and ans!=-1):
  ans=p
print(ans)

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
lst = [int(i) for i in input().split()][:num]
total= 1
for n in range(num):
    #numbers = int(input.split())
    total = total * lst[n]
if total>1000000000000000000:
    print(-1)
else :
    print(total)

Submission status: Time Limit Exceeded

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

import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)
x = prod(a)

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

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:
    if flag==False:
        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
    else:
        break


if Ans <= 10**18:
    if flag==False:
        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:
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:
N = input()
A = input().split()
total = 1
for i in range(len(A)):
	total *= int(A[i])
if (total > 10**18):
	print(-1)
else:
	print(total)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
naturenumber = input()
a = 0
na = []
for i in range (len(naturenumber)):
    if str.isdecimal(naturenumber[i]) == True:
        a = int(naturenumber[i]) + a*10
        if i+1 == len(naturenumber):
            na = na + [a]
    if str.isdecimal(naturenumber[i]) == False:
        na = na + [a]
        a = 0
result = 1
for l in range(len(na)):
    result = result * na[l]
if result > 10**18:
    result = -1
print(result)

Submission status: Time Limit Exceeded

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

result=reduce(mul,a)
if result>10**18:
  print('-1')
else:
  print(result)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
flag = False
limit = 1000000000000000000
a = [int(item) for item in input().split()]
ans = 1
for i in a:
    ans = ans*i
if(ans > limit):
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

N = int(input())
A = list(map(int, input().split()))
ans = 1
for a in A:
    if a == 0:
        print(0)
        sys.exit()
    ans *= a

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1
INF = 1000000000000000000

# for a in A:
#     ans *= a

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

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
flag0=0
flag1=0
inf=1000000000000000000

for a in A:
	ans=ans*a
	if(a==0):
		flag0=1
	if(ans>inf):
		flag1=1
	
if flag0==1:
	print(0)
elif flag1==1:
	print(-1)
else:
	print(ans)

Submission status: Time Limit Exceeded

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

N=int(input())

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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