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().split()))

sq=A[0]
for i in range(1,N):
    sq *= A[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

for i in An:
  ans = ans * i

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

Submission status: Time Limit Exceeded

Solution code:

def main():
    a = input()
    array = list(map(int, input().split()))

    sum = 1
    for i in range(len(array)):
        sum *= array[i]

    if (sum > 10**18):
        sum = -1;

    print(sum)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
arr = input().split()
def mult():
    if 0 in arr:
        print(0)
        return 0
    a = 1
    for i in arr:
        a = a * int(i)
    if a > 1000000000000000000:
        print(-1)
        return 0
    else: 
        print(a)
        return 0

mult()

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

arr = input().split()
count = 1
if "0" in arr:
  count = 0
else: 
  for i in arr:
    count *= int(i)
  if count > 1000000000000000000: count = -1
  
print(count)

Submission status: Time Limit Exceeded

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

hantei = 10 ** 18
kekka = 1
for x in range(n):
    kekka = kekka * m[x]

if kekka > hantei:
    print("-1")
else:
    print(kekka)

Submission status: Time Limit Exceeded

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

x = 1
for i in range(N):
    x = x * l[i]

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

Submission status: Time Limit Exceeded

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

ans = 1
for v in arr:
  ans *= v

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

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

ans = reduce(lambda a, b: a * b, arr)
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()))

if 0 in a:
    print(0)
    sys.exit()
    
ans = 1
for i in a:
    ans *= i
    
if ans <= 1000000000000000000:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    _ = input()
    an = map(int, input().split())

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

if __name__ == '__main__':
    resolve()

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    _ = input()
    A = map(int, input().split())

    from functools import reduce
    ans = reduce(lambda lhs, rhs: lhs * rhs, A)

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

if __name__ == '__main__':
    resolve()

Submission status: Time Limit Exceeded

Solution code:
input()
a = list(map(int, input().split()))
ans = 1
for el in a:
    ans *= el
if ans > 1e18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
 
A.sort()
if A[0] == 0:
  print(0)
else:
  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 = list(map(int, input().split()))

A.sort()
if A[0] == 0:
  print(0)
else:
  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()))
 
if 0 in A:
  print(0)
else:
  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()))

if 0 in A:
  print(0)
else:
  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().strip())
A = list(map(int, input().strip().split()))

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
T=1e18
arr=[int(i) for i in input().split()]
A=1
for a in arr:
    A*=a

print(A if A<=T else -1)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = input().split()
a = 0
b = 1
while a <= n - 1 :
  b = b * int(x[a])
  a += 1
if b <= 1000000000000000000:
  print(b)
else:
  print(-1)

Submission status: Time Limit Exceeded

Solution code:
import sys

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

if ans > 1e18:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

ans = 1

for i in A_list:
    ans = ans * i


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

print(ans)

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

if 0 in a:
    print(0)
else:
    for i in range(n):
        ans *= a[i]

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

Submission status: Time Limit Exceeded

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

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

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
num = input()
input_data = input().split()

result = 1
for i in range(int(num)):
  result = result * int(input_data[i])

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

Submission status: Time Limit Exceeded

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

else:
    print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

N = input()
l_1 = map(int,input().split())

ans = reduce(mul, l_1)

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

Submission status: Time Limit Exceeded

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

if 0 in A:
  ans = 0
  
else:
  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()))
 
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()))
 
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()))
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:
from functools import reduce
from operator import mul

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

result = reduce(mul, A)
print(result if result <= 10**18 else -1)

Submission status: Time Limit Exceeded

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

