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:
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    ans = 1
    threshold = 1000000000000000000
    for x in A:
        ans *= x
    if (ans > threshold):
        print(-1)
    else:
        print(ans)


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
count = int(input())
if count == 0:
  result = 0
else:
  nums_str = input().split()
  nums_int = []
  for strn in nums_str:
    nums_int.append(int(strn))

    if 0 in nums_int:
      result = 0
    else:
      result = 1
      for intn in nums_int:
        result *= intn
        if result > 1000000000000000000:
          result = -1
          break
    
print(result)

Submission status: Time Limit Exceeded

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

r = 1
for num in A:
  r *= num
  if r == 0:
    break
print(-1 if r > 10 ** 18 else r)

Submission status: Time Limit Exceeded

Solution code:
count = int(input())
if count == 0:
  result = 0
else:
  nums_str = input().split()
  nums_int = []
  for strn in nums_str:
    nums_int.append(int(strn))
 
    result = 1

    if 0 in nums_int:
      result = 0
    else:
      for intn in nums_int:
        result *= intn
        if result > 10**18:
          result = -1
          break
    
print(result)

Submission status: Time Limit Exceeded

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

import functools

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int,input().split()))
result=A[0]
x=1
while x<N:
    result=result*A[x]
    x+=1
if result>10**18:
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
SUM = 1
flag = 0
         
for a in A:
  SUM = SUM*a


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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

nl = map(int,input().split())

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

lim = 10**18

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

Submission status: Time Limit Exceeded

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

result = 1

if 0 in Ai:
	result= '0'  
else:
  for i in range(N):
      result *= Ai[i]

  if result > 10**18:
    result = '-1'

print(result)

Submission status: Time Limit Exceeded

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

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

if result > 10**18:
  result = '-1'

print(result)

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]
# print(len(str(ans))-1)
if ans<=10**18:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

d=1

for b in a:
  
  d=d*b
if d>10**18:
  print("-1")
else:
  print(d)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    data = input().split()
    res = 1
    for i in range(n):
        res *= int(data[i])
        if res == 0:
            print(0)
            return
    if res > 10**18:
        print(-1)
        return
    print(res)
    return

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

for num in a:
  ans *= num
  if ans == 0: break

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

Submission status: Time Limit Exceeded

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

q = 1

for i in num:
    q=q*i
    if i == 0:
        q=0
        break

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

Submission status: Time Limit Exceeded

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

q = 1

for i in num:
    q=q*i

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

Submission status: Time Limit Exceeded

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

result = 1
for a_i in a:
    result *= a_i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
wfwfe=input()

b=input().split()

if "0" in b:
    print (0)
else:

    count=1
    for i in b:
        count=count*int(i)
        
    if count>10**18:
        print (-1)
    else:
        print (count)

Submission status: Time Limit Exceeded

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

ans = 1
for n in nums:
  ans *= n

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

Submission status: Time Limit Exceeded

Solution code:
wfwfe=input()

b=input().split()



count=1
for i in b:
    count=count*int(i)
    
if count>10**18:
    print (-1)
else:
    print (count)

Submission status: Time Limit Exceeded

Solution code:
wfwfe=input()

b=input().split()

b=[int(p) for p in b]

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    num = int(input())
    suzi = list(map(int,input().split()))
    ans = 1
    if 0 in suzi:
	    print(0)
	    return

    for kazu in suzi:
	    ans *= kazu
    if ans >  1000000000000000000:
	    print(-1)
    else:
	    print(ans)

main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

res = 1
for i in a:
  if i == 0:
    print(0)
    break
  else:
    res *= i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#B
def unti():
    N = int(input())
    A = list(map(int, input().split()))
    result = 1
    if 0 in A:
        print(0)
        return
    for a in A:
        if 0 in A:
            print(0)
            break
        result *= a
    if result >10**18:
        print(-1)
    else:
        print(result)

unti()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

c = 0

for i in a_lst:
    if i == 0:
        print(0)
        c = 1
        break
        
    if i > 1000000000000000000:
        print('-1')
        c = 1
        break
        
if c != 1:
    for i, alst in enumerate(a_lst):
        if i == 0:
            b = alst
        else:
            b = b * alst
    
    if b > 1000000000000000000:
        print('-1')
    else:
        print(b)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

c = 0

for i in a_lst:
    if i == 0:
        print(0)
        c = 1
        break
if c != 1:
    for i, alst in enumerate(a_lst):
        if i == 0:
            b = alst
        else:
            b = b * alst
    
    if b > 1000000000000000000:
        print('-1')
    else:
        print(b)

Submission status: Time Limit Exceeded

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

for i, alst in enumerate(a_lst):
    if i == 0:
        b = alst
    else:
        b = b * alst

if b > 1000000000000000000:
    print('-1')
else:
    print(b)

