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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
input()
l = map(int, input().split())
r = 1
for i in l:
    r *= i
print(-1 if r > 1e18 else r)

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

num_list = list(map(int, input().split()))
     
num = 1
     
for i in num_list:
    num *= i
     
if num > 10**18:
    num = -1
     
print(num)

Submission status: Time Limit Exceeded

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

lim = 10 ** 18
ans = 1

for i in A:
  ans *= i
  if ans > lim and A[-1] > 0:
    ans = -1
    break
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys, re
import math
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul	# 
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd	# 最大公約数
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

# -*- coding: utf-8 -*-

n = INT()
a = LIST()
ans = a[0]

for x in a[1:]:
    ans *= x
if ans > 10 ** 18:
   print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from math import log10

def main(N):
    A = list(map(int, input().split()))
    st_A = set(A)
    if 0 in st_A:
        print(0)
    else:
        x = 1
        for a in A:
            x *= a
        if x > 10**18:
            print(-1)
        else:
            print(x)




if __name__ == '__main__':
    N = int(input())
    main(N)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce
N=int(input())
A = list(map(int,input().split()))
c=reduce(mul, A)
if c > 10**18:
    print(-1)
else:
    print(c)

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

Submission status: Time Limit Exceeded

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

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

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 and 0 not in a_list:
            print(-1)
            return

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

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
n = int(input())
temp = input().split()
mul = 1
for i in temp:
    mul *= int(i)
if mul > 1000000000000000000:
    print('-1')
else:
    print(mul)

Submission status: Time Limit Exceeded

Solution code:

def main():
    N = map(int,input())
    A = list(map(int,input().split(' ')))
    MAX = 10**18
    ans = 1
    for a in A:
        ans *= a
    if ans > MAX:
        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 *= A[i]
    if ans > (10**18):
        ans = -1
        

print(ans)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

if ans > int(1e18):
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
max_int = 1000000001  # 10^9+1
min_int = -max_int

n = int(input())
a = map(int, sys.stdin.readline().split())

prod = 1
for one in a:
    if not one:
        print(0)
        break
    prod *= one
else:
    if prod > 10**18:
        print(-1)
    else:
        print(prod)

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:
N = int(input())
A = [int(n) for n in input().split()]
result = 1

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

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

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

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


prod = 1

for a in As:
    prod *= a

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1
for i in s:
    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 > 1000000000000000000:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = input()

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

out = 1 

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

MAX = 10**18

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

if res > MAX:
    print("-1")
else:
    print(res)

Submission status: Time Limit Exceeded

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

t = 1
for i in range(N):
    t = t * s[i]

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

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

read= sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 1000000007
sys.setrecursionlimit(10**7)


N = int(readline())

A = list(map(int,readline().split()))
res = 1
for i in range(N):
    res*=A[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

sum = A[0]
for i in range(1, N):
    sum = sum * A[i]
if sum <= 10**18:
    print(sum)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())

"""========main code==============="""
t=ii()

a=ll()
s=1
f=0
val=10**18
for i in a:
    s*=i
    
if s>val:
    print(-1)
else:
    print(s)

Submission status: Time Limit Exceeded

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

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

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

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

Submission status: Time Limit Exceeded

Solution code:
input()
a = input().split(' ')
s = 1
for x in a:
  s *= int(x)

if s > 1000000000000000000:
  s = -1

print(s)

Submission status: Time Limit Exceeded

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


n = int(input())
up = 10**18
l = list(map(int, input().split()))

ans = 1
for i in l:
    ans *= i
    if i == 0:
        ans = 0
        break
    
if ans > up:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

N = int(input())
A = list(map(int,input().split()))
result = functools.reduce(operator.mul, A)
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()))
cnt = 1
for i in A:
    cnt *= i

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

A=[0]*N
A=list(map(int,input().split()))
sum=1
flag=0
for i in range(N):
    sum*=A[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


def solve(N: int, A: "List[int]"):
    p = 1
    m = pow(10, 18)
    for n in A:
        p = p * n
    if p > m:
        return -1
    return p


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, A))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

mul = reduce(lambda x, y: x*y, A)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

sum = a[0]

for i in range(1,len(a)):
    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()))

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

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

print(ans)

Submission status: Time Limit Exceeded

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

res = 1
for a in lst:
    res = res*a

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

Submission status: Time Limit Exceeded

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

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

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
str_list = input().split()

result = 1

for i in range(n):
  result = result * int(str_list[i])
  
t = 1
for j in range(18):
  t = t * 10

if(result > t):
  print('-1')
else:
  print(result)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
cnt=1
for it in map(int,input().split()):
  cnt*=it
