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

print(ans)

Submission status: Time Limit Exceeded

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

LIMIT = 10 ** 18

res = 1

for a in A:
    res = res * a

if res > LIMIT:
    print('-1')
else:
    print(res)

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())
aa = map(int, input().split())
s = math.prod(aa)
if s > 10**18:
    print(-1)
else:
    print(s)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
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:
import sys
input = sys.stdin.readline

"""

"""

tot = 1
n = int(input())
arr = map(int, input().split())

for v in arr:
    tot *= v

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

product = 1

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
#sys.stdin = open("input.txt", "r")
#sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)


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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

if tmp <=ans:
    print(tmp)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


N = int(input()) # 1行, 単数

arg = list(map(int, input().split())) # 1行, 配列
m = 1

for A in arg:
  m = A * m

if m - 1000000000000000000 > 0:
  print('-1')
else:
  print(m)

Submission status: Time Limit Exceeded

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

for i in A:
    Result = Result*i

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

Submission status: Time Limit Exceeded

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

for i, b in enumerate(A):
    if i == 0:
        pass
    else:
        X = X * b

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

Submission status: Time Limit Exceeded

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

if ans<0:
  ans=-1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
big = 10**18
bad = False
n = int(input())
start = 1
numbs = list(map(int, input().split()))
for x in numbs:
	start *= x
if start > big:
	bad = True


print(-1) if bad else print(start)

Submission status: Time Limit Exceeded

Solution code:
import sys

N = int(input())
As = [int(n) for n in input().split()]

limit = 10**18
over = False

prod = 1
for A in As:
    prod *= A
    if prod > limit:
        over = True
    if prod == 0:
        print(0)
        sys.exit(0)

if over:
    print(-1)
    sys.exit(0)
else:
    print(prod)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
import math
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

a = inp()
b = inpl()
ans = 1
for i in b:
    ans *= i
if ans <= 1000000000000000000:
    print(ans)
else:
    print(-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 = ans * As[i]
  
if (ans > 10**18):
  print(-1)
else:
  print(ans)

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 = ans*A[i]

if ans<=10**18:
    print("{}".format(ans))

else:
    print("{}".format(-1))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
a_list = list(map(int, input().split()))
ans = 1
flag = 1
for a in a_list:
    ans *= a
    if ans > 10 ** 18:
        flag = 0
    if a == 0:
        flag = 1
if flag == 0:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#---
N = int(input())
List = list(map(int, input().split()))

multi = 1
for i in range(N):
  multi = multi * List[i]

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

Submission status: Time Limit Exceeded

Solution code:
# ABC169 B Multiplication 2

n = int(input())

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

ans = 1
for i in range(n):
    ans *= a_list[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()))

s = 1
l=10**18

for i in a:
    s *= i
    if i > l:
        print(-1)
        exit()
if s > l:
    print(-1)
else:
    print(s)

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:
from functools import reduce

A = int(input())
lst = [int(x) for x in input().split()]
res = reduce(lambda a, b: a * b, lst)
print(res if res <= pow(10, 18) else -1)

Submission status: Time Limit Exceeded

Solution code:
import math

def main():
    # tt = int(input())
    
    tt = 1
    for _ in range(0, tt):
        n = int(input())
        
        arr = input().split(' ')
        ans = 0
        mult = 1
        j = 0

        for i in range(0, n):
            mult *= int(arr[i])

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline

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

m = 1
for i in AS:
    m = m * i

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

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

if ans <= 1e18: print(ans)
else: print(-1)

Submission status: Time Limit Exceeded

Solution code:
import math

# for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
p = 1
if 0 in a:
    print(0)
else:
    for i in range(len(a)):
        p = p * a[i]

    if p > math.pow(10, 18):
        print(-1)
    else:
        print(p)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

total = 1
for i in List:
  total = total*i

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

Submission status: Time Limit Exceeded

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

ans = 1
for i in range(n):
    ans *= c[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()))
t = 1
for i in range(n):
    t = t*a[i]
    if t == 0:
        print("0", end="")
        exit()
if t > 10**18:
    print("-1", end="")
    exit()
print(t, end="")

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

if ans > 1000000000000000000:
    print(-1)
    exit()
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
    #print(ans)
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()))
from itertools import accumulate
import operator
cumprod = list(accumulate(a, operator.mul))[-1]

print(-1 if cumprod > 10**18 else cumprod)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
q = int(input())
l = input().split()
x = 1
for i in range(0, q, 1):
    x *= int(l[i])
if x > 1000000000000000000:
    print(-1)
else:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

f = functools.partial(functools.reduce, operator.mul)

_ = input()
A = list(map(int, input().split()))
res = f(A)
if res > 10**18:
    print(-1)
else:
    print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul

n = int(input())
numbers = tuple(map(int, input().split(' ')))

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

