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

import sys
sum = 1
for i in a:
    if i == 0:
        print(0)
        sys.exit()
    else:
        sum *= i

if len(str(sum)) > 19:
    print(-1)
elif len(str(sum)) == 19 and sum != 10 ** 18:
    print(-1)
else:
    print(sum)

Submission status: Time Limit Exceeded

Solution code:
from math import *

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def main():
    a = cino()
    l = cina()
    ans = prod(l)
    # print(ans)
    if ans>1000000000000000000:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

a = list(input().split())
a = [int(i) for i in a]
ans=1

if len(a) % 2 == 1: 
  for i in range(1, int(len(a)/2)+2):
    if i == int(len(a)/i) + 1:
      ans = ans*a[i-1]
    else:
      ans = ans*a[i-1]*a[-1*i]
else:
  for i in range(0, int(len(a)/2)):
    ans = ans*a[i]*a[-1 - i]

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(map(int,input().split()))
ans=functools.reduce(operator.mul, a)

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

Submission status: Time Limit Exceeded

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

def multiply(x,y):
    return x * y

for item in it.accumulate(A,multiply):
    bomb = item

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

N = int(input())
As = [int(n) for n in input().split()]

limit = 10**18

prod = 1
over = False
for A in As:
    prod *= A
    if prod == 0:
        print(0)
        sys.exit(0)
    if prod > limit:
        over = True

if over:
    print(-1)
else:
    print(prod)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = int(1)
s = str(input())
ls = list(s.split())
for i in ls:
    x = int(i)
    ans *= x
    if ans > 1e18:
        ans = -1
    if ans == 0:
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math

N = int(input())

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

sum0 = 1

for n in range(0,N):
    sum0 = sum0 * str_list[n]
if sum0 > 10**18:
    print(-1)
else:
    print(sum0)

Submission status: Time Limit Exceeded

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

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

product = 1

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

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

Submission status: Time Limit Exceeded

Solution code:
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,heapify
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 a_list:
        ans *= i

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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

for i in range(n):
    ans *= lis[i]
if ans>=1000000000000000001:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
a=input()
b=input().split(" ")
sum1=1

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
numlist = list(map(int, input().split()))
if 0 < numlist.count(0):
    print('0')
    quit()

total = 1
for i in numlist:
  total *= i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

n = int(input())
h = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
#一行で入力された数値をリストに

ans = 1

for i in h:
    ans *= i

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

Submission status: Time Limit Exceeded

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

r= reduce((lambda x, y: x * y), a) 
if r>(10**18):
    print("-1")
else:
    print(r)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
num = input().rstrip().split()
total = 1
for i in range(n):
    total = total * int(num[i])
if total > 10 ** 18:
    print("-1")
else:
    print(total)

Submission status: Time Limit Exceeded

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

j = 1000000000000000000

ans = 1

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

if ans <= j:
    print(ans)
    quit()
else :
    print('-1')
    quit()

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
a = list(map(int, input().split()))
res = math.prod(a)
if res > 1e18:
    print(-1)
else:
    print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

m=li[0]
for i in range(1,N):
  m=m*li[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()))

ans = A[0]
for i in range(N-1):
	ans *= A[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()))
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:
n = int(input())
a = list(map(int,input().split()))
from operator import mul
from functools import reduce
ans = (reduce(mul,a))

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = []
a = list(map(int, input().split()))
total = 1
for num in a:
    total *= num
if total > 10**18:
    total = -1

print(total)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
import math
n = int(input())
a = list(map(int,input().split()))

ans = 10**18
prod = 1
for i in range(n):
    prod *= a[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [0]*n
a = input().split()
sum = int(a[0])
for k in range(len(a)-1):
  sum =sum*int(a[k+1])
if sum >1000000000000000000:
  print(-1)
else:
  print(sum)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
def chn(c):
	tot=1
	for i in range(len(c)):
		if c[i]==0:
			return 0
		
		tot=tot*c[i]
		
	if tot>pow(10,18):
		return -1
	return tot


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

print(chn(c))

Submission status: Time Limit Exceeded

Solution code:
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
from collections import deque


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
	
def count_str(m):
	tmp={}
	for i in range(10):
		if i in tmp:
			tmp[i]=1
		else:
			tmp[i]+=1
	return tmp

def is_prime(n):
	if n==1: return True

	for i in range(2,int(math.sqrt(n))+1):
		if n%i==0:
			return False
	return True


n=input1()
A=input_array()
if n>10**5:
	sys.exit()
ans=1
flag=True
for a in A:
	if a > 10**18:
		sys.exit()
	ans=ans*a

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()))
mx = 1E18
ans = 1 ;
for i in range(0, n) :
    ans *= x[i]
