Problem:


Score : 200 points

Problem Statement

Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.

However, if the result exceeds 10^{18}, print -1 instead.

Constraints

2 \leq N \leq 10^5

0 \leq A_i \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

Print the value A_1 \times ... \times A_N as an integer, or -1 if the value exceeds 10^{18}.

Sample Input 1

2
1000000000 1000000000

Sample Output 1

1000000000000000000

We have 1000000000 \times 1000000000 = 1000000000000000000.

Sample Input 2

3
101 9901 999999000001

Sample Output 2

-1

We have 101 \times 9901 \times 999999000001 = 1000000000000000001, which exceeds 10^{18}, so we should print -1 instead.

Sample Input 3

31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0

Sample Output 3

0



Sample input:
2
1000000000 1000000000


Sample output:
1000000000000000000

Submission status: Time Limit Exceeded

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

ans = 1
ans1 = 1
ans2 = 1
count = N // 2
if N%2 == 0:
    for i in range(count):
        ans1 *= A[i]
    for i in range(count):
        j = i + count
        ans2 *= A[j]
    ans = ans1*ans2
    if ans > 1000000000000000000:
        print('-1')
    else:
        print(ans)
else:
    for i in range(count):
        ans1 *= A[i]
    for i in range(count+1):
        j = i + count
        ans2 *= A[j]
    ans = ans1*ans2
    if ans > 1000000000000000000:
        print('-1')
    else:
        print(ans)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import math as m
import sys
n=int(sys.stdin.readline())
a=list(map(int,sys.stdin.readline().split()))
p=1
for i in range(n):
    p*=a[i]
if p>10**18:
    print(-1)
else:
    print(p)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

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


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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce
N = int(input())
L = list(map(int, input().split()))
M = reduce(mul, L)
if 1000000000000000000 < M:
    M = -1
print(M)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

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

