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:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil, floor, sqrt, gcd
from copy import deepcopy


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    num = 1000000000000000000
    ans = 1
    for i in range(n):
        ans *= a_list[i]

    if ans <= num:
        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()))

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

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

Submission status: Time Limit Exceeded

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

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


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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

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

Submission status: Time Limit Exceeded

Solution code:
a=[input() for i in range(2)]

a_num=a[1]
a_num=a_num.split()

a_mul=1

for i in range(len(a_num)):
	num=int(a_num[i])
	a_mul*=num

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

print(a_mul)

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]
answer = answer if answer <= 10 ** 18 else -1
print(answer)

Submission status: Time Limit Exceeded

Solution code:
def readInt():
    return list(map(int, input().split()))

from operator import mul
from functools import reduce

n = int(input())
a = readInt()
ans = reduce(mul, a, 1)
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()))
k=1
for i in range(n):
    k*=array[i]
if k>10**18:
    print(-1)
else:
    print(k)

Submission status: Time Limit Exceeded

Solution code:
import sys

def input():
    return sys.stdin.readline().strip()

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    A = [int(value) for value in input().split(" ")]
    result = 1
    for value in A:
        result *= value
        if 0 in A:
            print(0)
            exit()
        if result>10**18:
            print(-1)
            exit()
    
    print(result)


if __name__=="__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
a = int(sys.stdin.readline().rstrip())
res = 1
val = input().split(' ')

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
k = 1
m = input()
m = m.split()
# m = list(m)
# print(m)
for i in range(n):
    # print(m[i])
    k = k*(int(m[i]))

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
flag = 1
total = 1
alist = list(map(int, input().split()))
if 0 in alist:
  total = 0
  print(total)
else:
  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())
a=list(map(int,input().split()))
result=1
for i in a:
    result*=i
if result==1000000000000000000:
    print(result)
elif 18< len(str(result)):
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in a:
    ans = ans*i
if ans > 1e18:
    print("-1")
    sys.exit()
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
L=list(int(x) for x in input().split())
sum=1
for i in range(N):
	sum=sum*L[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().strip().split()))

result = 1

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

Submission status: Time Limit Exceeded

Solution code:
# Hello World program in Python
    
n = int(input())
lst = list(map(int, input().split()))
ans = 1
for a in lst: 
    ans *= a
if(ans>1000000000000000000): 
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n= int(input())
line= input().split(' ')
 
tot=1
for a in line:
	tot*= int(a)
	if a=='0':
		tot=0
		break

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

Submission status: Time Limit Exceeded

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

tar = 1
for i in A:
    tar *= i

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

Submission status: Time Limit Exceeded

Solution code:
N = input()
AN = list(map(int, input().split()))
X = 1
T = len(AN)
for i in range(T):
    X = X*AN[i]
    
if X <= 10**18:
    print(X)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
h = input().split()

ans = 0

for i in range(num):
    if i == 0:
        ans = ans + int(h[i])
    else:
        ans = ans * int(h[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()))
B = 1
for i in range(N):
    B = B*A[i]
if B <= 10**18:
    print(B)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
#import numpy as np
import math
n = int(input())
a= list(map(int,input().split()))

ans = a[0]

for i in range(1,n):
    if a[i] == 0:
        print("0")
        exit()
    elif a[i] > 10**18:
        print("-1")
        exit()
    else:
        ans *= a[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Ans=1

for A in range(N):
    NewAns=Ans*As[A]
    Ans=NewAns
if Ans>10**18:
    Ans=-1

print(Ans)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
input=stdin.readline
a=1
n=int(input())
ar=list(map(int,input().strip().split()))
for i in ar:
    a*=i
if(a>1000000000000000000):
    print("-1")
else:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

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

num = 1
for x in a[:]:
    num *= x
    if num == 0:
        break
if 10**18 < num:
    num = -1

print(num)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

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

n = int(input())
a = list(map(int, input().split()))
res = func(a)
if res > (10**18):
    print(-1)
else:
    print(res)

Submission status: Time Limit Exceeded

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

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

for ta in a:
    ans *= ta

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

# ĺĽĺ
n = int(input())
a_list = list(map(int, input().split()))

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

num_data = sys.stdin.readlines()
str_num_list = num_data[1].split()
num_list = [int(s) for s in str_num_list]
ans = 1
for i in range(int(num_data[0])):
  ans *= num_list[i]

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

Submission status: Time Limit Exceeded

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

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

if result >= 1000000000000000001:
    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()))