if ans > mx :
    print(-1)
else :
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())
numbers = input().split()
numbers = [int(i) for i in numbers]
res = math.prod(numbers)
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
j = 0
for a in A:
  ans = ans*a
  if(a == 0):
    j -= 100 
    break
  if(ans > 10**18):
    j = 1
    
if(j <= 0):
  print(ans)
else:
  print(-1)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

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

if N%2 == 1:
    ans_right = A.pop()
else:
    ans_right = 1

ans_left = 1

for i in range(N//2):
    right = A.pop()
    left = A.popleft()
    if right==0 or left==0:
        print(0)
        exit();
    
    ans_right = ans_right * right
    ans_left = ans_left * left


if ans_left*ans_right > 10**18:
        print(-1)
        exit();
else:
    print(ans_right*ans_left)

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

N = int(input())
A = list(map(int, input().split()))
r = 10**18
ans = reduce(mul, A)

if ans > r:
  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 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 = input().split(" ")
K = 1

for i in A:
    if "0" in A:
        K = 0
        print(0)
        break
    K *= int(i)
    if K > 10**18:
        print(-1)
        break
if K <= 10**18 and K != 0:
    print(K)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
num = 1
c=list(map(int, input().split()))
for i in c:
    num *= i
if num > 1000000000000000000:
    print("-1")
else:
    print(num)

Submission status: Time Limit Exceeded

Solution code:
import operator
from functools import reduce

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

    ans = reduce(operator.mul, A, 1)
    
    if ans > 10 ** 18:
        print("-1")
    else:
        print(ans)
    
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import functools
import operator

N = int(input())
A = [int(x) for x in input().split()]
prod = functools.partial(functools.reduce, operator.mul)


sum = prod(A)

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

Submission status: Time Limit Exceeded

Solution code:

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

ans = 1
flag = 1
flag2 = 0

for d in data:
  if d == 0:
    flag2 = 1

for d in data:
  ans = ans * d
  if ans > 1e18:
    flag = 0

if(flag2):
  print(0)
elif(flag):
  print(ans)
else:
  print(-1)

Submission status: Time Limit Exceeded

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

import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)

def acinput():
    return list(map(int, input().split(" ")))


N=input()
a=sorted(acinput())

res=1

for sa in a:
    res*=sa
    if res>10**18:
        res=-1
        
    
print(res)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
n = input()
data = map(int, sys.stdin.readline().split())

ans = 1

over=False
zero=False
for num in data:
    ans*=num
    if(ans>1000000000000000000):
        over=True
    if(num == 0):
        zero=True

if ans>1000000000000000000:
    over=True

if zero:
    print("0")
elif over:
    print("-1")
else:
    print(ans)

Submission status: Time Limit Exceeded

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

import functools
import operator

from functools import reduce

r=reduce(lambda a,b:a*b,a)

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

Submission status: Time Limit Exceeded

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

ans = 1
if 0 in input_line:
    print(0)
else :
    for i in input_line:
        ans = ans * i
    if ans <= 10 ** 18 :
        print(ans)
    else :
        print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
a = int(input())
b = list(map(int,input().split()))

n = 1
m = 1

aa = a/2

if a%2 == 1:
    aa = (aa*2+1)//2

for i in range(int(aa)):
  n = n * b[i]
  
  
for i in range(int(aa),a):
    m *= b[i]
    

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

Submission status: Time Limit Exceeded

Solution code:
MAX = 10**18

n = int(input())
a = [int(i) for i in input().split()]
ans = 1
for i in a:
    ans *= i
