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()))
s =  1
f=0

for a in A:
    s = s*a

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
M=[int(_) for _ in input().split()]
a=1
for s in M:
    a=a*s
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

exit
for i in a:
    ans *= i

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

Submission status: Time Limit Exceeded

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

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

if ans<1000000000000000001:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

import sys
# import math
# sys.setrecursionlimit(10**8)
# INF = float('inf')
# PI = math.pi()
# from functools import lru_cache
# @lru_cache(maxsize=None)

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

ans = 1
for item in a:
    ans=ans*item
if ans>10**18:
    print(-1)
    sys.exit()
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
def main():
    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)
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 > 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*= l[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()))
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()]

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:
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()))
flag = 1
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()))
answer = 1
for i in range(len(A)):
    answer *= A[i]

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
from math import log10


def _i(): return int(sys.stdin.readline().strip())


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    _ = _i()
    a = list(_ia())
    tmp = 0 if min(a) == 0 else sum(log10(ai) for ai in a)
    if tmp < 19:
        ret = 1
        for ai in a:
            ret *= ai
        if ret <= 10**18:
            return ret

    return -1


if __name__ == "__main__":
    print(main())

Submission status: Time Limit Exceeded

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

mul = 1
for a in A:
    mul *= a
    if mul == 0:
        break
    elif mul > 10 ** 18:
        mul = -1

print(mul)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

def main():
    n = int(input())
    array = list(map(int, input().split()))
    ans = 1
    for i in range(n):
        ans *= array[i]
        re = 10 ** 18

    
    if ans > re:
        print(-1)
    else:
        print(ans)
    return 0
        
main()

Submission status: Time Limit Exceeded

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

ans = A[0]


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

if ans > MAX:
    ans = -1

print(str(ans))

Submission status: Time Limit Exceeded

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

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

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

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

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

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())
num_list = list(map(int, input().split()))
ans = num_list[0]
for i in range(1, N):
    ans *= num_list[i]

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

Submission status: Time Limit Exceeded

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

result = reduce(mul, a_list)
if result > 10**18:
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

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

ans = 1

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

if ans // (10 ** 18 + 1) != 0:
    ans = -1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
n = int(input())
lis = list(map(int,input().split()))
num = reduce(lambda x,y: x * y, lis)
print(num if num <= 10**18 else -1)

Submission status: Time Limit Exceeded

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    MAX_V = 10 ** 18

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

    ans = 1
    for a in A:
        ans *= a
        if ans > MAX_V:
            ans = -1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n= map(int, input().split())
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:
n=int(input())
l=list(map(int,input().split()))

f=1
c=0
for i in l:
    f*=i
    
if f > 10**18:
    print(-1)
else:
    print(f)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    # N, D = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    a_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([a_list]))
    b = 10**18

    a = 1
    for _a in a_list:
        a *= _a

    if a > b:
        print(-1)
    else:
        print(a)


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2
1000000000 1000000000"""
        output = """1000000000000000000"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3
101 9901 999999000001"""
        output = """-1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """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"""
        output = """0"""
        self.assertIO(input, output)

Submission status: Time Limit Exceeded

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

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:
import sys
import copy
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
maxr = 10**18
_ = ni()
a = na()
res = 1
for item in a:
    res *= item

print(res if res <= maxr else -1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

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


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


print(val if val<=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 = 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()))
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())
X = list(map(int, input().split()))

x = 1

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = map(int, input().split())
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:
from operator import mul
from functools import reduce

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

ans = reduce(mul, A)
if ans > 10**18: ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 1
    for i in a:
        ans *= i 
    if ans <= 1e18:
        print(ans)
    else:
        print(-1)

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    A = list(map(int,input().split()))
    C = 1
    for i in range(N):
        C *= A[i]
    if C > 10**18:
        C = '-1'
    print(C)
    
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
List = list(map(int, input().split()))
a=1

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

Submission status: Time Limit Exceeded

Solution code:
#from pprint import pprint
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from copy import deepcopy
#from itertools
#from bisect import bisect_right #二分探索用のモジュール bisect_right(a_list,value)

#import sys 
#sys.setrecursionlimit(N) #N回まで再起を許可する。

# = int(input())

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

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

# = [list(map(int,input().split())) for _ in range(XXXX)]

n = int(input())

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

result = 1

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

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
MAX_RSESULT = 1000000000000000000

result = 1
for ai in a:
    result *= ai
if result <= MAX_RSESULT:
    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

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

Submission status: Time Limit Exceeded

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

ans = 1

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
# 初期入力
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
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())

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

ans = 1

for i in t:
  ans *= i

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

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

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

else:
    print(mul)

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    a = list( map( int, input().split()))
    sum = 1
    for i in a:
        sum = sum * i
    if sum >1000000000000000000:
        print(-1)
    else:
       print(sum)
    
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
"""
~~ Author : Bhaskar
~~ Dated : 31~05~2020
"""

import sys
from bisect import *
from math import floor,sqrt,ceil,factorial as F,gcd,pi
from itertools import chain,combinations,permutations,accumulate
from collections import Counter,defaultdict,OrderedDict,deque
from array import array
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
mod = 1000000007
lcm = lambda a,b : (a*b)//gcd(a,b)
setbit = lambda x : bin(x)[2:].count("1")

def solve():
    n = int(sys.stdin.readline())
    a = list(map(int,sys.stdin.readline().split()))
    ans=  1
    flag = False
    for i in a:
        ans *= i
    print(ans if ans<=10**18 else -1)

if __name__ == "__main__":
    solve()

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

N = intinp()
A = list(mapint_inp())

lim = 10**18
ans = 1
f = True
for A_i in A:
    ans = ans*A_i
    if 0 in A:
        ans = 0
        break
    if ans > lim:
        f = False
        break

if f:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:

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

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

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:
#!/usr/bin/env python3
n = int(input()) 
A = list(map(int, input().split()))
i = 10 ** 18
ans = 1
for a in A:
    ans = ans * a
if ans > i:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

def main():

    input = stdin.readline

    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)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if reduce(mul, A) > 10**18:
    print(-1)
    exit()
else:
    print(reduce(mul, A))

Submission status: Time Limit Exceeded

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

mult = 1
for i in range(N):
    mult = mult*A[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()))

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

import math
total=1
for i in range(n):
    total*=a[i]

if  total>pow(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 > 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:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

ans = 1
LIM = 10 ** 18
for a in A:
    ans *= a

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

Submission status: Time Limit Exceeded

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

ans = 1
for a in A:
    ans *= a
if ans > 1e18:
    ans = -1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

    INF = 10 ** 18

    res = 1

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

    if res > INF:
        res = -1

    print(res)



main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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 itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from operator import mul

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

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

Submission status: Time Limit Exceeded

Solution code:
n = input()
As = list(map(int,input().split()))
out = 1
for A in As:
    out = out * A

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

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