b = sorted(A)
if b[0] == 0:
    ans = 0
else:
    ans  = reduce(lambda x,y : x * y, b)
if ans > 10**18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

print(-1 if ans > x else ans)

Submission status: Time Limit Exceeded

Solution code:

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

Submission status: Time Limit Exceeded

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


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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
x = list(map(int, input().split()))
t = 1
for num in x:
    t = t * num

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

Submission status: Time Limit Exceeded

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

for a in A:
    ans = ans*a

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
n = int(input())
a = [int(x) for x in input().split()]

x = reduce(lambda x, y: x*y, a)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input().rstrip())
list = input().rstrip().split(' ')
ans = 1
for i in range(n):
    ans = ans * int(list[i])

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
aa = map(int, input().split())
prod = 1
overflow = False
for i in aa:
    prod = prod * i

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
temparr = input()
temparr = temparr.split()
flag = 0 

arr = []
first = 0 
totallen = 0 
for i in  temparr:
    if first == 0 :
        totallen += len(i)
        first = 1 
    else:
        totallen += len(i) - 1 
    if totallen > 19:
        flag = 2
        break
    if "0" in temparr:
        flag = 1 
        break 

    arr.append(int(i))
if flag == 2:
    print("-1")
elif flag == 1 :
    print("0")
else:
    ans = 1
    for i in arr:
        ans *= i 
        if ans > 1000000000000000000:
            flag = 1 
            break 
    if flag == 0 :
        print(ans)
    else:
        print(-1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
total = 1;
for i in input().split():
    if i==0:
        total = 0;
        break
    total*=int(i)
if total>int(1e18):
    print(-1)
else : print(total)

Submission status: Time Limit Exceeded

Solution code:


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

    limit = 10**18
    result = 1
    for i in a:
        result *= i

    if result > limit:
        result = -1
    print(result)

main()

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

def souseki():
    N = input()
    H = list(map(int,input().split()))
    result = 1
    prod = functools.partial(functools.reduce, operator.mul)
    result = prod(H)
    if result > 10**18:
        result = -1
    print(result)
    
souseki()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in a:
    f *= i
  


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

Submission status: Time Limit Exceeded

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

ans = 1

for a in range(0,N):
	ans = ans * int(A[a])

#for a in input().split:
#	ans = ans * a


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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n= int(input())
line= input().split(' ')
 
tot=1
for a in line:
	tot*= int(a)
if tot>10**18:
	print(-1)
else:
	print(tot)

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 = reduce(mul, A)
if S > 10 ** 18:
    print("-1")
else:
    print(S)

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

else:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
#import functools

def main():
    N = int(input())
    A = [int(c) for c in input().split(' ')]
    A.sort(reverse=True)

    if A[-1] == 0:
        print('0')
        exit()
    elif A[0] > 1e18:
        print('-1')
        exit()

    ret = 1
    for x in A:
        ret = ret * x
        # if ret > 1e18:
        #     print('-1')
        #     exit()
        # elif ret == 0:
        #     print('0')
        #     exit()

    if ret == 0:
        print('0')
        exit()
    elif ret > 1e18:
        print('-1')
        exit()
    print(f'{ret}')


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul
import sys
n=int(input())
s=input().split()
if '0' in s:
  print(0)
  sys.exit()
l=map(int,s)
ans=reduce(mul, l)
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()))
s=1
for i in range(n):
  s=s*a[i]
  if s==0:
    break
if s>10**18:
  print(-1)
else:
  print(s)

Submission status: Time Limit Exceeded

Solution code:
N= int(input())
A= list(map(int,input().split()))
 
S= 1
for n in range(N):
  if A[n] == 0:
    S=0
    break
  elif S > 10**18:
    S = -1
  else:
    S *= A[n]
    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

flag_0 = False

