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:
a = 1
n = int(input())
b = input().split()
if '0' in b:
  print(0)
else:  
  for i in b:
      a *= int(i)
  print(a if a <= 10**18 else "-1")

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = int(input())
l = list(map(int, input().split()))
a=np.array(l, dtype='object')
x=np.prod(a)
y = -1 if x > 10**18 else x
print(y)

Submission status: Time Limit Exceeded

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


def main():
    n = int(readline().rstrip())
    aList = list(map(int, readline().rstrip().split()))
    ans = 1
    for a in aList:
        if aList.count(0) > 0:
            ans = 0
            break
        if ans * a > 10 ** 18:
            ans = -1
            break
        ans *= a
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

#n = 5
#S = [1,2,3,4,5]

ans = int(1)
#print(n)
#print(S)
#print(ans)

for i in S:
    ans = ans * i
#    print(ans)

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

Submission status: Time Limit Exceeded

Solution code:
n=eval(input())
str=input()
num=[int(n) for(n) in str.split()]
ans=1;
for i in num:
  ans*=i
if ans>=1000000000000000001:
  print(-1)
else :
  print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1
flag = True
for a in A:
    ans *= a
    if ans > 10 ** 18:
        flag = False
    else:
        flag = True

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

Submission status: Time Limit Exceeded

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

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

  if result > 10e+17:
    result = -1
    break
  
print(result)

Submission status: Time Limit Exceeded

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

sum=1

for i in range(a):
    sum = sum*li[i]

if sum <= 10**18:
    print(sum)
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 = ans * a[i]
        if ans == 0:
                break
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(n):
        ans = ans * a[i]
if ans > 10**18:
        print(-1)
else:
        print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    arr = []
    product = 1
    # while i < N:
    arr = list(map(int , input().split(' ')))

    if 0 in arr:
        print(0)
        return

    for i in arr:
        if( int(i) == 0):
            exit
        product = product * int(i)

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

main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
arr = []
product = 1
# while i < N:
arr = ((input().split(' ')))

for i in arr:
    if( int(i) == 0):
        exit
    product = product * int(i)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
arr = []
product = 1
# while i < N:
arr = ((input().split(' ')))

for i in arr:
    product = product * int(i)

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

Submission status: Time Limit Exceeded

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

# スペース区切りの整数の入力
N, *d = map(int, open(0).read().split())
A = 1

for O in d:
    A = A*O

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

print(A)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
As = map(int, input().split())
result = 1
 
for a in As:
  result *= a
  
if 0 in As:
  print(0)
elif result > 10**18:
  print(-1)
else:
  print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
As = list(map(int, input().split()))
result = 1
 
for a in As:
  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
if 0 in A:
    ans = 0
else:
    for a in A:
        ans *= a
    if ans > 1000000000000000000:
        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(N):
  ans = 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
if 0 in A:
    ans = 0
else:
    for a in A:
        ans *= a
    if ans > 10**18:
        ans = -1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
lim = 1e18
n = int(input());
nums = list(map(int,str(input()).split(" ")))
ans = 1
for num in nums:
    if num == 0:
        print(0)
        quit()
    ans *= num
if ans > lim:
    print(-1)
else:
    print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
lim = 1e18
n = int(input());
nums = list(map(int,str(input()).split(" ")))
ans = 1
for num in nums:
    ans *= num
if ans > lim:
    print(-1)
else:
    print(int(ans))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
lim = 1e18
n = int(input());
nums = list(map(int,str(input()).split(" ")))
ans = 1
for num in nums:
    ans *= num
if ans > lim:
    print(-1)
