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()))
over_value = 10 ** 18 + 1
total = 1
if A.count(0):
    print(0)
else:
    cnt = 0
    while cnt < len(A):
        total *= A[cnt]
        cnt += 1
        
    if total >= over_value:
        total = -1
    print(total)

Submission status: Time Limit Exceeded

Solution code:

ans=1
n=int(input())   
a=sorted(list(map(int,input().split())))
if n % 2 != 0:
    ans=a[n//2]
for i in range(0,n//2):
    ans=ans*a[i]*a[n-i-1]
if ans>10**18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

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:
N=int(input())

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

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

print(result)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

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

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

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

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

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()))
tmp = sorted(a)
M = 10**18

if 0 in a:
	print(0)
else:
	tmp = reduce(mul, a)
	if tmp > M:
		print(-1)
	else:
		print(tmp)

Submission status: Time Limit Exceeded

Solution code:
def multiplyList(myList) : 
      
    result = 1
    for x in myList: 
         result = result * x  
    return result  
      

a = 1000000000000000000
n = int(input()) 
lst = list(map(int,input().strip().split()))[:n] 

x = multiplyList(lst)
if x > a :
    print(-1)
else :
    print(x)

Submission status: Time Limit Exceeded

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

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

from operator import mul
from functools import reduce

a = reduce(mul, x)

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
t = A[0]
i = 1
while i < N:
    t *= A[i]
    i += 1
if t <= 1e18:
    print(t)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
MAX = 10 ** 18

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

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

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin


def get_result(data):
    A = data[1]
    ans = 1
    for val in A:
        ans = ans * val
    return ans if ans <= 10**18 else -1


if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)

Submission status: Time Limit Exceeded

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

ans = 1

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


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

Submission status: Time Limit Exceeded

Solution code:
from math import prod

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
limit = 1000000000000000000

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

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

if result < 0 or result > limit:
  result = -1

print(result)

Submission status: Time Limit Exceeded

Solution code:

import math


