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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import operator
from functools import reduce

N = int(input())
A = input().split()

length = len(A)

list = []

for num in range(length):
    list.append(int(A[num]))

result = reduce(operator.mul, list, 1)

max = 10**18

if result <= max:
    print(result)
else:
    print("-1")

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse = False)
cnt = 1

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

num = int(input())
a = input().split(" ")
table = list(a)
total = 1
for i in range(num):
    total *= int(table[i])

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

Submission status: Time Limit Exceeded

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

result = 1
length = len(A)

for num in range(length):
    result = result * int(A[num])

max = 1000000000000000000;

if result <= max:
    print(result)
else:
    print("-1")

Submission status: Time Limit Exceeded

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

for i in range(0, n):
    ans *= list_a[i]

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

else: print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1

ok = True
for i in range(n):
    ans *= a[i]
    if ans > 10 ** 18:
        ok = False

if ok == True or ans == 0:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

ans = 1

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
nums = input().split()

seki = 1
for item in nums:
  seki *= int(item)
  
if seki > 10**18:
  print(-1)
else:
  print(seki)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#B
N = int(input())
A = list(sorted(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:
#B
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()))
S = 1
for i in range(N):
    S *= A[i]
if S > 100 ** 9:
    print("-1")
else:
    print(S)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if 0 in A:
  iszero = True

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

print(ans)

Submission status: Time Limit Exceeded

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

if 0 in A:
  iszero = True

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

print(ans)

Submission status: Time Limit Exceeded

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

for i in range(N):
  if(A[i]==0):
    iszero = True

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

print(ans)

Submission status: Time Limit Exceeded

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

ans = 1
threshold = 10 ** 18
for i in range(n):
    ans *= a[i]
if threshold < ans:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

result = 1
length = len(A)

for num in range(length):
    result = result * int(A[num])

max = 10 ** 18

if result <= max:
    print(result)
else:
    print("-1")

Submission status: Time Limit Exceeded

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

result = 1
length = len(A)

for num in range(length):
    result = result * int(A[num])

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

Submission status: Time Limit Exceeded

Solution code:
MAX = pow(10,18)
n = int(input())
A = list(map(int,input().split()))

if 0 in A:
    print(0)
else:
    ans = 1
    for a in A:
        ans *= a
    if ans > MAX:
        print(-1)
    else:
        print(ans)

Submission status: Time Limit Exceeded

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

result = 1

for num in range(N):
    result = result * int(A[num])

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
n = int(input())
An = list(map(int, input().split()))
ans = 1
for i in range(0,n):
    ans = ans * An[i]

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

Submission status: Time Limit Exceeded

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

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
SUM = 1
while i < N:
    SUM = SUM * A[i]
    i += 1

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()))
b = 1
c = 0
for i in range(N):
  b = b * A[i]
  if b > 10 ** 18:
    if A.count(0) == 0:
      c = 1
      break
if c == 0:
  print(b)
else:
  print(-1)

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 = 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()))
num = 1
for i in a:
    num *= i
if 10**18 < num:
    print(-1)
else:
    print(num)

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
ans = 1 
if 0 in a:
    print(0)
    sys.exit()
for i in a:
    ans *= i
    if ans > 10**18:
        ans = -1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    a = []
    res = 1
    MAX = 10**18
    a = list(map(int, input().split()))

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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N=input()
A=input().split()
B=[int(s) for s in A]
c=1
for i in B:
    c*=i

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = 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:
import sys
n = int(input())
a = list(map(int, input().split()))
ans = 1 
if 0 in a:
    print(0)
    sys.exit()
for i in a:
    ans *= i
    if ans > 10**18:
        ans = -1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

if s <= 10**18:
    print(s)
elif s > 10**18:
    print(-1)

Submission status: Time Limit Exceeded

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

for i in range(n):
  product *= A[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
input()
A=map(int,input().split())
r=1
for a in A:
  r*=a
if r>10e17:
  print(-1)
else:
  print(r)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
input()
r=reduce(lambda a,b:eval(f'{a}*{b}'),input().split())
if 10e17<r:
  print(-1)
else:
  print(r)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 1
    for num in A:
        ans *= num
    if ans > 10**18:
        ans = -1
    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Time Limit Exceeded

Solution code:
def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 1
    for i in range(N):
        ans *= A[i]
    if ans > 10**18:
        ans = -1
    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Time Limit Exceeded

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

try:
    idx =a.index(0)
    print(0)

except ValueError:

    ans = a[0]
    for i in range(1, len(a)):
        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()))

def multi_lst(lst):
    ans = lst[0]
    for i in range(1, len(lst)):
        ans *= lst[i]
    
    return ans
try:
    idx =a.index(0)
    print(0)

except ValueError:
    
    ans = multi_lst(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()))

def multi_lst(lst):
    ans = lst[0]
    for i in range(1, len(lst)):
        ans *= lst[i]
    
    return ans

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
An = list(map(int,input().split()))
a = 1
if 0 in An:
    print("0")