for i in range((n//2)-1):
    l = a[i] * a[i+1]
    r = a[-1-i] * a[-2-i]
    a[i+1] = l
    a[-2-i] = r

if n % 2 == 0:
    c = a[n//2] * a[(n//2) -1]
else:
    c = a[n//2] * a[(n//2) -1] * a[(n//2) +1]

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

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

total = 1

if 0 in li:
    total = 0
    print(total)
else:
    total = reduce(mul, li) #=> 1320
    if 10 ** 18 < total:
        total = -1
    print(total)

Submission status: Time Limit Exceeded

Solution code:
a = input()
l = list(map(int,input().split()))
ans = 1

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

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
from decimal import *

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

getcontext().prec = 21

aa = [Decimal(f'{b}').log10() for b in a if a != 0]
ans = Decimal('0')

for c in aa:
    ans += c


if ans > 18.0:
    print(-1)
else:
    ans = 1

    for c in a:
        ans *= c

    print(ans)

Submission status: Time Limit Exceeded

Solution code:
x1 = input()
x2 = [int(i) for i in input().split(" ")]

result = 1
for xv in x2:
  result = xv * result

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
i = input().split()
list = []
i = [int(j) for j in i]

result = 1
for k in i:
    result = result*k
if result<=1000000000000000000:
    print(result)
else:
    print("-1")

Submission status: Time Limit Exceeded

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

p = reduce( (lambda x, y: x * y), a)
if p <= 10**(18):
    print(p)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
v = ((map(int, input().split())))
answer = 1
for i in v:
    answer = answer * i
answer = answer if answer <= 1000000000000000000 else -1
print(answer)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
N= int(input())
lists = list(map(int,input().split()))
def main():
    import math
    q=int(1)
    for i in range(N):
        s = lists[i-1]
        q *= s
    if q > pow(10,18):
        print(-1)
    else:
        print(q)
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

def mal():
  val=1
  x=0
  while True:
    val*=a[x]
    x+=1
    if x==n:
      if val>10**18:
        print(-1)
      else:
        print(val)
    yield x

mal()
for i in mal():
  if i==n:
    break

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
import math
x=list(map(int,input().split()))
result1 = math.prod(x)
if(result1>1000000000000000000):
  print(-1)
else:
  print(result1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())  # nは入力回数
a = list(map(int, input().split()))
# print(a)   # 出力を確認

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

if ans>1000000000000000000:
    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()))
result = functools.reduce(operator.mul, a)

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

N = int(input())
A = list(map(int,input().split()))
result = functools.reduce(operator.mul, A)
if result > 10**18 :
    print('-1')
else :
    print(result)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
res = 1
ls = input().split(' ')
for a in ls:
    res = res * int(a)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l = input().split()
max = 10**18

r = 1

for x in l:
  r *= int(x)

r = r if r <= max else -1
print(r)

Submission status: Time Limit Exceeded

Solution code:
def main():
    import numpy as np
    from sys import stdin
    input = stdin.readline
    N = int(input())
    A = np.array(list(map(int,input().split())),dtype='object')
    ans = np.prod(A)
    if ans > 10**18:
        print(-1)
    else:
        print(ans)
main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = map(int, input().split())
s = 1
for v in x:
    s = s * v

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

Submission status: Time Limit Exceeded

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

input = sys.stdin.readline

n = int(input())
An = [int(x) for x in input(). split()]

for i in range(n):
    if An[i] == 0:
        print(0)
        quit()

j = 1000000000000000000
ans = 1
ans = reduce(mul, An)


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1
for i in a:
    if i == 0:
      	ans = 0

if ans != 0:
	for i in a:
		ans = ans*i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, *a = map(int, open(0).read().split())

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

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

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
from decimal import *

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

getcontext().prec = 28


aa = [Decimal(f'{b}').log10() for b in a if a != 0]

ans = Decimal('0')

for c in aa:
    ans += c

if ans > 18.0:
    print(-1)
else:
    ans = 1

    for c in a:
        ans *= c

    print(ans)

Submission status: Time Limit Exceeded

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

ans = 1
for x in li:
    ans = ans * x
print(ans) if ans <= 10 ** 18 else print(-1)

Submission status: Time Limit Exceeded

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

answer = reduce(operator.mul,a)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
 
ans = 1
for val in input().split():
    ans = ans * int(val)

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

Submission status: Time Limit Exceeded

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

base = 0
for i in range(N):
  if i == 0:
    base = l[i]
  else:
    base = base * l[i]

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

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


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

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

Submission status: Time Limit Exceeded

Solution code:
LIMIT = 10 ** 18
n = int(input())
prod = 1
for i in input().split():
	prod *= int(i)
	
if prod > LIMIT:
	prod = -1
	
print(prod)

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

if __name__ == "__main__":
    input()
    aList = list(map(int, input().split()))
    if not 0 in aList:
        result = reduce(lambda x, y: x*y, aList)
        print(result if result <= 10**18 else -1)
    else:
        print(0)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
y = pow(10,18)
x = 1

for i in map(int,input().split()):
    x *= i
if x > y:
    print("-1")
else:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

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

ans = reduce(mul, nums)

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    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)




main()

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
N = input()
l = input()
l_list = l.split(" ")
l_si_i = [int(s) for s in l_list]
kakezan = reduce(lambda x, y: x * y, l_si_i)
if kakezan > 1000000000000000000:
  print(-1)
else:
  print(kakezan)

Submission status: Time Limit Exceeded

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

# A1,A2,..Anの入力
A = list(map(int,input().split()))

flg = 0         
# A1,A2...Anの積
A_multi = 1
for a in A:
    A_multi = A_multi * a


# A_len = len(str(A_multi))
# if A_len > 19:
#   flg = 1

# if A_len == 19:
#    if A_multi > 10**18:
#        flg = 1

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
p=list(map(int, input().split()))
i=0
ans=1
flag=0
k=1e18
while(n>i):
	if(p[i]==0):
		flag=1
	i+=1
if(flag==1):
	print(0)
else:
	flag=0
	i=0			
	while(n>i):
		ans*=p[i]
		if(ans>k):
			flag=1
		i+=1		
	if( flag==1):
		print(-1)
	else:
		print(ans)

Submission status: Time Limit Exceeded

Solution code:
x1 = input()
x2 = [int(i) for i in input().split(" ")]

result =  1
for xv in x2:
  result = xv * result

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

M = 1

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce
N, *A = map(int, open(0).read().split())
x = reduce(mul, A)
if x > 10 ** 18:
  x = -1
print(x)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

N = int(input())
v = list(map(int, input().split()))
answer = functools.reduce(operator.mul, v) if functools.reduce(operator.mul, v) <= 1000000000000000000 else -1
print(answer)

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np;
from numba import jit
import warnings
from operator import mul
from functools import reduce
warnings.simplefilter('ignore')
    

if __name__ == '__main__':
    N = int(input())
    A = map(int, input().split())
    ans = reduce(mul, A)
    if ans > 10 ** 18:
        print(-1)
        quit()
    print(ans)

Submission status: Time Limit Exceeded

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

input = sys.stdin.readline

n = int(input())
An = [int(x) for x in input(). split()]

j = 1000000000000000000
ans = 1
ans = reduce(mul, An)


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

Submission status: Time Limit Exceeded

Solution code:
import math
T=int(input())
a=list(map(int,input().split()))
if math.prod(a)>pow(10,18):
	print(-1)
else:
	print(math.prod(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

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

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

N = int(input())
int_numbers = [int(n) for n in input().split()]
  
if reduce(mul, int_numbers) > 10**18:
  print(-1)
else:
  print(reduce(mul, int_numbers))

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

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

ans=functools.reduce(operator.mul,l)
if (ans > 10**18):
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
sub = input()
input = input().split(" ")
nl = list()
for ele in input:
  nl.append(int(ele))
res = math.prod(nl)
if res > 1000000000000000000:
  print("-1")
else:
  print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
BIG = 10**(18)
 
N = int(readline())
A = [int(x) for x in input().split()]
 
ans = 1
for i in range(N):
    ans = ans * A[i]
    
if ans > BIG:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
count = int(input())
num = []
num = input().split()

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

if __name__ == "__main__":
    input()
    aList = list(map(int, input().split()))
    result = reduce(lambda x, y: x*y, aList)
    print(result if result <= 10**18 else -1)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def m(list1): 
      
    mul=1
    for x in list1: 
         mul=mul*x  
    return mul 
      
n=int(input())
arr=list(map(int,input().split()))
if m(arr)>pow(10,18):
    print(-1)
else:
    print(m(arr))

Submission status: Time Limit Exceeded

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

f = True

a = 0 in l

b = 1000000000000000000

for i in range(1,n):
  if sum > b and a == False:
    f = False
    break
  sum *= l[i]
  if sum > b  and a==False:
    f = False
    break

if f == True:
  print(sum)
else:
  print(-1)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

N = int(input())
v = list(map(int, input().split()))
answer = functools.reduce(operator.mul, v)
answer = answer if answer <= 1000000000000000000 else -1
print(answer)

Submission status: Time Limit Exceeded

Solution code:
import collections

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

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

counter = collections.Counter(A)
ans = 1
for k, v in counter.items():
  ans *= k ** v
if ans > 10**18:
  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()))
B = reduce(lambda a,b: a*b, A)
if B <=1E18:
  print(B)
else:
  print('-1')

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
n = input()
a = input().split()
mul = reduce(lambda x, y: int(x) * int(y), a)
# for i in li:
#   j = int(i)
#   mul *= j

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce
 
N=input()
A = list(map(int, input().split()))
B=reduce(mul,A)
C=pow(10,18)
if  B<=C:
    print(B)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

input = sys.stdin.readline

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

j = 1000000000000000000
ans = 1
ans = reduce(mul, An)


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

Submission status: Time Limit Exceeded

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


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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

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

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

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

Submission status: Time Limit Exceeded

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

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

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

a=int(input())
b = list(map(int, input().split()))
d=functools.reduce(operator.mul, b)
if d > 1000000000000000000 :
    print(-1)
else :
    print(d)

Submission status: Time Limit Exceeded

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

import math
ans =1
ord =0
m = 1
 
if min(A) == 0:
    print(0)
else:
    for i in range(N):
        ord += math.log10(A[i])
        m = m*A[i] % 10
    if ord >= 18 and m > 0:
        print(-1)
    else:
        for i in range(N):
            ans = ans * A[i]
        print(ans)

Submission status: Time Limit Exceeded

Solution code:
x1 = input()
x2 = [1]*int(x1)

for k,v in enumerate(input().split(" ")):
    x2[k] = int(v)

result =  1
for xv in x2:
  result = xv * result

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul

t = input() #trash
L = list(map(int, input().split()))

if reduce(mul,L) <= 1000000000000000000:
  print(reduce(mul, L))  
else:
  print("-1")

Submission status: Time Limit Exceeded

Solution code:
import operator
from functools import reduce


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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
y = 10**18
x = 1

for i in map(int,input().split()):
    x *= i
if x > y:
    print("-1")
else:
    print(x)

Submission status: Time Limit Exceeded

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

for i in range(N):
    ans *= A[i]
    if 0 in A:
        ans = 0
        break
    if ans > 1000000000000000000:
        ans = -1
        break

print(ans)

Submission status: Time Limit Exceeded

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

total = 1

if 0 in li:
    total = 0
    print(total)
else:
    for a in li:
        total *= a
        if 10 ** 18 < total:
            total = -1
    print(total)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

N = int(input())
numbers = input().split()
int_numbers = [int(numbers[n]) for n in range(N)]
  
if reduce(mul, int_numbers) > 10**18:
  print(-1)
else:
  print(reduce(mul, int_numbers))

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce 
sub = input()
input = input().split(" ")
nl = list()
for ele in input:
  nl.append(int(ele))
res = reduce((lambda x, y: x * y), nl)
if res > 1000000000000000000:
  print("-1")
else:
  print(res)

Submission status: Time Limit Exceeded

Solution code:
import operator
from functools import reduce
N = int(input())
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:
g=0
f=1
n=int(input())
s=str(input())
a=s.split(" ")
a.sort()
for i in a:
  if int(i)==0:
    g=1
    break
  f=f*int(i)
if g==1:
  print(0)
elif f>10**18:
  print(-1)
else:
  print(f)

Submission status: Time Limit Exceeded

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

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

    print(f'{ans}')


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import collections
N=int(input())
A=list(map(int, input().split()))
A_dict=collections.Counter(A)
ANS=1

for key, value in A_dict.items():
    ANS=ANS*(key**value)

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

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

Submission status: Time Limit Exceeded

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

ans = reduce(mul, Aj)

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

Submission status: Time Limit Exceeded

Solution code:
#-*- coding: utf-8 -*-
import math
n = int(input()) 
a = [int(i) for i in 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:
a = []
x = 1

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

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

Submission status: Time Limit Exceeded

Solution code:
import math
T=int(input())
a=list(map(int,input().split()))
result=1
for i in a:
	result=result*i
if result>pow(10,18):
	print(-1)
else:
	print(result)

Submission status: Time Limit Exceeded

Solution code:
a = int(input())

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

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
import functools
import operator
N=int(input())
A = list(map(int, input().split()))
#AA=A.sort()
if A.count(0)>0:
    ans=0
else:
    ans=functools.reduce(operator.mul, A)
if ans>10**18 :
    ans=-1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = input().rstrip().split(' ')
A = [int(s) for s in S]
B = 1
for i in range(N):
    B *= A[i]
if B<0 or B>1000000000000000000:
    print(-1)
else:
    print(B)

Submission status: Time Limit Exceeded

Solution code:
import sys

def main():
    n = int(input())
    limit = pow(10,18)
    readStr = input()
    flds = readStr.split(" ")
    res = 1
    for i in range(n):
        if flds[i] == 0:
            res = 0
            break
        res *= int(flds[i])

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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())#リストの要素数
L = list(map(int,input().split()))
ASW = L[0]
for i in range(0,N-1):
  ASW = ASW*L[i+1]
  
if ASW > 10**18:
  ASW = -1
  
print(ASW)