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())
L = list(map(int,input().split()))
A=1
for i in range(N):
    A = A * L[i]
    if i == N-1 and A <= 10**18:
        print(A)
if A > 10**18:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    if 0 in inlis:
        ans = 0
    else:
        ans = 1
    for i in inlis:
        ans *= i
        #print(ans)
        if ans > 10 ** 18:
            ans = -1
    print(ans)
    
 
 
 
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    A_list = list(map(int, input().split()))

    ans = 1
    for i in A_list:
        ans *= i
        if 1000000000000000000 < ans and 0 not in set(A_list):
            print('-1')
            exit()
        elif ans == 0:
            print(0)
            exit()
    else:
        print(ans)


main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split()))
import numpy as np
B = np.array(A,dtype='object')
ans = np.cumprod(B)
if int(ans[N-1]) > 10**18:
    print(-1)
else:
    print(int(ans[N-1]))

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
Aj = list(map(int, input().split()))
Aj_coll = collections.Counter(Aj)
ans = 1
for k, v in Aj_coll.items():
	ans *= k**v
if ans > 10**18:
	ans = -1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce
n = input()
tmp = input().split(" ")
l = (int(e) for e in tmp)
res = 1
res = reduce(mul,l)
if res > 1e+18:
    print("-1")
else:
    print(res)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
A=list(map(int,input().split()))
from collections import deque
q=deque(A)

ans=1
while len(q)>0:
    p=q.popleft()
    ans=ans*p
if ans>1000000000000000000:
    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:
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())), dtype=np.object)

# X = 1
# Y = 1
# Z = 1
# L = len(A)
#
# if L%2 == 0:
#     for i in range(int(math.floor(L/2))):
#         X = X * A[i]
#         Y = Y * A[-1 - i]
# else:
#     Z = A[int(math.floor(L/2)) + 1]
#     for i in range(int(math.floor(L/2))):
#         X = X * A[i]
#         Y = Y * A[-1 - i]
#
#     # for i, b in enumerate(A):
#     #     if i == 0:
#     #         X = b
#     #     else:
#     #         X = X * b

if A.prod() > 1000000000000000000:
    print('-1')
else:
    print(A.prod())

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 = reduce(mul, a)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
mx = 1000000000000000000

n = int(input())
arr = list(map(int, input().split()))
ans = 1
for ele in arr :
	ans = ans * ele
if (ans > mx) :
	print(-1)
else :
	print(ans)

Submission status: Time Limit Exceeded

Solution code:
over = 10**18

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

for i in range(n):
  if a[i] == 0:
    ans = 0
if not ans == 0:
  for i in range(n):
    ans = ans * a[i]
    if ans > over:
      ans = -1
if ans < 0:
  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>(1000000000000000000)):
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import operator
from functools import reduce
N=int(input())
A=[]
A=(int(x) for x in input().split())
ans=reduce(lambda x,y:x*y,A)
if ans<=10**18:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

v = np.array(a, dtype=object)
ans = np.prod(v)
if ans > 10**18:
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    a = list( map( int, input().split()))
    sum = 1
    for i in a:
        sum *= i
    if sum - 1000000000000000000 > 0:
        print(-1)
    else:
       print(sum)
    
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n=input()
l=input().split()
ans = 1
for x in l:
    ans*=int(x)
if ans>10**18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
num = int(input())
s = list(map(int,input().split()))
res = 1
for i in s:
    res *= i
    
if res <= 10 ** 18:    
    print(res)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
sub = input()
input = input().split(" ")
nl = list()
for ele in input:
  nl.append(int(ele))
def multiplyList(myList) : 
    result = 1
    for x in myList: 
         result = result * x  
    return result
res = multiplyList(nl)
if res > 1000000000000000000:
  print("-1")
else:
  print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
A = int(input())
hoge=list(map(int, input().split()))
  
sum=1
for i in range(A):
  sum = sum*hoge[i]

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
#print(a)
import functools
import operator

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


def multiplyList(myList):
    if int(reduce(lambda x, y: x*y, myList)) <= 1000000000000000000:
        return reduce(lambda x, y: x*y, myList)
    else:
        return -1

print(multiplyList(n))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

fuga = int(input())
arr = list(map(int, input().split()))

hoge =1
for num in arr:
    hoge = hoge*num

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

Submission status: Time Limit Exceeded

Solution code:
# import numpy as np

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

result = 1

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

# result = np.prod(a)

if result > pow(10, 18):
    result = -1

print(result)

Submission status: Time Limit Exceeded

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

s = 1
for i in mlist:
    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().strip().split()))[:n] 
flag=1
for i in a:
	if i==0:
		flag=0;
prod=1
if (flag==0):
	print(0)
else:
	for i in a:
		prod = prod*i
		if prod>1000000000000000000:
			flag=0
	if (flag==0):
		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 *= a[i]
    
if(ans > 1000000000000000000):
    print(-1)
    
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
input()
a = list(map(int, input().split()))
ans = 1
flag = False
for i in a:
    ans *= i
if ans<1000000000000000001:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np
n=int(input())
List=list(map(int,input().split()))
List=np.array(List)
if 0 in List:
    print(0)
    sys.exit()