Submission status: Time Limit Exceeded

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

p = 1
for i in range(N):
  p*=arr[i]
    
if p > pow(10,18):
  print(-1)
else:
  print(p)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

for number in A:
  result = result * number
  
if result > 1000000000000000000:
  print(-1)  
  
else:
  print(result)

Submission status: Time Limit Exceeded

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

from operator import add, mul, sub,truediv, floordiv
from functools import reduce

result = reduce(lambda x, y: x*y, A)

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

Submission status: Time Limit Exceeded

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

result = 1
for number in A:
  result = result * number
  
if result > 10**18:
  print(-1)  
  
else:
  print(result)

Submission status: Time Limit Exceeded

Solution code:
#for  _ in range(int(input())):
    #n, k = map(int, input().split())

n = int(input())

arr = list(map(int, input().split()))
ans=1
i=0
j=n-1
while i<=j:
    if i==j:
        ans=ans*arr[i]
    else:

        ans=ans*arr[i]*arr[j]
    j-=1
    i+=1

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

Submission status: Time Limit Exceeded

Solution code:
#for  _ in range(int(input())):
    #n, k = map(int, input().split())

n = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
#coding: utf-8
times= int(input())
a= 1
for i in list(map(int, input().split())):
  i*= a
  a= 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()))
a=A[0]
for i in range(1,n):
    a = a*A[i]
if(a>10**18):
    a=-1
print(a)

Submission status: Time Limit Exceeded

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

if 0 in l:
    ans = 0
else:
    n = min(N,len(l))
    ans = 1
    for i in l[:n]:
        ans *= i
    if ans > 10**18:
        ans = -1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
l = [int(x) for x in input().split()]
n = min(N,len(l))
ans = 1
for i in l[:n]:
    ans *= i
if ans > 10**18:
    ans = -1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def B():
    n = int(input())
    a = list(map(int, input().split()))
    ret = 1
    for d in a:
        ret *= d
    if ret > pow(10, 18) :
        print(-1)
    else:
        print(ret)
B()

Submission status: Time Limit Exceeded

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

for i in range(a):
  if i != 0:
    c = c * b[i]
  elif b[i] == 0:
    c = 0
    break
  else:
    c = b[i]

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

Submission status: Time Limit Exceeded

Solution code:
lenght = int(input())
 
x = list(map(int,input().split()))
x.sort()
if x[0]==0:
  print(0)
else:
  first_value = 1
  for val in x:
    first_value *= val
  if first_value > 1e18:
    print(-1)
  else:
    print(first_value)

Submission status: Time Limit Exceeded

Solution code:
lenght = int(input())
 
x = list(map(int,input().split()))
first_value = 1
for val in x:
  first_value *= val
if first_value > 1e18:
  print(-1)
else:
  print(first_value)

Submission status: Time Limit Exceeded

Solution code:
lenght = int(input())
 
x = list(map(int,input().split()))
first_value = 1
for i in range(lenght):
  first_value *= x[i]
  if first_value == 0:
    break
if first_value > 1e18:
  print(-1)
else:
  print(first_value)

Submission status: Time Limit Exceeded

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

a= x[1:]
a2= x[:1]
for i in a:a2.append(a2[-1]*i)

if a2[-1] > 1e18:
	print(-1)
else:
  	print(a2[-1])

Submission status: Time Limit Exceeded

Solution code:
lenght = int(input())
 
x = list(map(int,input().split()))
 
for i in range(lenght-1):
  x[i+1] = x[i] * x[i+1]
if x[-1] > 1e18:
  x[-1] = -1
print(x[-1])

Submission status: Time Limit Exceeded

Solution code:
lenght = int(input())

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

first_val = x[0]
for i in range(lenght-1):
  first_val *= x[i+1]

if first_val > 1e18:
  first_val = -1

print(first_val)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

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

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

Submission status: Time Limit Exceeded

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

for number in A:
  result *= number
  if (result == 0):
    print(0)
    break

if (result > 10 ** 18):
  print(-1)
elif (result != 0):
  print(result)

Submission status: Time Limit Exceeded

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

"""
ans = 1
for x in range(N):
    ans *= A[x]
"""
A = sorted(A)

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

if ans > 1.0e+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 x in range(N):
    ans *= A[x]
