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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

ans = 1;
for num in num_list:
    ans = ans * num

if ans > 1000000000000000000:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
N=int(input())
s = list(map(int, input().split()))
ans =1
for i in s:
    ans*=i
    
if ans>1e18:
    print(-1)
    sys.exit(0)

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

Submission status: Time Limit Exceeded

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

ans = 1
max_ans = 10**18
for num in num_list:
    ans = ans * num

if ans > max_ans:
    ans = -1


print(ans)

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

Submission status: Time Limit Exceeded

Solution code:
import collections


def main():
    max_n = 10**18
    n = int(input())
    a = input_list()
    ans = 1
    if 0 in a:
        print(0)
        exit()
    ac = collections.Counter(a)
    for i, k in ac.items():
        ans *= i**k
    if ans > max_n:
        print(-1)
    else:
        print(ans)

def input_list():
    return list(map(int, input().split()))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

for i in A:
  total*=i
  
if 1*(10**18)+1<=total:
  print("-1")
else:
  print(total)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline

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

a=10**18
ans=1
for i in l:
    ans*=i

if ans > a:print(-1);exit()
print(ans)

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
line = input().rstrip().split()
x = 1

for i in range(num):
  x = x * int(line[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()))


for i in range(N):
  if (i == 0):
    ans = a[0]
  else:
    ans = ans * a[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
nums = list(map(int, input().split()))
ans = 1
for i in nums:
    ans*= i
    if(ans > int(1e18) and 0 not in nums):
        break
if(ans > int(1e18)):
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:

def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    limit = 10**18
    _sum = 1
    for a in A:
        _sum *= a
    if _sum <= limit:
        print(_sum)
    else:
        print(-1)

if __name__ == "__main__":
    resolve()

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 == 0:
        print(0)
        exit()
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()]

from operator import mul
from functools import reduce

ans = reduce(mul,a)
if ans <= pow(10,18):
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
sum = 0
A = list(map(int,input().split()))
Asum = 1
flag = 0
for i in A:
    Asum = Asum * int(i)
if Asum > 10**18:
    flag = 1

if flag == 0 :
    print(Asum)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = input()
l = [int(e) for e in input().split(" ")]
res = 1
for e in l:
    res = res*e
if res > 1e+18:
    print("-1")
else:
    print(res)

Submission status: Time Limit Exceeded

Solution code:
import sys
n = int(input())
s = input().split()

result = 1
for i in range(n):
    result = result * int(s[i])
    
if result > (10 ** 18):
    print(-1)
    sys.exit()

print(result)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

n = int(input())
a = [int(arg) for arg in input().split()]
res = reduce(lambda x, y: x*y, a)
print(res if res <= 10**18 else -1)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
Al=list(map(int,input().split()))
S=1
for i in range(N):
    S*=Al[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lst = list(map(int,input().split()))
output = 1
for m in lst :
    output *= m
if output <= 1000000000000000000 :
    print(output)
else :
    print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

result = 1

for e in A:
    result *= e

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 1
arr = [int(x) for x in input().split()]
for i in range(n):
  ans *= arr[i]

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

Submission status: Time Limit Exceeded

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

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

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
v=True
for i in arr:
    ans=ans*i

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

Submission status: Time Limit Exceeded

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

ans = 1

p = 10 ** 18

flg = False
flg_2 = False

for a in A_list:
    ans *= a

if ans > p:
    ans = -1


print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
n = input()
s = list(map(int, input().split()))
a = 1
flag0 = False
flag = True
for i in s:
  a*=i
  if a > 1000000000000000000:
    flag = False
  if i == 0:
    flag0 = True
if flag0:
  print(0)
elif flag:
  print(a)
else:
  print(-1)

Submission status: Time Limit Exceeded

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

ans = 1
flag = False
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:
from math import *

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def main():
    a = cino()
    l = cina()
    check = True
    suma = 1
    for i in l:
        suma = suma*i
    if suma>1e18:
        print(-1)
    else:
        print(suma)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
# your code goes here
n = int(input(""))
a = input("").split()
res = 1
for e in range(n):
	res *= int(a[e])
if res > 1000000000000000000:
	print(-1)
else:
	print(res)

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:
import functools
_ = input()
l = list(map(int, input().split(" ")))

ans = functools.reduce(lambda x, y : x* y, l, 1)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

res = 1

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

    if a[i] == 0:
        break


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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

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

res = 1
thr = 10**18
for a in A:
    res *= a

    if res > thr:
        res = -1

if 0 in A:
    res = 0

print(res)

Submission status: Time Limit Exceeded

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

ans = 1
for i in range(len(a)):
    ans *= a[i]
    if ans > 10 ** 18 and 0 not in a:
        print(-1)
        exit()

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

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

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

if prod(A) > INF:
    print(-1)
else:
    print(prod(A))

Submission status: Time Limit Exceeded

Solution code:
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

n = ni()
m = nl()
res = 1
for i in m:
    res *= i
print(res if not res > 10**18 else -1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if ans<0:
  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(len(A)):
  ans *= A[i]
  
if ans > 10**18:
  ans = -1
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a_list = list(map(int,input().split()))
ans = 1
for i in a_list:
    ans *= 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()))
s = 1
x = 0
y = 0
for i in range(n):
    s *= a[i]
    if a[i] == 0:
        y += 1
    if s > 1000000000000000000:
        x += 1

if y != 0:
    print(0)
else:
    if x != 0:
        print(-1)
    else:
        print(s)

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

answer = A[0]
overl = False

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

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

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

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

Submission status: Time Limit Exceeded