else:
    for i in range(N):
        a *= An[i]
    if a <= 10**18:
        print(a)
    else:
        print("-1")

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul
N = int(input())
An = input().split()
An_int = list(map(int, An))
AnS = reduce(mul,An_int)
if AnS <= 10**18:
    print(AnS)
else:
    print("-1")

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul
N = int(input())
An = input().split()
Ani = [int(i) for i in An]
AnS = reduce(mul,Ani)
if AnS <= 10**18:
    print(AnS)
else:
    print("-1")

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul
N = int(input())
An = input().split()
for i in range(N):
    An[i] = int(An[i])
AnS = reduce(mul,An)
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()))
a=1
for i in range(N):
    a=A[i]*a
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 x in a:
  ans *= x
if ans > 10**18:
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# Multiplication2
import math
N = int(input())
A = list(map(int,input().split()))
ans = 1
for a in A:
    ans *= a
ans = [-1, ans][ans <= 10**18]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# Multiplication2
import math
N = int(input())
A = list(map(int,input().split()))
ans = [-1, math.prod(A)][math.prod(A) <= 10**18]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul

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

seki = reduce(mul, l)
max = 1000000000000000000
print(-1 if seki > max else seki)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul

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

seki = reduce(mul, l)
print(-1 if seki > 10 ** 18 else seki)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

if ans > lim:
	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 = ans * a[i]

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

Submission status: Time Limit Exceeded

Solution code:
import sys

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

product = 1
for i in range(N):
    product = product * p[i]

if product > 10 ** 18:
    print(-1)
    sys.exit()
print(product)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def main(a):
  if 0 in a:
    ans = 0
  else:
    ans = 1
    for item in a:
      ans *= item
      if ans > 1000000000000000000:
        ans = -1
  return ans

ans = main(a)
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

ans = 1
for item in a:
  ans = ans * item
  if ans > 1000000000000000000:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

ans = 1
for item in a:
  ans = ans * item
  if ans > 1000000000000000000:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

ans = 1
for item in a:
  ans = ans * item
if ans > 1000000000000000000:
  ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

ans = 1
for item in a:
  ans = ans * item
  if ans > 1000000000000000000:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
x=int(input())
b=input()
lst=b.split(" ")
a=0
ans=int(lst[0])
q=0
while(a<x-1):
    q=int(lst[a+1])
    ans*=q
    a+=1
if(ans<=10**18):
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y

n = ini()
a = inl()
ans = 1
lim = 10 ** 18
for i in a:
        ans *= i
if ans > lim:
        ans = -1
print(ans)

Submission status: Time Limit Exceeded

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

def f(a):
    if 0 in a:
        return 0
    ans = a[0]
    for i in range(1, len(a)):
        ans *= a[i]
    if ans > 10 **18:
        return -1
    else:
        return ans

print(f(a))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A_list=sorted(list(map(int, input().split())), reverse=True)
ans=1

if 0 in A_list:
  print(0)
  exit()
else:
  for a in A_list:
    ans*=a
  if ans>1e+18:
    ans=-1
    print(-1)
    exit()
  print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def Qb():
    from functools import reduce
    from operator import mul

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

    ans = reduce(mul, lina)

    # for i, a in enumerate(lina):
    #     ans *= a
    if 10 ** 18 < ans:
        ans = -1
    print(ans)


def Qc():
    pass


if __name__ == '__main__':
    Qb()

Submission status: Time Limit Exceeded

Solution code:
def Qb():
    n = int(input())
    lina = map(int, input().split())

    ans = 1
    for i, a in enumerate(lina):
        ans *= a
    if 10 ** 18 < ans:
        ans = -1
    print(ans)


if __name__ == '__main__':
    Qb()

Submission status: Time Limit Exceeded

Solution code:
def Qb():
    n = int(input())
    lina = map(int, input().split())

    ans = 1
    for i, a in enumerate(lina):
        ans = a * ans
    if 10 ** 18 < ans:
        ans = -1
    print(ans)


if __name__ == '__main__':
    Qb()

Submission status: Time Limit Exceeded

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

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

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

print(n)

Submission status: Time Limit Exceeded

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

import functools
import operator

n = functools.reduce(operator.mul, A)

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

print(n)

Submission status: Time Limit Exceeded

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


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

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

print(n)

Submission status: Time Limit Exceeded

Solution code:
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]
n = I()
li = LI()
ans = 1
for k in li:
  ans = ans*k
if ans > 10**18:
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

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

r = 1
for tt in t:
    r *= tt

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

Submission status: Time Limit Exceeded

Solution code:

def main():
    MAX = 1_000_000_000_000_000_000
    n = int(input())
    nums = [int(_x) for _x in input().split()]
    result = 1
    for num in nums:
        result = result * num

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


main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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()))
count=1
for i in A:
	count=count*i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
import operator
input()

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

Submission status: Time Limit Exceeded

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

for i in li:
    n *= i

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

m = 1

for a in A:
    m = m * a

if m > 1000000000000000000:
    print(-1)
    exit(0)

print(m)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

m = 1

for a in A:
    m = m * a

if m > 10**18:
    print(-1)
    exit(0)
    
print(m)