x = 1
for i in range(N):
    x = x * l[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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 == 0:
        break

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

if x>10**18:
    print(-1)
        
   

        
else:
    print(x)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    s = [input() for l in range(2)]
    N, A_dct, A = int(s[0]), {int(x): int(x) for x in s[1].split()}, [int(x) for x in s[1].split()]
    if 0 in A_dct:
        print(0)
    else:
        tmp = 1
        for k in A:
            tmp *= k
        if tmp > 10**18: tmp = -1
        print(tmp)
    

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    s = [input() for l in range(2)]
    N, A = int(s[0]), [int(x) for x in s[1].split()]
    tmp = 1
    for a in A:
        tmp *= a
        if a == 0:
            break
    if tmp > 10**18: tmp = -1
    print(tmp)
    

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
A = list(map(int, input().split()))
total = math.prod(A)
if total > 1000000000000000000:
    print(-1)
else:
    print(total)

Submission status: Time Limit Exceeded

Solution code:
#
# ~oisín~ Python3 Template
#

import sys
import math
import statistics
import datetime
import collections

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 1
    for x in a:
        ans *= x
    if ans > 1000000000000000000:
        print("-1")
    else:
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

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

if 10**18 < res:
    print(-1)
    exit()

print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
s=input()
a=input()
a=a.split()


c=1
for x in a:
  c=c*int(x)
  
if c <= 10**18:
  print(c)
else:  
  print("-1")

Submission status: Time Limit Exceeded

Solution code:
s=input()
a=input()
a=a.split()
c=1
for x in a:
  c=c*int(x)
if c > 10**18:
  print("-1")
else:  
  print(c)

Submission status: Time Limit Exceeded

Solution code:
s=input()
a=input()
a=a.split()


c=1
for x in a:
  c=c*int(x)
  
if c > 10**18:
  print("-1")
else:  
  print(c)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
 
N=int(input())
#print(N)
A=input().split()
A_int = [int(s) for s in A]
#print(A_int)
ans=1
for i in range(N):
  ans=ans*A_int[i]

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    if 0 in a:
        print(0)
        return
    ans = 1
    for cal in a:
        ans *= cal
    if ans > 1e18:
        ans = -1
    print(ans)


main()

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

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

ans = 1
for i in li:
    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 = 1
for i in li:
    ans *= i

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

n = input()
li = list(map(int, input().split()))
result = functools.reduce(operator.mul, li)

if result >= 1000000000000000001:
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#intの場合
N = int(input()) #ここで標準入力

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

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



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

Submission status: Time Limit Exceeded

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

mx = 1e18
pr = 1
done = True

for i in a:
	pr = pr*i

if pr <= mx:
	print(pr)
else:
	print(-1)

Submission status: Time Limit Exceeded

Solution code:
c = 10**18

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

for i in a:
    b *= i

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

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 > pow(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())):
  a*= i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

import numpy as np

def main():
    n = int(input())
    l = list(map(int,input().split()))
    pro=1
    for num in l:
        pro = pro*num
    if pro > 10**18:
        print(-1)
    else:
        print(pro)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
a1 = int(input())
b2 = input().split(" ")

def check(a , b):
  score = 1
  now = 10 ** 18
  if '0' in b:
    return print(0)
  else:
    for i in range(a):
      score *= int(b[i])
    if score > 10 ** 18:
      return print(-1)
    else:
      return print(score)

check(a1 , b2)

Submission status: Time Limit Exceeded

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

product = 1
for i in a:
    if i==0:
        product = 0
        break
    product *= i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lst = [int(x) for x in input().split()]
ret = 1
for x in lst:
    ret *= x

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
#A=[int(x) for x in input().strip().split(" ")]
A=list(map(int,input().split()))
x=1
c=1000000000000000000
for i in range(N):
    if x<c or x!=0:
        x *=A[i]
if x>c:
    print("-1")
else:
    print(x)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(a) for a in 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:
s = int(input())

#a = [input() for i in range(s)]
a = list(map(int, input().split()))

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


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 i in range(n):
    ans *= a[i]
    if 0 in a:
        print('0')
        exit()
    elif ans > 10**18:
        print('-1')
        exit()
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:
a = int(input())

b = input().split(" ")
score = 1

for i in range(a):
  t = int(b[i])
  score *= t
  
if score > 10 ** 18:
  print(-1)
else:
  print(score)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
Nlist = list(map(int, input().split()))
total = 1

for i in range(N):
    total = total*Nlist[i]

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
n = int(input())

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

if 0 in arg:
    ans = 0
else:
    for m in arg:
        ans *= m

        if ans > 1000000000000000000:
            ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

if 0 in arg:
    ans = 0
else:
    for m in arg:
        ans *= m

    if ans > 1000000000000000000:
        ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
from decimal import Decimal

n = int(input())

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

if 0 in arg:
    ans = 0
else:
    for m in arg:
        ans *= m

    if ans > 1000000000000000000:
        ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Y = 1
for i in range(N):
    X = A[i]
    X = int(X)
    Y = Y * X

M = 10 ** 18

if Y > M:
    print(-1)
else:
    print(Y)

Submission status: Time Limit Exceeded

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

a=1
for i in range(N):
  if(P[i]==0):
    a=-1
    break
if a!=0:
  for i in range(N):
    a*=P[i]
    if(a>1000000000000000000):
      a=-1
      break
print(a)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

for i in A:
    answer*=i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
inp = input()
inp = input()
 
def mp(nums):
  n = 1
  for num in nums:
    n *=num
  return n
 
limit = 10**18
num = mp([int(x) for x in inp.split(" ")])
 
if num > limit:
  print(-1)
else:
  print(num)

Submission status: Time Limit Exceeded

Solution code:
inp = input()
inp = input()
 
def mp(nums):
  n = 1
  for num in nums:
    n *=num
  return n
 
limit= mp([10]*18)
num = mp([int(x) for x in inp.split(" ")])
 
if num > limit:
  print(-1)
else:
  print(num)

Submission status: Time Limit Exceeded

Solution code:
inp = input()
inp = input()

def mp(nums):
  n = 1
  for num in nums:
    n *=num
  return n
 
limit= mp([10]*18)
num = mp([int(x) for x in inp.split(" ")])

if num > limit:
  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 > 10**18:
    print("-1")
else:
   print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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)