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:
#!/usr/bin/env pypy
from __future__ import division, print_function
from collections import defaultdict, Counter, deque
from future_builtins import ascii, filter, hex, map, oct, zip
from itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement
from __builtin__ import xrange as range
from math import ceil, factorial, log,tan,pi,cos,sin,radians
from _continuation import continulet
from cStringIO import StringIO
from io import IOBase
import __pypy__
from bisect import bisect, insort, bisect_left, bisect_right
from fractions import Fraction
from functools import reduce
from decimal import *
import string
import sys
import os
import re
inf = float('inf')
mod_ = int(1e9) + 7
mod = 998244353

def factors(n):
    from functools import reduce
    return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))

def sieve(m):
    n=1
    primes = {}
    arr=set([])
    for i in range(2, int(m ** 0.5) + 1):
        a = n // i
        b = m // i
        for k in range(max(2, a), b + 1):
            c = i * k
            primes[c] = 1

    for i in range(max(n, 2), m + 1):
        if i not in primes:
            arr.add(i)

    return arr


class DisjointSetUnion:
    def __init__(self, n):
        self.parent = list(range(n))
        self.size = [1] * n
        self.num_sets = n
 
    def find(self, a):
        acopy = a
        while a != self.parent[a]:
            a = self.parent[a]
        while acopy != a:
            self.parent[acopy], acopy = a, self.parent[acopy]
        return a
 
    def union(self, a, b):
        a, b = self.find(a), self.find(b)
        if a != b:
            if self.size[a] < self.size[b]:
                a, b = b, a
 
            self.num_sets -= 1
            self.parent[b] = a
            self.size[a] += self.size[b]
 
    def set_size(self, a):
        return self.size[self.find(a)]
 
    def __len__(self):
        return self.num_sets



def main():
    n=int(input())
    prod=1
    arr=list(map(int,input().split()))
    for i in arr:
        if i==0:
            prod=0
            break

        prod*=i

    if prod>10**18:
        print(-1)
        exit()
    print(prod)
    # n,m=
    # print(n*m)












    



# region fastio

BUFSIZE = 8192

class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

printed = False
if 0 in a:
    print(0)
    printed = True

ans = 1

for x in a:
    ans *= x
    if ans > 1e18:
        if not printed:
            print(-1)
        printed = True
    
if not printed:
    print(ans)

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

ans = 1

for a in A:
    ans *= a

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

  m = 10 ** 18
  ans = A[0]

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

  if(ans > m):
    ans = -1

  print(ans)

if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


def main():
    limit = 10**18
    N = int(input())
    A = list(map(int, input().split()))
    assert N == len(A)
    answer = functools.reduce(operator.mul, A)
    # for i in A:
    #     answer *= i
    #     if answer > limit:
    #         print("-1")
    #         exit()
    print(answer) if answer <= limit 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(len(a)):
    ans *= a[i]
    
if ans > 10**18:
  print(-1)
  exit()
  
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1

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

Submission status: Time Limit Exceeded

Solution code:
n = input()
v = list(map(int, input().split()))
sum = 1
for i in v:
    sum *= i

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [num for num in 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())
num_list = map(int, input().split())

a = 1
for x in num_list:
  a = a * x
if a > 1000000000000000000:
  print("-1")
else:
	print(a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
MAX_VAL = 10 ** 18

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

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
from sys import stdin

drop = input()

li = [int(x) for x in stdin.readline().rstrip().split()]
result = functools.reduce(operator.mul, li)

lim = pow(10,18)

if lim < result :
	print (-1)
else :
	print(result)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=1
f=0
x=[int(x) for x in input().split()]
if x.count(0)>0:
    print(0)
else:
    for i in range(len(x)):
        s=s*x[i]
    if s>10**18:
        print(-1)
    else:print(s)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 1
v = []
v = [int(x) for x in input().split()]
for x in v:
	ans = ans*x
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
if 0 in a:
    ans = 0
else:
    for i in a:
        ans *= i
        if ans > 1000000000000000000:
            ans = -1
print(ans)

Submission status: Time Limit Exceeded

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

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

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()))
mat = 1
upper = pow(10,18)
fl=1
for i in A:
    if i==0:
        fl=2
        break
    mat = mat * i
    if mat > upper:
        fl=3
if fl==2:
    print(0)
elif fl==3:
    print(-1)
else:
    print(mat)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)
n = int(input())
a = list(map(int,input().split()))
ans = int(prod(a))
print(ans if ans <= 10**18 else -1)

Submission status: Time Limit Exceeded

Solution code:
# from itertools import accumulate
# from operator import add, mul

n = int(input())

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1
burst = False
zero = False
for k in K:
    if k == zero:
        zero = True
        break
    ans *= k
    if ans > 10**18:
        burst = True
if zero:
    print(0)
elif burst:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int,input().split()))
ans=1
way=0
for i in A:
    ans*=i
way=str(ans-1)
if(len(way)>=19):
    ans=-1
else:
    pass
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==0:
    break
if ans>10**18:
  ans=-1
print(ans)

Submission status: Time Limit Exceeded

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

ans = 1

for i in A:
    ans = ans*i

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

Submission status: Time Limit Exceeded

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