Submission status: Time Limit Exceeded

Solution code:
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = 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:
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
#from collections import deque
#import heapq
#from fractions  import gcd
input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
ans=1
for i in range(n):
    ans*=a[i]
if ans>pow(10,18):
  print(-1)
  
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    a = int(input())
    b = [int(i) for i in input().split()]
    ans = 1

    for i in b:
        if  0 in b:
            ans = 0
            break
        ans = ans*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()))
lim = 10**18
ans = 1
for i in range(n):
  ans = ans*a[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
re = 1

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

for i in range(n):
    re = re * li[i]
if re > 1000000000000000000:
    print(-1)
else:
    print(re)

Submission status: Time Limit Exceeded

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



if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

total = 1
flag = 9
for i in range(N):
  total *= A[i]
  if total > 10**18:
    flag = 0
    break
  elif min(A) == 0:
    flag = 1
    break
if flag == 0:
  print(-1)
elif flag == 1:
  print(0)
else:
  print(total)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

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

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

Submission status: Time Limit Exceeded

Solution code:
N = input()
a = input().split()
ans = 1
for i in a:
    ans *= int(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()]
result = 1
for i in a:
  result = result * i
if result > 1000000000000000000:
  print('-1')
else:
  print(result)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

result = 1
for n in map(int, input().split()):
    result *= n

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

Submission status: Time Limit Exceeded

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

for a in A:
    ans = ans*a

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    a=1
    l=[int(x) for x in input().split()]
    for i in range(len(l)):
        a=a*l[i]
        
    if a>10**18:
        a=-1
    print(a)
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(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>1000000000000000000:
    print("-1")
else:
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
A = LI()
ans = A[0]
for i in range(1, N):
    ans = ans*A[i]
if ans > 10**18:
    ans = -1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

# print('input >>')
N = int(input())
As = list(map(int,(input().split())))

INF = 10 ** 18

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

if ans > INF:
    ans = -1

# print('-----output-----')
print(ans)

Submission status: Time Limit Exceeded

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

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

if sum>pow(10,18):
    sum = -1

print(sum)

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 a == 0:
        print(0)
        break

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

Submission status: Time Limit Exceeded

Solution code:
def solve(a):
    ans = 1
    for i in a:
        ans *= i
    if ans > 10**18:
        return -1
    else:
        return ans

if __name__ == '__main__':
    n = int(input())
    a = list(map(int,input().split()))
    print(solve(a))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
aa = [int(x) for x in input().split()];
ans = 1
for a in aa:
    ans *= a
if ans > 1e18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
count = int(input())
num = []
num = input().split()

total = 1
for i in range(count):
    total = int(num[i])*total
    
if total > 10**18:
    total = -1
    
print(total)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

A = input().split()
result = 1

for i in A:
    result *= int(i)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

l = []
ans = 1
l = input().split(' ')
for i in range(n):
  x = int(l[i])
  ans *= x

if ans > 1e18:
  ans = -1
print(ans)

Submission status: Time Limit Exceeded

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

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

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
# h1, m1, h2, m2, k = list(map(int, input().split()))
#a, b = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
#p = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# py = [list(map(int, input().split())) for i in range(m)]
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
    # print(ans)
    if ans > 1000000000000000000 and not(0 in a):
        print(-1)
        exit()
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
n = int(input())
a = list(map(int, input().split()))
ans = a[0]

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

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

Submission status: Time Limit Exceeded

Solution code:
n = input()

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


temp = pow(10, 18)
ans = 1
flag = 0

for i in a:
    ans = ans * i

if ans <= temp:
    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 *= li[i]
if(ans>1000000000000000000):
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
###############################################################################
#Imports
import collections
import itertools
from functools import lru_cache
import sys
import math
###############################################################################
#Constants
MOD = int(1e9)+7
###############################################################################
#Helper
def helper():
	pass
###############################################################################
#Solver
def solve():
	n = int(input())
	arr = list(map(int, input().split(' ')))
	sm = 1
	for num in arr:
		sm *= num
	if sm > int(1e18):
		print(-1)
		return
	print(sm)

###############################################################################
#Driver
t = 1
for _ in range(t):
	solve()
###############################################################################

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

if s > 1000000000000000000:
    s = -1

print(s)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

import functools
import operator

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

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()))
answer = A[0]
for i in A:
    answer *=i
answer //= A[0]
if answer>10**18:
    print("-1")
else:
    print(answer)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n = input()
cut = 10**18
nums = list(map(int,input().split(" ")))

ans = 1
for i in nums:
  ans = ans*i
if ans > cut:
  print("-1")
else:
  print(ans)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

if 0 in a_list:
  print(0)
  
else:
  num = 1
  for a in a_list:
    num *= a
  if num > 1E18:
    print(-1)
  else:
  	print(num)