for a_i in a:
    
    if a_i == 0:
        flag_0 = True
        break

    ans *= a_i
    
    if ans > 10**18:
        ans = -1
        
if flag_0 == True:
    print(0)
elif ans <0:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
list=input().split(" ")
ans=1
if (0 in list)==True:
    ans=0
for i in range(n):
    ans=ans*int(list[i])

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

l.sort(reverse = True)
ans = 1
for i in range(n):
    ans *= l[i]
    if ans > 10**18:
      ans = -1
      break
    if 0 in l:
      ans = 0
      break

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

f = True

a = 0 in l

b = 10**18

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:
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:
from operator import mul
from functools import reduce

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
prod = 1
a.sort()
for i in range(n):
	if a[i] == 0:
		prod = 0
		break
	else:
		prod *= a[i]
if prod > int(1e18):
	print(-1)
else:
	print (prod)

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")
else:
	print(product)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = sorted(list(map(int, input().rstrip().rsplit())))

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

    if ans == 0:
        break

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

multi = 1

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
num=int(input())
line=input().split()
line=[int(i) for i in line]

ans=1
for x in range(num):
  ans=ans*line[x]

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
As = list(map(int,input().split()))
c = int(As[0])
for x in range(N):
  if x == 0:
    continue
  c = int(c) * int(As[x])

if 1000000000000000001 <= c:
  print("-1")
else:
  print(c)

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

Submission status: Time Limit Exceeded

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

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
answer = 1
lens = int(input())
arrs = [int(x) for x in input().split()]
for x in arrs:
    answer *= x
if answer > int(10 ** 18):
    answer = -1
print(answer)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
from operator import mul
from functools import reduce

input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
l = (10 ** 18)
if 0 in a:
    print(0)
    exit()
c = reduce(mul, a)
if c > l:
    print(-1)
else:
    print(reduce(mul, a))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
t = A[0]
for i in range(1, N):
    t *=  A[i]
if t > 1e18:
    print(-1)
else:
    print(t)

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

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

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

    ans = func_A(A)
    
    if ans > 10 ** 18:
        print("-1")
    else:
        print(ans)
    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

ans = 1
can = 1
zero = 0

if 0 in a:
    zero = 1
    ans = 0

if(zero==0):
    for i in range(N):
        ans = ans * a[i]
        if(ans>1000000000000000000):
            can = 0

if(can==1):
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

if ans == 0:
  print(ans)
elif b == 1:
  print(-1)
elif ans>10**18:
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
import operator
import functools

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

ans = functools.reduce(operator.mul, num, 1)

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

Submission status: Time Limit Exceeded

Solution code:
import math
n=int(input())
b=1
a=list(map(int,input().split()))
x=1000000000000000000
for i in range(n):
    if(a[i]==0):
        print(0)
        exit(0);
    b=b*a[i]

if(b>x):
    b=-1
print(b);

Submission status: Time Limit Exceeded

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

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

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

if ans > 1000000000000000000:
  ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

def main():
    n = int(input())
    a_list = list(map(int, input().split()))

    if 0 in a_list:
        print('0')
        return

    result = 1

    for a in a_list:
        result = result * a

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

    print(result)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
se = 1
for n in range(N):
  if A[n] == 0:
    se = 0
    break
  se *= A[n]
if se >  10**18:
  print("-1")
else:
  print(se)

Submission status: Time Limit Exceeded

Solution code:
import sys
n = int(input())
a =[ [int(c) for c in l.split()] for l in sys.stdin]
a =a[0]
m = 1

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

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

Submission status: Time Limit Exceeded

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


z = 1
for i in range(0, n):
  z = z * a[i]


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

Submission status: Time Limit Exceeded

Solution code:
n = int(input()) 
  
# Below line read inputs from user using map() function  
a = list(map(int,input().strip().split()))[:n] 
ans = 1
for i in range(n):
	ans = ans * a[i]
if(ans > 1000000000000000000):
	ans = -1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

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

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

ans = multi(a)

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

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

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

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

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:
        print(0)
        exit()
    ans *= a[i]

m = 10 ** 18

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

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(f1)
if f1 > 1000000000000000000:
    print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

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