def main():
    N = int(input())
    A = [int(arg) for arg in input().split()]
    ans = 1
    for i in range(N):
        ans *= A[i]

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
n = input()
a = list(map(int, input().strip().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().strip())
array = list(map(int, input().strip().split()))
ans = 1
for i in array:
  ans *= i
if ans > 1e18:
  print(-1)
else :
  print(ans)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

if 0 in numList:
    print(0)
else:
    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:
def main():    
    t =  int(input())
    n = 1
    a = list(map(int,input().strip().split()))[:t]
    for i in range(t):
        n*=a[i]
    if n>1e18:
        print(-1)
    else:
        print(n)
        
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# Nの入力
N = int(input())

# A1,A2,..Anの入力
A = list(map(int,input().split()))
         
# A1,A2...Anの積
A_multi = 1
for a in A:
    A_multi = A_multi * a

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
num = list(map(int,input().split()))
ans = 1
limit = 1000000000000000000
for i in range(n):
  ans *= num[i]
  if ans == 0:
    break
if ans>limit:
  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 *= A[i]
    
if X > 10**18:
    print(-1)
else:
    print(X)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = input().split()
answer = 1
flag = 0
x = 10**18
for i in range(N):
  answer *= int(A[i])

check = answer/x
if ((check) >= 1) and (answer != x):
  print(-1)
else:
  print(answer)

Submission status: Time Limit Exceeded

Solution code:
import sys

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

res = 1

for i in x:
  res = res * i
  if(res > int(1e18)):
    res = -1

if 0 in x:
  print(0)
else:
  print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
LIMIT = 1000000000000000000

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

for e in A:
    answer *= e

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

sum = a[0]

for i in range(1,len(a)):
    sum = sum * a[i]
    if 0 in a:
        sum = 0
        break
    elif sum > 10**18:
        break
    


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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

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

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
res = 1
tab = [int(n) for n in input().split()]
for i in tab:
    res = res * i
if res > pow(10, 18):
  print("-1")
else:
  print(res)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
import sys

kaisu = int(input())
num = list(map(int,input().split(' ')))
val = 1
for i in range(0, kaisu):
    val = val * num[i]


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
  if (a[i] == 0):
    print(0)
    sys.exit()

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
num = [int(x) for x in input().split()]
a = 1
max = 10**18

for i in num:
  a *= i
  
a = -1 if a > max else a
print(a)

Submission status: Time Limit Exceeded

Solution code:
a=1
n=input()

s=input()
count=""
#print(len(s))
for i in range(len(s)):
  #print(i,s[i],count)
  if s[i]==" ":
    a*=int(count)
    count=""
    continue
  elif i==len(s)-1:
    if len(count)==0:
      a*=int(s[i])
    else:
      count+=s[i]
      #print("--------")
      a*=int(count)
  else:
    count+=s[i]
if a>10**18:
  print(-1)
else:
  print(a)

Submission status: Time Limit Exceeded

Solution code:
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

from operator import mul
from functools import reduce

""" Input
S = input().rstrip()
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

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

total = reduce(mul, A)
if total > 10 ** 18:
    print(-1)
else:
    print(total)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

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

Submission status: Time Limit Exceeded

Solution code:
n = input(); n=1
X = str(input())
em = 0
Return = []
for spam in range(len(X)):
    if X[spam] == " ":
        n *= int(X[em:spam])
        em = spam+1
n *= int(X[em:])
if len(str(n-1)) >= 19:
    print(-1)
else:
    print(n)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
line = input().rstrip()
N = int(line)
line = input().rstrip()
line = line.split(' ')
mult = 1

for i in range(N):
    A = int(line[i])
    mult = mult * A

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

print(mult)

Submission status: Time Limit Exceeded

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

ans = 1


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

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

else:
  print(0)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split()))
over_value = 10 ** 18 + 1
total = 1
if A.count(0):
    print(0)
else:
    for i in A:
        total *= i
    if total >= over_value:
        total = -1
    print(total)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

from functools import reduce

N = int(input())
AS = map(int, input().split())

ans = reduce(lambda a,b: a*b, list(AS))

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()))
 
result=1
for a in A:
    result=result*a
if result>10**18:
    result=-1
print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
numbers = [int(n) for n in input().split()]
mlt = 1
for n in numbers:
    mlt *= n
if mlt > 1000000000000000000:
    mlt = -1
print(mlt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

n = int(input())

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

multiplicacao = reduce((lambda x, y:x * y),numeros)

if multiplicacao > 1e18:
    print(-1)

else:
    print(multiplicacao)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

MAX = 1000000000000000000
ans = 1

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

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

n = int(input().rstrip())
nums = map(int,input().rstrip().split(' '))

ans = reduce(mul, nums)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1
t = 1e18
for i in range(n//2):
    ans *= a[i]
    ans *= a[i+n//2]

if n % 2 == 1:
    ans *= a[n-1]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

res = 1
for x in A:
    res *= x

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

Submission status: Time Limit Exceeded

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

if 0 in a:
    print(0)
    exit()

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:
res = 1
n = int(input())
k = input().split()
for a in k:
    if a == 0:
        res = 0
        break
    else:
        res *= int(a)
        if res > 1e18:
            res = -1
print(res)

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = 1
if n % 2 == 0:
    for i in range(n//2):
        ans *= a[i]
        ans *= a[len(a)-i-1]
        if a[i] == 0 or a[len(a)-i-1] == 0:
            ans = 0
            exit

if n % 2 == 1:
    for i in range(n//2):
        ans *= a[i]
        ans *= a[len(a)-i-1]
        if a[i] == 0 or a[len(a)-i-1] == 0:
            ans = 0
            exit
        
    ans *= a[len(a)//2+1]
if ans > 10**18:
    ans = -1
print(ans)

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

Submission status: Time Limit Exceeded

Solution code:
input_num = int(input())
line = input().split(" ")
output = 1
zero_flg = False
for i in range(input_num):
    if int(line[i]) == 0:
        zero_flg = True
        break
    output = output * int(line[i])
    
if zero_flg:
    print("0")
elif output > 10 ** 18:
    print("-1")
else:
    print(output)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
A = input()
x = list(map(int, input().split()))
C = 1
for b in x:
  C = C * b

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()))
ans = 1
j = 0
for i in range(n):
    ans *= a[i]
    if 0 in a:
        j += 2
        break
    if ans > 10**18:
        j += 1
        break
if j == 2:
    print(0)
elif j == 1:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:

import math


def main():
    N = int(input())
    A = [int(arg) for arg in input().split()]
    ans = 1
    for i in range(N):
        ans *= A[i]
        if ans > pow(10, 18) and i == N-1:
            ans = "-1"
            break

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
# a = int(input())
# スペース区切りの整数の入力
# b, c = map(int, input().split())
# 文字列の入力
# s = input()
# 出力
# print("{} {}".format(a+b+c, s))

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

aa =[]
aa.append(1)
for j in range(n):
    aa.append(aa[j] * a[j])

if aa[n] > 10**18:
    print(-1)
else:
    print(aa[n])

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:

count = int(input())
num = []
num = input().split()

total = 1
for i in range(count):
    if total == 0:
        break
    total = int(num[i])*total
    
if total > 10**18:
    total = -1
    
print(total)

Submission status: Time Limit Exceeded

Solution code:

N = int(input())

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



ans = 1

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

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

Submission status: Time Limit Exceeded

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

P = 1

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

n=int(input())
A=list(map(int, input().split()))
x= functools.reduce(operator.mul, A)
if x<=10**18:
    print(x)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

n = int(input())
li = [int(i) for i in input().split()]
result = functools.reduce(operator.mul, li)

if result >pow(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 a:
  ans = i * ans

if ans - (10 ** 18) > 0:
  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()))
over_value = 10 ** 18 + 1
total = functools.reduce(operator.mul, A)

if total >= over_value:
    total = -1
print(total)

Submission status: Time Limit Exceeded

Solution code:
# cook your dish here

num = int(input())
arr = list(map(int,input().split(" ")));

maxi = 1000000000000000000
val = 1;
for i in arr:
        val = val*i;

if val>maxi:
        print("-1")
else:
        print(val)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
input()
A = input().split()
ans = 1
for a in A:
    ans*=int(a)
    if ans==0:
        print(0)
        quit()
print(-1 if ans>10**18 else ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

N = int(input())
s = input().split()
k = [int(i) for i in s] 

if reduce(mul, k) <= 10**18:
    print(reduce(mul, k))
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 == 0:
  print(0)
  exit()
elif ans > 10**18:
  print(-1)
  exit()
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    if n % 2 == 1:
        a1 = a[:int((n-1)/2)]
        a2 = a[int((n-1)/2):]
    else:
        a1 = a[:int(n/2)]
        a2 = a[int(n/2):]
    res1 = 1
    res2 = 1
    for i in a1:
        res1 *= i
    for i in a2:
        res2 *= i
    res = res1 * res2
    if res <= 10 ** 18:
        print(res)
    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 i in a:
    ans *= i
print(ans if not ans > 10**18 else -1)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n = int(input())
a= input().split()
level = np.power(10, 18)
product = 1

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

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

Submission status: Time Limit Exceeded

Solution code:

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
liste = input().split()
number = [int(x) for x in liste]
# print(N,number)
total = 1
i = 0
while i < N:
    if 0 in number:
        total = 0
        break
    else:
        total *= number[i]
        i = i + 1
        if total > 10**18:
            total = -1
            break
print(total)

Submission status: Time Limit Exceeded

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

for i in vals:
	if i == 0:
		product = 0
		break
	product *= i;

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
n = input()
a = list(map(int, input().strip().split()))
ans = 1
p = pow(10, 18)
ans = functools.reduce(operator.mul, a)
if ans > p:
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul

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

if 0 in a_li:
    print(0)
    exit()

ans = reduce(mul, a_li)

if ans > 1000000000000000000:
    print(-1)
    exit()
else:
    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==0):
    break;
if(product>val):
  print(-1)
else:
  print(product)

Submission status: Time Limit Exceeded

Solution code:
s = [input() for i in range(2)] 
li = list(map(int, s[1].split()))
s0 = int(s[0])
f1 = 1
for i in range(s0):
    f1 = f1 * li[i]
if f1 > 1000000000000000000:
    print(-1)
if f1 <= 1000000000000000000:
    print(f1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
b = [int(x) for x in input().split()]
r = 1
max = 10**18

for i in b:
  r *= i
  
r = -1 if r > max else r
print(r)

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

Submission status: Time Limit Exceeded

Solution code:
# Your code here!

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

for i in range(n):
  if i == 0:
    b = c[i]
  else:
    b = b*c[i]
if b>1000000000000000000:
  b = -1
print(b)