import operator
from functools import reduce
if reduce(operator.mul, values) > 10**18:
  print(-1)
else:
  print(reduce(operator.mul, values))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

As = 1
for i in range(N):
    As = As*A[i]
if 1000000000000000000 < As:
    print(-1)
else:
    print(As)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


import functools
import operator
total_product = functools.partial(functools.reduce, operator.mul)
ans = total_product(a)

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

if 0 in a:
    ans = 0
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def ABC_169_B():
    N=int(input())
    A = input().split()
    A = [int(s) for s in A]
    sum=1

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


if __name__ == '__main__':

    ABC_169_B()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a_lst = list(map(int, input().split()))
x = 10 ** 18
ans = 1
for i in range(n):
    ans *= a_lst[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
L=list(map(int,input().split()))
ans=1
for i in range(n):
    ans=ans*L[i]
    if L[i]==0:
        break

if ans > 1e18:
    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
    b.sort(reverse=True)
    for i in b:
        if  0 in b:
            ans = 0
            break
        ans *= i
        if ans > 10 ** 18:
            ans = -1
            break
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

N = int(input())
A = [int(x) for x in input().split(" ")]
product = 1
for a in A:
    product = product * a
if product > 10 ** 18:
    print(-1)
    sys.exit(0)

print(product)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = input().split()
res = 1
for i in a:
  res *= int(i)
if res > 10 ** 18:
  res = -1
print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
arr = input()   # takes the whole line of n numbers
l = list(map(int,arr.split(' '))) #
ans = 1
for i,v in enumerate(l):
    ans *= v
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()))

if n != 0 :
    ans = a_list[0]
else :
    ans = 0

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

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


print(ans)

Submission status: Time Limit Exceeded

Solution code:
def solve(N, A):
    ret = 1
    upper = 10**18
    for a in A:
        ret *= a
    return ret if ret <= upper else -1

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

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

Submission status: Time Limit Exceeded

Solution code:
a=int(input())
b=input().split(' ')
m=0
s=1
while m<a:
    s=s*int(b[m])
    m=m+1
if s>10**18:
    print(-1)
else:
    print(s)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
ans = a[0]
for i in range(n-1):
    ans *= a[i+1]

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

else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

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

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

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

Submission status: Time Limit Exceeded

Solution code:

def main():
    import sys
    import math
    def input():
        return sys.stdin.readline()[:-1]
    N=int(input())
    A=list(map(int,input().split()))
    c=1
    for x in A:
        c=c*x
    
    if c>10**18:
        print(-1)
        sys.exit()

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
L=list(map(int,input().split()))
M=1
for i in L:
    M=M*i
if M>1000000000000000000:
    print("-1")
else:
    print(M)

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:
# -*- 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:
        if 0 in input_list:
            ans = 0
        else:
            ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = input().split()
m = 1
for i in range(n):
    m = m * int(a[i])
    if m == 0:
        break
    

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 a in A:
  ans *= a
ans = -1 if ans > 10**18 else ans

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N=int(input())
    A=[int(n) for n in input().split()]
    p = 1
    ov = False
    for i in range(N):
        np = p * A[i]
        if np > 10**18:
            ov = True
        if A[i] == 0:
            print(0)
            return
        p = np
    if ov:
        print(-1)
    else:
        print(np)
main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

import functools
import operator

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import operator
from functools import reduce
n = input()
l = [int(each) for each in input().split()]
result = reduce(operator.mul,l)
if result > 10**18:
    result = -1
print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

limit = 10 ** 18
current = 1

maxFlag = False

for x in range(N):
    current *= A[x]

if current > limit:
    print(-1)
else:
    print(current)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:

def main():
  _n = int(input())
  ans = 1
  for num in map(int, input().split()):
    ans *= num

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

main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
def S(): return sys.stdin.readline().rstrip()
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()

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

if(ret > 1000000000000000000):
    ret = -1


print(ret)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
input()
*a, = 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:
n = int(input())

res = 1

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

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


if (res > 1000000000000000000):
    res = -1

print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1
for ll in l:
  ans *= ll
  
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 A:
    sum=sum*i
if sum>1000000000000000000:
    print(-1)
else:
    print(sum)

Submission status: Time Limit Exceeded

Solution code:
import sys
N = int(input())
A = map(int, input().split())
m = 1

for item in A:
    m *= item

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

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

result=1
for n in numbers:
  result *= n
  
if result > 10**18:
  result = -1
  
print(result)

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

Submission status: Time Limit Exceeded

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

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

maxa = 10 **18

ans = 1

for i in a:
  ans = ans * i

print(ans if maxa >= ans else -1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

N = int(input())
x = [int(i) for i in input().split()]
y = reduce(mul, x)

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    N = int(input())
    A = list(map(int, input().split()))

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

    # %%
    if answer > pow(10, 18):
        print(-1)
    else:
        print(answer)    

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
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)

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

Submission status: Time Limit Exceeded

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

for i in A:
  x = x*i  

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# ABC169 B Multiplication 2

from collections import deque

n = int(input())

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

ans = 1
for i in range(n):
    ans *= a_list.popleft()

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

Submission status: Time Limit Exceeded

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