else:
    print(int(ans))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = [int(x) for x in 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
if 0 in a :
    print(0)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
def solve(n, a):
  if 0 in a:
    return 0
  else:
    p = 1
    x = 10**18
    for i in a:
      p*=i
    if p>x:
      p = -1
    return p

n = int(input())
a = [int(x) for x in input().split()]
print(solve(n, a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
i=n-1
res=1
z=10**18
while(i>=0):
    res*=a[i]
    if(a[i]>z):
        break
    i-=1
if(res>z):
    res=-1
print(res)

Submission status: Time Limit Exceeded

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

z=10**18
for i in a:
    res*=i
    if(i>z):
        break
if(res>z):
    print(-1)
else:
    print(res)

Submission status: Time Limit Exceeded

Solution code:
def main ():
  N = int(input())
  A = list(map(int,input().split()))
  prod = 1 
  
  for a in A:
    prod *= a
    
  if prod > 1000000000000000000:
    print(-1)
    return
  
  else:
    print(prod) 

main()

Submission status: Time Limit Exceeded

Solution code:
def main ():
  N = int(input())
  A = list(map(int,input().split()))
  prod = 1 
  
  for a in A:
    prod *= a
    
  if prod > 1000000000000000000:
    print(-1)
  
  else:
    print(prod) 

main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n = iinput()
a = iarr()

ans = 1
for num in a: ans *= num
if ans > 10**18: ans = -1
if 0 in a: ans = 0
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

a = list(int(i) for i in input().split(" "))

prod = 1

for i in a:
  prod *= i

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

print(prod)

Submission status: Time Limit Exceeded

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

n = int(input())
a = list(map(int, input().split()))
ans = 1
for aa in a:
    ans *= aa

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

Submission status: Time Limit Exceeded

Solution code:
n = input()
s = 1
for i  in input().split():
  s = s * int(i)

if s > 1e+18:
  print(-1)  
else:
  print(s)

Submission status: Time Limit Exceeded

Solution code:
n = input()
numbers = input()
numberList = numbers.split()
sum = 1
for x in numberList:
    sum *= int(x)

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

Submission status: Time Limit Exceeded

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

ans = 1
for i in num:
  ans *= i
  if ans > 1000000000000000000:
    ans = -1
  
if ans > 1000000000000000000:
  ans = -1
print(ans)

Submission status: Time Limit Exceeded

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

ans = 1
for i in num:
  ans *= i
if ans > 1000000000000000000:
  ans = -1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
N = int(input())
L = list(map(int,input().split()))
if(0 in L):
    print(0)
    sys.exit()
    
sum_l = 1
for x in L:
    sum_l *= x

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def multiplication2(n,a):
    acc = functools.reduce(lambda x,y:x*y, a)
    if 10**18 < acc:
        acc = -1

    return acc

if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    acc = functools.reduce(lambda x,y:x*y, a)
    if 10**18 < acc:
        acc = -1
    print(acc)
    #print(multiplication2(n,a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def multiplication2(n,a):
    acc = functools.reduce(lambda x,y:x*y, a)
    if 10**18 < acc:
        acc = -1

    return acc

if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    print(multiplication2(n,a))

Submission status: Time Limit Exceeded

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

def multiplication2(n,a):
    acc = 1
    for x in a:
        acc = x*acc
    if 10**18 < acc:
        acc = -1

    return acc

if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    print(multiplication2(n,a))

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
n, *a = map(int, open(0).read().split())
ans = reduce(lambda x, y: x*y, a, 1)
print((-1 if ans > 10**18 else ans))

Submission status: Time Limit Exceeded

Solution code:
input_num = input()
input_list = input()
 
total_pow = 1
for num in input_list.split(" "):
  total_pow *= int(num)
 
if total_pow > 10**18:
  print("-1")
else:
  print(total_pow)

Submission status: Time Limit Exceeded

Solution code:
a = []
x = 1

n = int(input())
a = input().split()

for i in range(n):
    a[i] = int(a[i])
    x = x * a[i]
    
if x <= 10**18:
    print(x)
elif x > 10**18:
    print(-1)

Submission status: Time Limit Exceeded

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

M = 1
for a in A:
    if a == 0:
        M = 0
        break
    M *= a

if M > 1000000000000000000:
    M = -1

print(M)

Submission status: Time Limit Exceeded

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

print(A)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
AS = list(map(int,input().split()))
zero=False
sum = 1
for i in range(len(AS)):
  if AS[i]==0:
    zero=True
    break
  sum = sum * AS[i]
if zero==True:
  print(0)
else:
  if sum > 10**18:
    print(-1)
  else:
    print(sum)

Submission status: Time Limit Exceeded

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

ans = 1

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

Submission status: Time Limit Exceeded

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

if 0 in a:
  print(0)
  exit()
ans = 1
for i in a:
  ans = ans*i
if ans > 10**18:
  print(-1)
  exit()
print(ans)

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 i in a:
  ans *= i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
n = int(input())


g = functools.reduce(lambda a,b : a*b,map(int,input().split()))
if g > 10**18:
    print(-1)
else:
    print(g)

Submission status: Time Limit Exceeded

Solution code:
import functools
n = int(input())
lis = list(map(int,input().split()))

g = functools.reduce(lambda a,b : a*b,lis)
if g > 10**18:
    print(-1)
else:
    print(g)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
if __name__ == "__main__":
    n = input()
    nums = input().split(' ')
    f = pow(10, 18)

    result = 1
    for i in range(int(n)):
        if str(0) in nums:
            result = 0
            break

        result = result * int(nums[i])
        if result > f:
            result = -1
            break

    print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

ans = 1

for x in l:
  ans = ans*x
  
if(ans > 1000000000000000000):
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

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

ans = 1
for i in a:
  ans *= i
  
if ans > 10**18:
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[int(o) for o in input().split()]
s=1
for _ in range(n):
    s=s*a[_]
if s>1000000000000000000: print(int(-1))
else: print(s)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [int(s) for s in input().split()]
l = 1
for s in S:
  l = l * s
if l > 10**18:
  l = -1
print(l)

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:
def main():
    n=int(input())
    aa=input().split()
    x=1
    for a in aa:
        x*=int(a)
    if x>1000000000000000000:
        print(-1)
    else:
        print(x)
main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
count = int(input())
num = list(map(int, input().split()))
ans = 1
breakFlag = False
for i in range(len(num)):
  ans = ans*num[i]
if ans > 1000000000000000000:
  ans = -1
print(ans)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    n=int(input())
    aa=map(int,input().split())
    x=1
    for a in aa:
        x*=a
    if x>1000000000000000000:
        print(-1)
    else:
        print(x)
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 *= A[i]

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
from functools import reduce 

# 標準入力から読み込み
inputs = [list(map(int, input().split())) for _ in range(2)]
inputs = inputs[1]

output = 0 if (0 in inputs) else reduce((lambda x, y: x * y), inputs)
if output > 1e18:
  output = -1

print(output)

Submission status: Time Limit Exceeded

Solution code:
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
#from fractions import *
from bisect import *
from io import BytesIO, IOBase
def vsInput():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]

#-------------------------code---------------------------#
#vsInput()

n=Int()
a=array()
ans=1
for i in a:
    ans*=i
if(ans>10**18):
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########

def resolve():
    n = ii()
    a = mi()
    res = 1
    for i in a:
        res = res * i
    print(res if res <= 10**18 else -1)

if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

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

ans = 1
thres = pow(10, 18)
for i in A:
  ans = i * ans

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
n = int(input())
li_a = list(map(int, input().split()))

if 0 in li_a:
    print(0)
    exit(0)
w = functools.reduce(lambda x, y: x * y, li_a)
if w > 10 ** 18:
    print(-1)
    exit(0)
else:
    print(w)
    exit(0)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
array=[]
array+=map(int,input().split())
flag=0
flag2=0
s=1
for m in range(len(array)):
    if array[m]==0:
        flag=1
        break
    s=s*array[m]

if flag==1:
    print("0")
elif s>10**18:
    print("-1")
else:print(s)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin, stdout
def main():  
    n = int(stdin.readline())
    ans = 1
    a = stdin.readline()
    k = a.split(' ')
    for i in k:
        ans = ans*int(i)
    if ans > 1e18:
        ans = -1
    stdout.write(str(ans)) 
  
if __name__ == "__main__": 
    main()

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

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

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

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
ans = 1
for r in range(N):
  ans *= A[r]
if ans > 1e18:
    ans = -1
print(ans)

Submission status: Time Limit Exceeded

Solution code:

N=int(input())
input = input()
split = input.split()
data=[]
for i in range(N):
    data.append(int(split[i]))

sum_1=1

for i in data:
    sum_1=sum_1*i

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
b=list(map(int,input().split()))
an=1
c=0
for m in b:
  an*=m
if(an>10**18):
  print("-1")
else:
  print(an)