print(-1 if ans > MAX else ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a= input().split()
level = 1000000000000000000
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=int(input())
L=list(map(int, input().split()))
ans=1
if "0" in L:
  print("0")
  exit()
else:
  for i in range(N):
    ans=ans*L[i]
print(ans if ans<=10**18 else "-1")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
op = 1
p = list(map(int,input().split()))
for i in p:
    op = op*i

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

Submission status: Time Limit Exceeded

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

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import functools
import operator

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

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

val = prod2(nums)

if val > 1e18:
    val = -1

print(val)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
li = list(map(int,input().split()))
mul = 1
for i in li:
  mul *= i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
N=int(input())
A=[int(x) for x 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:
n = int(input())

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

a=int(input())
b=list(map(int,input().split()))
c = functools.reduce(operator.mul, 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
for i in range(N):
    ans=ans*A[i]
if ans>1e+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):
    num = A[i]
    ans *= num

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
largenum = 10**18
def main():
    n = int(input())
    a = list(map(int, input().split()))

    r = 1
    for i1 in range(n):
        r *= a[i1]
    if r > largenum:
        print('-1')
        sys.exit()
    else:
        print(r)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:

from operator import mul
from functools import reduce
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    limit = 10**18

    _prod = reduce(mul, A)
    if _prod <= limit:
        print(_prod)
    else:
        print(-1)

if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

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

ans = reduce(mul, li)
if ans <= 10 ** 18:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
tmp = 1
dat = input().split(" ")
for d in dat:
    tmp *= int(d)

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
n=int(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())
import  functools
import operator
prod=functools.partial(functools.reduce, operator.mul)

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

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

ans = A[0];
for i in A[1::]:
    ans = ans * i

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A_ls = list(map(int, input().split()))
mul = 1

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

Submission status: Time Limit Exceeded

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

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

ans = 1
list.sort(a, reverse = True)
for i in range(len(a)):
    if 0 in a:
        ans =0
        break

    ans = ans * a[i]
    if ans >10**18:
        break


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

Submission status: Time Limit Exceeded

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

if 0 in numbers:
  print("0")
else:
 result=1
 for n in numbers:
    result *= n
 if result > 10**18:
  result = -1
 print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

arr=[int(i) for i in input().split(' ')]
prod=1
kill=0
for j in arr:
    prod=prod*j


if prod>1000000000000000000:
    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 (0, N):
	if A[i] == 0:
		ans = 0
	else:
		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()))

s=1

for i in a :
    s *= i

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = list(map(int,input().split()))
A.sort()
an = 1
for i in A:
    an *=i
    if an >10**18:
        an = -1

print(an)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

import functools
import operator


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

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

Submission status: Time Limit Exceeded

Solution code:
input()
a = map(int, input().split())
ans = 1
from functools import reduce
from operator import mul
ans = reduce(mul, a)
if(ans > 10 ** 18):
    ans = -1
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)
    result = -1 if result > 10**18 else result
        
    print(result)
    
souseki()

Submission status: Time Limit Exceeded

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

thre = 10**18

a.sort()
#print(a)

tmp = a[0]
if(tmp==0):
  print(0)
else:
  for i in range(1,n):
    tmp*= a[i]
  if(tmp > thre):
    print(-1)
  else:
    print(tmp)

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul

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

ans = reduce(mul,a)

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

Submission status: Time Limit Exceeded

Solution code:
input_number = int(input())
int_list = list(map(int, input().split()))

ans = int_list[0]
for i in int_list[1:]:
    ans = ans * i

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

Submission status: Time Limit Exceeded

Solution code:

N = int(input())
rvalue = 1
s = input()
s = s.split()
for i in range(N):
    rvalue*=int(s[i])
if rvalue > 1e18:
    print(-1)
else:
    print(rvalue)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

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

Π = functools.partial(functools.reduce, operator.mul)
if Π(A) > 10 ** 18:
    print(-1)
else:
    print(Π(A))

'''

if len(A) == 2:
    ans = A[0] * A[1]
    if ans > 10 ** 18:
        print(-1)
    else:
        print(ans)
else:
    ans = np.prod(A)
    if ans > 10 ** 18:
        print(-1)
    else:
        print(ans)
'''

Submission status: Time Limit Exceeded

Solution code:
input()
input2 = input()
A_list = [int(digit) for digit in input2.split(" ")]
product = 1
for A in A_list:
  product *= A
 
if product > 10 ** 18:
  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 a:
    ans*=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()))

sum = 1
i = 0
while i < n:
  sum *= a[i]
  i += 1

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

if t > 1e18:
  t = -1

print(t)

Submission status: Time Limit Exceeded

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

m = 1
for n in num_list:
  m = m * n
  
if(m <= 1e+18):
  print(m)
else:
  print(-1)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = input().split()
result = 1
for i in range(N):
	result = result * int(a[i])

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
an = map(int, input().split())
num = 1
num = 1
for i in an:
    num *= i
    if (i == 0):
        num = 0
        break
    
if num > 10**18:
    print(-1)
else:
    print(num)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
check = 10**18
ans = a[0]

for  i in range(1,n):
    ans = ans * a[i]
if ans <= check:
    print(ans)
else:
    print('-1')

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())
numbers = input().split()
res = 1
for i in range(0, n):
    numbers[i] = int(numbers[i])
res = math.prod(numbers)
if res > 10**18:
    print(-1)
else:
    print(res)

Submission status: Time Limit Exceeded

Solution code:
import functools
n = input()
As = list(map(int,input().split()))
out = functools.reduce(lambda a,b:a*b,As,1)
if out > 10**18:
    print(-1)
else:
    print(out)