"""
ans = 1
for x in A:
    ans *= x

if ans > 1.0e+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 x in range(N):
    ans *= A[x]

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

for number in A:
  result *= number

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

Submission status: Time Limit Exceeded

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


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

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

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

Submission status: Time Limit Exceeded

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

result = 1
for idx in A:
    result *= idx
if result <= 10**18:
	print(result)
else:
 	print(-1)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for e in a:
    sum_a *= e

if sum_a > 1e18:
    sum_a = -1

print(sum_a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = (int(x) for x in input().split())

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

MAX = 10**18
total = 1
for i in range(N):
    total *= A[i]

if total > MAX:
    print(-1)
else:
    print(total)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())
x_list = list(map(int, input().split()))
 
result = math.prod(x_list)
if result >1e18:
  print(-1)
else:
  print(result)

Submission status: Time Limit Exceeded

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

result = 1
for x in x_list:
  result *= x
if result >1e18:
  print(-1)
else:
  print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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): res *= a[i]
print(-1) if res > 10**18 else print(res)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a=input()
x = list(map(int, input().split()))
sum=1
for i in x:
  sum*=i
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 i in range(N):
    ans=ans*A_list[i]

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

Submission status: Time Limit Exceeded

Solution code:
#-*-coding:utf-8-*-
N = int(input())
A = list(map(int,input().split()))

num = 1

for i in A:
  num *= i
if num > 10 ** 18:
  num = -1
    
    
print(num)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


#リストAの要素をすべて掛け算
product = 1
for i in A:
    product *= int(i)

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

print(product)

Submission status: Time Limit Exceeded

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

#リストAの要素をすべて掛け算
product = 1
for i in A:
    product *= i

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

print(product)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import functools
n = int(input())
arr = [int(a) for a in input().split()]
m = 10 ** 18

ans = functools.reduce(lambda a, b: a*b, arr)
if ans <= m:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

def main ():
  count = int(input())
  c = list(map(int,input().split()))

  if 0 in c:
    print(0)
    return

  a = reduce(mul, c)

  if a > 1000000000000000000:
    print(-1)
    return
  else:
    print(a)

main()

Submission status: Time Limit Exceeded

Solution code:
def main ():
  N = int(input())
  A = list(map(int,input(). split ()))
  if 0 in A:
    print(0)
    return

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

  if prod > 1000000000000000000:
    print(-1)
    return
  
  print(prod)
  
main ()

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

count = int(input())
list = [int(x) for x in input().split()]

a = reduce(mul, list)

if a > 1000000000000000000:
    print('-1')
else:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
count = int(input())
list = [int(x) for x in input().split()]
b = 1
for a in list:
    b *= a

threshold = int(1000000000000000000)

if b > threshold:
    print('-1')
else:
    print(b)

Submission status: Time Limit Exceeded

Solution code:
count = int(input())
list = [int(x) for x in input().split()]
b = 1
for a in list:
    b *= a

threshold = int(10 ** 18)

if b > threshold:
    print('-1')
else:
    print(b)

Submission status: Time Limit Exceeded

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

ans = 1

for a in A:
  ans *= a
  
if ans > pow(10, 18):
  print(-1)
  import sys
  sys.exit()

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
nums = list(map(int, input().split()))
sum = 1
flag = 1
upper = pow(10, 18)
for num in nums:
  sum = sum * num
  if sum > upper:
    flag = 2
  if num == 0:
    sum = 0
    flag = 1
    break

if flag == 1:
  print(sum)
elif flag == 2:
  print(-1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
nums = list(map(int, input().split()))
sum = 1
flag = 1
upper = pow(10, 18)
for num in nums:
  sum = sum * num
  if flag != 0:
    if sum > upper:
      flag = 2
  if num == 0:
    flag = 0
if flag == 2:
  print(-1)
else:
  print(sum * flag)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
nums = list(map(int, input().split()))
sum = 1
flag = 1
upper = pow(10, 18)
for num in nums:
  sum = sum * num
  if sum > upper:
    flag = 2
  if num == 0:
    sum = 0
    flag = 0
if flag == 0:
  print(0)
elif flag == 1:
  print(sum)
elif flag == 2:
  print(-1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
nums = list(map(int, input().split()))
sum = 1
flag = 1
upper = pow(10, 18)
for num in nums:
  sum = sum * num
  if sum > upper:
    flag = 2
  elif num == 0:
    sum = 0
    flag = 0
if flag == 0:
  print(0)
elif flag == 1:
  print(sum)
else:
  print(-1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
nums = list(map(int, input().split()))
sum = 1
flag = 1
upper = pow(10, 18)
for num in nums:
  sum = sum * num
  if sum > upper:
    flag = 0
  elif num == 0:
    sum = 0
    flag = 1
    break
if flag == 1:
  print(sum)
else:
  print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def multiply(arr):
    ans = 1
    for i in arr:
        ans *= i
    if ans > 1000000000000000000:
            return -1
    return ans
n = int(input())
nums = list(map(int, input().split(' ')))
print(multiply(nums))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
if(A[-1] == 0):
  print(0)
else:
  p = 1
  for An in A:
    p *= An
  if(p > 10 ** 18):
    print(-1)
  else:
    print(p)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

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

Submission status: Time Limit Exceeded

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

num = 1
for k in range(n):
	num *= a[k]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(len(a)):
    c = c * a[i]

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