Solution code:
LIMIT = 1000000000000000000

def main():
    N = int(input())  # 文字列または整数(一変数)
    a = list(map(int, input().split()))  # 整数のリスト

    answer = 1

    for i in a:
        answer = answer * i

    if answer > LIMIT:
        print(-1)
    else:
        print(answer)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:

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

Submission status: Time Limit Exceeded

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


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    limit = 10 ** 18

    ans = 1
    for i in a:
        ans *= i
    if ans > limit:
        ans = -1

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

p = 1

for e in a:
  p *= e

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

Submission status: Time Limit Exceeded

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

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

    if ans == 0:
        break

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
Ai = [0] * N
Ai = list(map(int,input().split()))
Ans = 1

for i in range(N):
  Ans = Ans * Ai[i]
  
if Ans <= 10**18:
  print(Ans)
else:
  print('-1')

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from sys import exit
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())
X = list(map(int, input().split()))
Y = 1
for i in range(0, N):
  Y = X[i] * Y
if Y <= 10 ** 18:
  print(Y)
else:
  print(-1)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for a in A:
    result *=a


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

Submission status: Time Limit Exceeded

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

# print(n)

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

if(mul > 1_000_000_000_000_000_000):
    print(-1)
else:
    print(mul)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
_ = input()
inp = map(int, input().split())

of = False
re = 1

for a in inp:
    re *= a


if (re - 1) // (10**18) > 0:
    re = -1

print(re)

Submission status: Time Limit Exceeded

Solution code:
import sys
N = int(input())
A = [int(n) for n in input().split()]
MAX = 10**18
ans = 1
for a in A:
    ans *= a
else:
    if ans > MAX:
        print("-1")
    else:
        print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

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

Submission status: Time Limit Exceeded

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

p = 1
for i in range(N):
  p = p*A_list[i]
  
if p >1e18:
  print('-1')
else:
  print(p)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
s=1
for i in range(n):
  l=a.pop()
  if l == 0:
    s=0
    break
  else:
    s=s*l

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce


def main():
    n = int(input())
    a_list = map(int, input().split())

    result = reduce(lambda a1, a2: a1*a2, a_list)

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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:

n = int(input())
nums = list(map(int, input().split()))
res = 1
for i in range(n):
    res *= nums[i]
if res <= 1000000000000000000:
    print(res)
else:
    print(-1)

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()))
sort = sorted(a)
ans = sort[0]

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

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

Submission status: Time Limit Exceeded

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

n = int(input())

a = inpl()

t = 1

for i in a:
    t *= i

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

Submission status: Time Limit Exceeded

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

x = 1000000000000000000
res = 1

for val in A:
    res = res * val

print(res if res <= x else '-1')

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
A = list(map(int, stdin.readline().rstrip().split()))

result = 1
for i in A:
    if i != 0:
        result = result * i
    else:
        print(0)
        exit()
        
    if result > 10**18 or result == -1:
        result = -1
print(result)

Submission status: Time Limit Exceeded

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

sum = 1
i = 0
while i < len(A):
    sum *= A[i]
    i+=1

if sum > 1000000000000000000:
    sum = -1

print(sum)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import math
import sys

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

INF = 1000000000000000000
if (sumans > INF):
    print(-1)
else:
    print(sumans)

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=[]
A=list(map(int,input().split()))
L=10**18
S=1
for i in range(N):
    S=S*A[i]
if S<=L:
    print(S)
else:
    print("-1")

Submission status: Time Limit Exceeded

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

sum = 1
flag = False
for i in A:
    sum = sum * int(i)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
c = 1
for i in range(len(a)):
    c = c*a[i]

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = 1
limit = 10**18
for x in input().split():
    x = int(x)
    ans *= x
    if(x==0):
        print(x)
        exit()


if(ans > limit):
        print(-1)
        exit()    
print(ans)

Submission status: Time Limit Exceeded

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

ans = 1
for i in range(n):
  if a[i] == 0:
    ans = 0
    break
  else:
    ans *= a[i]

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

a = list(input().split())
a = [int(i) for i in a]
ans=1
for i in a:
  ans = ans*i

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

Submission status: Time Limit Exceeded

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

ans = 1

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
L_A = [int(s) for s in input().rstrip().split(' ')]
k = 1
for i in range(N):
    if L_A[i] == 0:
        print(0)
        break
    else:
        k *= L_A[i]
else:
    if k > 10**18:
        print("-1")
    else:
        print(k)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
 
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
 
def main():
  K = int(input())
  s = list(map(int, input().split()))
  prod = 1
  for k in range(K):
    prod = prod * s[k]
  if prod > 10 ** 18:
    print(-1)
  else:
    print(prod)

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

Submission status: Time Limit Exceeded

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

ans = 1
flag = 0
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        flag = 1

if flag == 1 and ans != 0:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

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

if ans>1e18:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1
for num in nums:
    ans *= num
    
if ans <= (10**18):
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

ans = 1

for i in range(N):
  ans *= A[i]
if ans <= 1e18:
  print(ans)
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')
    exit(0)
print(ans)

Submission status: Time Limit Exceeded

Solution code:

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

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


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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

a = int(stdin.readline())
A=stdin.readline().split()

product=1
K=0

for k in range(0,a):
    if int(A[k])==0:
        product=0
        K=1
        break
if K==0:
   for b in range(0,a) :
       product=product*int(A[b])
   if product > 10 ** 18:
       product = -1



print(product)

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


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

Submission status: Time Limit Exceeded

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

ans = 1

for a in A:
    ans *= a

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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