ans=1
for i in List:
    ans*=int(i)
if ans<=10**18:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

ans = 1
for i in A_list:
    ans *= i
    if 1000000000000000000 < ans and 0 not in set(A_list):
        print('-1')
        exit()
    elif ans == 0:
        print(0)
        exit()
else:
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
li = list(map(int,input().split()))
result = 1
i = 0
while i < N:
  result = result * li[i]
  i = i + 1

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    n = II()
    A = LI()
    # th = pow(10, 18)
    ans = 1
    for a in A:
        ans *= a
        # print(a, ans)
        # if ans > th:
        #     print(-1)
        #     return
    if ans > 1_000_000_000_000_000_000:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
result = 1
checker =False
for j in a:
  if j > 1000000000000000000:
    result = -1
    checker =True
if 0 in a:
  result = 0
  checker=True
while checker==False:
  for i in range(len(a)):
    result = result*a[i]
  checker = True
    

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

    maks = 10**18
    mnozenje = 1
    for i in a:
        mnozenje *= int(i)

    if mnozenje > maks:
        print(-1)
    else:
        print(mnozenje)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

m = functools.reduce(operator.mul, a)
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())) 
a.sort
p = True
ans = 1 
for i in a : 
  ans *= i 
  if(ans == 0) : 
    print(0)
    p = False 
    break 
if p:
  if ans > 10 **18 : 
    print(-1)
  else:
    print(ans)

Submission status: Time Limit Exceeded

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

if a > 10**18:
  a = -1
    # break
 
print(a)

Submission status: Time Limit Exceeded

Solution code:
def main():
    import functools
    import operator
    n = int(input())
    inlis = list(map(int, input().split()))
    ans = functools.reduce(operator.mul, inlis)
    if ans > 10 ** 18:
        ans = -1
    print(ans)
    
 
 
 
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
from operator import add, mul, sub, truediv, floordiv
from functools import reduce
N = input()
listA = map(int, input().split())
ans = reduce(lambda x, y: x*y, listA)

if(ans>1.0E+18):
    print("-1")
else:
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for a in A:
    product *= a

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

Submission status: Time Limit Exceeded

Solution code:
import sys
 
def input():
    return sys.stdin.readline().strip()
 
n = int(input())
A = list(map(int, input().split()))
sum = 1
for i in range(n):
    sum *= A[i]
if(sum > 10**18):
    sum = -1
print(sum)

Submission status: Time Limit Exceeded

Solution code:
c = int(1)
N = int(input()) #1行目のNを取得する
i = list(map(int, input().split())) #i_1 i_2を取得し、iに値を入れる
for k in range(N):
    c*=i[k]
if c>10**18:
    print('-1')
else:
    print(c)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

a = [int(x) for x in input().split(" ")]
ans = 1
fail = False
zero = False
for i in range(N):
	ans*=a[i]
	if(ans>1000000000000000000 or ans<0) :
		fail = True
	elif(a[i]==0) :
		zero = True
		break

if(fail and not zero) :
	print("-1")
else:
	print(ans)

Submission status: Time Limit Exceeded

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

result = 1

for number in L:
    result = result * number


if len(str(result)) < 19 or result == 1000000000000000000:
    print(str(result))
else:
    print(-1)

Submission status: Time Limit Exceeded

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

x= functools.reduce(operator.mul,a)
if x<=10**18:    
    print(x)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
result = 1
checker =False
for j in a:
  if j > 1000000000000000000:
    result = -1
    checker =True
if 0 in a:
  result = 0
  checker=True
while checker==False:
  import functools
  import operator
  result = functools.reduce(operator.mul, a)
  checker = True
    

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=input().split()
a=list(map(int,a))
i=0
ans=1
for calc in a:
    ans=ans*a[i]
    i+=1
    if(i==n):
        break
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

check = True
zero = False

for i in a:
    ans = ans*i

    if i==0:
        zero = True

    if ans>1000000000000000000:
        check = False




if zero:
    print(0)
else:
    if check:
        print(ans)
    else:
        print(-1)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)
s = int(input())
n = list(map(int, input().split()))
ans = 1
if (0 in n) == True:
  ans = 0
else:
  ans = prod(n)
  if ans > 10 ** 18:
    ans = -1

print(ans)

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

N = input()
s = input().split()
k = [int(_) for _ in s] 
y = reduce(mul, k)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a=list(map(int,input().split()))
 
ans=1
 
for i in a:
    ans=ans*i
 
if ans>1000000000000000000:
    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(" ")))

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

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin, stdout

n = stdin.readline() 
n=int(n)
arr = [int(x) for x in stdin.readline().split()]
#print(arr)
ans=1
for i in range(0,n):
    ans*=arr[i]
if(ans>(10**18)):
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = 1
A = input().split(' ')
A = [int(l) for l in A]

for a in A:
  ans *= a

b = pow(10,18)

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    n = II()
    A = LI()
    th = pow(10, 18)
    ans = 1
    for a in A:
        ans *= a
        # print(a, ans)
        # if ans > th:
        #     print(-1)
        #     return
    if ans > th:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

