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()))
LA = len(A)
ans = A[0]
for i in range(LA-1):
    ans = ans*A[i+1]
if ans > 10**18:
    print('-1')
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:

def main():
    n = int(input())
    As = list(map(int, input().split()))
    ans = 1

    for a in As:
        ans *= a

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

Submission status: Time Limit Exceeded

Solution code:
n=input()
list1=list(map(int,input().split()))
if 0 in list1:
    print(0)
else:
    ans=1
    for i in list1:
        ans*=i
    print(ans) if ans<=1e18 else print(-1)

Submission status: Time Limit Exceeded

Solution code:
n=input()
list1=list(map(int,input().split()))
if 0 in list1:
    print(0)
else:
    ans=1
    for i in list1:
        ans*=i
    print(ans) if ans<=1e18 else print(-1)

Submission status: Time Limit Exceeded

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

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

if ans<=10**18:
    print(ans)
elif 0 in li:
    print(0)
else:
    print("-1")

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#                               #
    # author : samars_diary #
    # 18-09-2020 │ 19:57:15 #
#                               #

import sys, os.path

if(os.path.exists('input.txt')):
    sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

def mod(): return 10**9+7
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    a=ii();b=lii();c=1
    for x in b:
        c*=x
    if c<=10**18: print(c)
    else: print(-1)
for _ in range(1):
    solve()

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:
# -*- coding: utf-8 -*-

n = int(input())

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

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

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

sum = 1
for i in n1:
    sum *= i

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

i = 0
sum = 1

while i < n:
    sum *= n1[i]
    i += 1

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(v) for v in input().split()]
ans = 1
num = 1
limit = 1000000000000000000
for i in a:
    if i == 0:
        num = 0
        break
    if i >= limit:
        num = -1
        break
    else:
        num *= i
if num > limit:
    num = -1
ans = num
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    a_tuple = tuple(map(int, input().split()))

    answer = 1
    for a in a_tuple:
        answer *= a
    print(answer if answer <= 10**18 else -1)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

if 0 in As:
    print(0)
else:
    for i in range(N):
        ans*=As[i]
    print(ans if ans<=int(1e18) else -1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
line = [int(i) for i in input().split()]
sum = 1
for num in line:
  if num == 0:
    print(0)
    exit()
  sum = sum * num
if sum > 10 ** 18:
  print(-1)
else:
  print(sum)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
line = [int(i) for i in input().split()]
sum = 1
for num in line:
  sum = sum * num
if sum > 10 ** 18:
  print(-1)
else:
  print(sum)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
N = int(input())
A = map(int, input().split())
B = reduce((lambda x, y : x*y), A)
if B > 10**18:
  print(-1)
else:
  print(B)

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

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 > pow(10, 18):
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[int(z) for z in input().split()]
x=1
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 = 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()))
wa = 1
ka = 0
for i in range(n):
  wa = wa*a[i]
if(wa>10**18):
  print("-1")
else:
  print(wa)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
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 = [int(x) for x in input().split()]
a.sort()
ans = 1

for i in a:
    ans *= i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
N =int(input())

B = 1

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

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

#print(B)
C = 10 ** 18
#print(C)
if result > C:
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
#169-B

N =int(input())

B = 1

A = list(map(int,input().split()))
    
#print(A)
for j in A:
    B = B * j


#print(B)
C = 10 ** 18
#print(C)
if B > C:
    print(-1)
else:
    print(B)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

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

mul = 1

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

print(mul if mul <= 1e18 else -1)

Submission status: Time Limit Exceeded

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

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

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

    print(mul)

main()

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(x)
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==0:
    print(0)
    break
if M>1000000000000000000:
  print(-1)
elif M!=0:
  print(M)

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

Submission status: Time Limit Exceeded

Solution code:
def kake(b,c):
    return b * c

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

A = 1
for i in range(n):
    A = kake(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()))

A = 1
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