if cnt>1000000000000000000:
  print(-1)
else:
  print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = input().split(" ")

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

c = 1

for k in range(18):
  c = c * 10

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
An = []
mul = 1

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

for i in An:
    mul *= i

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
X = input().split()
c = 1

for k in range(N):
	c = c* int(X[k])

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

else:
	print(c)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

num = list(input().split())
ans = 1
for i in num:
    ans *= int(i)
    n *= len(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()))
result=1
for i in X:
  result*=i

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

print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if 0 in A:
    print(0)
else:
    out = 1
    for a in A:
        out *= a
    out = -1 if (out > 10 ** 18) else out
    print(out)

Submission status: Time Limit Exceeded

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

val_list = input().split()
answer = 0
for i, val in enumerate(val_list):
    if i == 0:
        answer = int(val)
    else:
        answer = answer * int(val)

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
#N, K = map(int, input().split())
# 文字列の入力
N = int(input())
#開業されたN個要素を受け付ける
#input_list = [int(input()) for i in range(N)]
input_list = list(map(int, input().split()))
ans = 1
for input in input_list:
    ans = ans*input

if ans > 1000000000000000000:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

mult = 1
A = list(map(int, input().split()))
try:
    for a in A:
        mult *= a
        
    if mult > 10**18:
        print("-1")
    else:
        print(mult)
except:
    print("-1")

Submission status: Time Limit Exceeded

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

A = 1
break_flag = 0
for i in range(N):
  A*=int(Nums[i])
  if A > 10**18:
    A = -1
    break_flag = 1
  if A == 0:
    break_flag = 2

if break_flag == 1:
  print(-1)
else:
  print(A)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from math import *
import sys, random

def nextInt():
    return int(input())
def nextStrs():
    return input().split()
def nextInts():
    return list(map(int,nextStrs()))

def main():
    n = nextInt()
    a = nextInts()

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

    if res > 1e18:
        return -1
    return res
    

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

res = 1

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


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

Submission status: Time Limit Exceeded

Solution code:
x1 = input()
x2 = [int(s) for s in input().split(" ") ]

if len(x2) >0 :
  result =  1
else :
  result =  0
for x in x2:
  result *= x 

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

Submission status: Time Limit Exceeded

Solution code:
from sys import exit
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())
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())
nums = input().split()
nums = [int(s) for s in nums]
result = 1
for num in nums:
  result = result * num
if 10**18 < result:
  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 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
th = 10**18

for i in a:
    ans *= i
if ans <= th:
    print(ans)
else:
    print(-1)

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

res = A[0]

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

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

print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans=1

for num in a:
    ans*=num

Inf=10**18

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

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

Submission status: Time Limit Exceeded

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

for a in A:
  ans *= a

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

Submission status: Time Limit Exceeded

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil, floor, sqrt, gcd
from copy import deepcopy

def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    num = 1000000000000000000
    ans = 1
    for i in range(n):
        ans *= a_list[i]

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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

N=int(input())
L=list(map(int, input().split()))
ans=functools.reduce(operator.mul, L)
print(ans if ans<=10**18 else "-1")

Submission status: Time Limit Exceeded

Solution code:
import math
def main():
    i = int(input())
    j = list(map(int, input().split()))
    res = 1
    for jj in j:
        res *= jj

    if math.pow(10, 18) < res:
        print(-1)
    else:
        print(res)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

for i in range(N):
    if i == 0:
        multiple = inputs[0]
    else:
        multiple *= inputs[i]

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

ans = 1

for a in ai:
    ans *= a

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from math import log10 as log

N = int(input())
A = [int(a) for a in input().split()]
if min(A) == 0:
    B = [0]
else:
    B = [log(b) for b in A]

ans = 1
if sum(B) > 18:
    ans = -1
else:
    for a in A:
        ans *= a
if ans > 10 **18:
    ans = -1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

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

mm = reduce(mul, a)

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

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:
from functools import reduce
from operator import add, mul

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

ans = reduce(mul,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(N):
    Answer *= A[i]

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

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

Submission status: Time Limit Exceeded

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

for i in range(0,len(P[0])):
    a=a*P[0][i]

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

Submission status: Time Limit Exceeded

Solution code:
import operator
import functools
N=int(input())
A=list(map(int,input().split(' ')))
if functools.reduce(operator.mul, A, 1)>10**18:
    print(-1)
else:
    print(functools.reduce(operator.mul, A, 1))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力

if __name__ == "__main__":
    
    N = int(input())
    INPUT = list(map(int, input().split()))

    output = 1
    for i in INPUT:
        output = output * i

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

    print(output)