N = int(input()) #リストの要素数

L = input().split()
L = map(lambda x: int(x), L)
ASW = functools.reduce(operator.mul, L)

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

Submission status: Time Limit Exceeded

Solution code:
from operator import add, mul, sub,truediv, floordiv
from functools import reduce

import sys
input = sys.stdin.readline

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

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

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):
    k*=a[i]
if k>1000000000000000000:
    print("-1")
else:
    print(k)

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()))
res = prod(a)
if res > (10**18):
    print(-1)
    exit()
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 ans <= 10 ** 18:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
v = [int(i) for i in input().split()]
ans = 1
for l in v:
    ans *= l;

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
array=list(map(int, input().split()))
k=1
a,b=n//2,n%2
for i in range(a):
    k*=(array[i*2]*array[i*2+1])
if b==1:
    k*=array[-1]
if k>1000000000000000000:
    print(-1)
else:
    print(k)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
data = list(map(int, input().split()))
 
a = 1
i = 0
while i<n:
  a = a*data[i]
  i += 1

if a > 10**18:
  a = -1
    # break
 
print(a)

Submission status: Time Limit Exceeded

Solution code:

n = input()
a = list(input().split(' '))
# print(n, a)
def doit(a):
  m = 1
  for ai in a:
    # print(ai)
    m = m*int(ai)

  if m > 1000000000000000000:
    return -1
  return m
 
print(doit(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
_ = int(input())
a = 1
for Ai in input().split(' '):
    a *= int(Ai)

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

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 *=  An[i]


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
m = {}
ans = 1
r = 10**18

for a in A:
  if not a in m:
    m[a] = 1
  else:
    m[a] += 1
    
for k, v in m.items():
  ans *= k**v
  
if ans > r:
  ans = -1
  
print(ans)

Submission status: Time Limit Exceeded

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


if __name__ == '__main__':
	main()

Submission status: Time Limit Exceeded

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

count = int(input())
list = list(map(int, input().split()))
sum = list[0]
for i in range(count - 1):
    sum = sum * list[i + 1]

if sum > 1000000000000000000:
    sum = -1

print(sum)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
ans=1
li = input().split()
zero=False
for i in li:
  ans*=int(i)
  if ans==0:
    zero=True
  if ans>1000000000000000000:
    ans=-1

if ans<0:
  ans=-1
if zero:
  ans=0
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
from functools import reduce

n = int(input())
A = [None]*n
A = map(int, input().split())
T = reduce((lambda x, y: x * y), A)
if T > pow(10,18):
    print(-1)
else:
    print(T)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

ans = 1

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

for i in n:
    ans *= i

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

Submission status: Time Limit Exceeded

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

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

print(int(x))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

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

ans=1

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

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

Submission status: Time Limit Exceeded

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

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

cum = 1
over = False
for x in a:
    if x == 0:
        cum = 0
        break

    cum *= x
    if (cum > 1e18):
        over = True

print(-1) if (over and cum != 0) else print(cum)

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

Submission status: Time Limit Exceeded

Solution code:
over = 10**18

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator


N=int(input())
A=list(map(int,input().split()))
B= functools.reduce(operator.mul,A)
if B>1000000000000000000:
    print(-1)
else:
    print(B)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
inputNum = int(input())
if inputNum in range(2, pow(10, 5)+1):
  input = input()
  inputArr = input.split()
  result = 1
  for n in range(inputNum):
    result = int(inputArr[n]) * result
  if result in range(0, pow(10, 18)+1):
    print(result)
  else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

pi = functools.partial(functools.reduce, operator.mul)
n = int(input())
a = list(map(int, input().split()))
ans = pi(a)
if ans > 10**18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

new = 1
a = list(map(int,input().split()))
for i in a:
	new = new * i 
val = pow(10,18)
if new > val:
	print(-1)
else:
	print(new)

Submission status: Time Limit Exceeded

Solution code:
N = input()
B = input().split()

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

else:
    print("choose right value")

Submission status: Time Limit Exceeded

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

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

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())
sum  = 1
flag = 0
for i in A:
    sum = sum * i
    if(i == 0):
        print(0)
        flag=1
        break
if(flag==0):
    if(sum > (10**18)):
        print(-1)
    else:
        print(sum)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

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

num_list = list(map(int, input().split()))
     
num = 1
     
for i in num_list:
    num *= i
    
    if num == 0:
        break

if num > 1000000000000000000:
    num = -1

print(num)

Submission status: Time Limit Exceeded

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

ans = 1;
for i in range(N):
	ans *= L[i]
  
if ans > 1000000000000000000:
  ans = -1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

A = input()

C = reduce(mul, map(int, input().split()))
if C > 10**18:
  print(-1)
else:
  print(C)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# このファイルはutf-8で書かれているため、日本語を書く場合は上の記述が必要


count_num = int( input())

text = input()

num_data = text.split(' ')


ans = 1
for i in num_data:
        if i == '0':
                ans = 0
                break

if ans == 1:
        for i in num_data:
                ans = ans * int(i)
        if ans > 1000000000000000000:
                ans = -1

print(ans)