if min(A) == 0:
    ans = 0
    print(ans)
    exit()
else:
    for i in A:
        ans *= i
    if ans > 10**18:
        ans = -1
        print(ans)
        exit()

print(ans)

Submission status: Time Limit Exceeded

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

if min(A) == 0:
    ans = 0
else:
    for i in A:
        ans *= i
    if ans > 10**18:
        ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lst = list(map(int, input().split()))
mult = 1

for i in lst:
    mult *= i

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lst = list(map(int, input().split()))
mult = 1

for i in lst:
    mult *= i

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lst = list(map(int, input().split()))
mult = 1
i = 0

while i < len(lst):
    mult *= lst[i]
    i += 1

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

if ans > max_limit:
  print(str(-1))
else:
  print(str(ans))

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':

	INF = 10**18
	
	n = int(input())
	A = list(map(int,input().split()))

	ans = 1
	flg = False

	for i in range(n):
		if A[i] == 0:
			ans = 0
			break
		ans = 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=A[0]
for cnt in range(N-1):
    ans = ans * A[cnt+1]

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int, input().split()))
ans=1
for i in 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()))

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(N):
    A_sum = A_sum * A[i]
    
    if A_sum == 0:
        break
    

if A_sum > 1e18:
        print(-1)

else:
    print(A_sum)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

ans = 1

for item in A:
    ans *= item

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

Submission status: Time Limit Exceeded

Solution code:
if __name__ == "__main__":
    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:
from functools import reduce

if __name__ == "__main__":
    N = int(input())
    A = input().split()
    ans = 1
    for i in range(N):
        ans *= int(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 a in A: ans *= a

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

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

U = 10**18
ret = 1

for x in A:
  ret *= x
  if ret > U:
    ret += 1
    
if ret > U:
  ret = -1

print(ret)

Submission status: Time Limit Exceeded

Solution code:
import sys

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

U = 1e18
ret = 1
for x in A:
  ret *= x
  if ret > U:
    ret += 1
if ret > U:
  ret = -1

print(ret)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

if __name__ == "__main__":
    N = int(input())
    A = input().split()
    ans = reduce(lambda x,y:int(x)*int(y), A)

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

if __name__ == "__main__":
    N = int(input())
    A = input().split()
    ans = 0

    ans = reduce(lambda x,y:int(x)*int(y), A)
        

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

Submission status: Time Limit Exceeded

Solution code:
import sys

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

def solve():
  ret = 1
  for x in A:
    ret *= x
    if ret > 1e18:
      ret += 1
  if ret > 1e18:
    ret = -1
  return ret

print(solve())

Submission status: Time Limit Exceeded

Solution code:
import sys

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

def solve():
  ret = 1
  for x in A:
    ret *= x
  if ret > 1e18:
      ret += 1
  if ret > 1e18:
    ret = -1
  return ret

print(solve())

Submission status: Time Limit Exceeded

Solution code:
import sys

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

def solve():
  ret = 1
  for i in range(N):
    ret *= A[i]
  if ret > 1e18:
      ret = -1
  return ret

print(solve())

Submission status: Time Limit Exceeded

Solution code:
input();a=sorted(map(int,input().split()));z=1
for i in a:z*=i
if z>1e18:z=-1
print(z)

Submission status: Time Limit Exceeded

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

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

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

print(ANS)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

N = int(stdin.readline())
A = list(map(int, stdin.readline().split()))

ans = 1

if 0 in A:
    ans = 0

if ans:
    for a in A:
        ans *= a
        if ans > pow(10, 18):
            ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

N = int(stdin.readline())
A = list(map(int, stdin.readline().split()))

ans = 1

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

N = int(stdin.readline())
A = list(map(int, stdin.readline().split()))

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

Submission status: Time Limit Exceeded

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

if 0 in S:
    print(0)
elif 10 ** 18 in S:
    print(-1)
else:
    ans = 1
    for s in S:
        ans *= s
    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()))
ans = 1

for s in S:
  ans *= s
  
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()))

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

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

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()))
x=1
flag=1
for i in range(n):
  if A[i]==0:
    print(0)
    exit()
  else:
    x*=A[i]

if x>10**18:
  flag=0
  

if flag==1:
  print(x)
else:
  print("-1")

Submission status: Time Limit Exceeded

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

if x>10**18:
  flag=0
  

if flag==1:
  print(x)
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 and 0 not in a:
    print(-1)
    break
else:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
num = int(input())

k = input().split()

mul = 1

for i in range(num):
    mul *= int(k[i])

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

else:
    print(mul)

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def prod(li):
  pd = 1
  for l in li:
    pd *= l
  return pd
 
if __name__ == '__main__':
  n = input()
  a = [int(x) for x in input().split()]
  prd = prod(a)
  if prd > int(1e+18):
    print(-1)
  else:
    print(prd)

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:
def resolve():
    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)

if '__main__' == __name__:
    resolve()

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
import operator
_ = input()
M = reduce(operator.mul, [int(v) for v in input().split()])

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#
# author Sidratul
#

from math import prod

if __name__ == '__main__':
    n = input()
    a = list(map(int, input().split(' ')))
    s = prod(a)
    if s > 10**18:
        print(-1)
    else:
        print(s)

Submission status: Time Limit Exceeded

Solution code:
#
# author Sidratul
#

from functools import reduce

if __name__ == '__main__':
    n = input()
    a = list(map(int, input().split(' ')))
    s = reduce((lambda x, y: x*y), a)
    if s > 10**18:
        print(-1)
    else:
        print(s)

Submission status: Time Limit Exceeded

Solution code:
#
# author Sidratul
#

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

Submission status: Time Limit Exceeded

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

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

for i in A:
    sum *= i

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

Submission status: Time Limit Exceeded

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

for i in A:
    sum *= i

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

Submission status: Time Limit Exceeded

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

for i in A:
    sum *= i

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

Submission status: Time Limit Exceeded

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

for i in A:
    sum *= i

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

Submission status: Time Limit Exceeded

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

for i in range(int(N/2)):
    sum1 *= A[i]
    sum2 *= A[N-i-1]

sum = sum1 * sum2
if N % 2 == 1:
    sum *= A[int(N/2)]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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 *= A_list[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(ans)
else:
  print(-1)

Submission status: Time Limit Exceeded

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

product = 1
for x in v:
  product *=  x
  
if product > 1000000000000000000:
  print(-1)
else:
  print(product)

Submission status: Time Limit Exceeded

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

c=1

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

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

Submission status: Time Limit Exceeded

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

for i in A:
    ans=ans*i
if ans>1000000000000000000:
    print(-1)
    exit()

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
arr = str(input())
lst =[]
for i in arr.split():
    lst.append(i)
multi = 1
for i in lst:
    multi *= int(i)
if multi > pow(10,18): print(-1)
else: print(multi)

Submission status: Time Limit Exceeded

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

ans = 1
for i in A:
  if any(j == 0 for j in A) == True:
    ans = 0
    break
  ans *= i
  if ans > 10**18:
    ans = -1
    break

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#b問題
n=int(input())
ans=1
a=list(int(y) for y in input().split())
# print(a)
if 0 in a:
    print(0)
else:
    for i in range(n):
        ans*=a[i]
        if ans>10**18:
            ans=-1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
#b問題
n=int(input())
ans=1
a=list(int(y) for y in input().split())
# print(a)
for i in range(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 = 1
for i in range(n):
    ans *= a[i]
    
if ans <= 10**18:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
#import numpy as np

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

#ans = np.prod(Alist)
Alist.sort()
ans = 1
for i in range(N):
  #print (Alist[i])
  ans*= Alist[i]
  if Alist[i]==0:
    break

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