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()))
res = 1
for a in A:
  res *= a
if res > 1e18:
  print(-1)
else:
  print(res)

Submission status: Time Limit Exceeded

Solution code:
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n=int(input())
A=input_array()
MAX=10**18
ans=1

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n=int(input())
a=[0]*2
total=1
a=([int(x) for x in input().split()])
for i in range(n):
    total=total*a[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
 
n = int(input())
ms = list(map(int, input().split()))
 
if 0 in ms:
  r = 0
else:
  r = functools.reduce(operator.mul, ms)
if r > 10 ** 18:
  r = -1
print(r)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = 1
for i in range(n):
  b *= a[i]
  if 0 in a:
    b = 0
    break
  elif b > 10**18:
    break
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()))
b = 1
for i in range(n):
  b *= a[i]
  if b > 10**18 and not(0 in a):
    break
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()))

num = 1

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

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

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(lambda a : int(a), input().split(" ")))
ans = 1
for i in range(len(A)):
  ans *= A[i]
 
print(ans) if ans <= 10 ** 18 else print("-1")

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

ans = 1
for i in a:
    ans *= i
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")
    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 = ans*A[i]
    if 0 in A:
        ans = 0
        break
    elif ans > 10**18:
        ans = -1
        break
 
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 0 in A:
        ans = 0
    elif ans > 10**18:
        ans = -1
        break
 
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

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 > pow(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):
  if 0 in A:
    ans = 0
    break
  ans *= A[i]
  i += 1
  if ans > 10**18:
    ans = -1
    break

print(ans)

Submission status: Time Limit Exceeded

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

ans = 1

for i in range(N):
  if any(j == 0 for j in A) == True:
    print(0)
    break
  ans *= A[i]
  i += 1
  if ans > 10**18:
    print('-1')
    break
  if i == N:
    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]
  i += 1

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

Submission status: Time Limit Exceeded

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

for i in c:
    ans = ans*i

if ans <= mod:
    print(ans)
else:
    print('-1')

Submission status: Time Limit Exceeded

Solution code:
def func(n, a):
	tmp = [0 for i in range(n)]
	tmp[0] = a[0]
	if(0 in a):
		return 0
	for i in range(1, n):
		tmp[i] = tmp[i-1] * a[i]
		
	if(tmp[i] > 10**18):
			return '-1'
	
	return str(tmp[-1])

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

Submission status: Time Limit Exceeded

Solution code:

def func(n, a):
	tmp = [0 for i in range(n)]
	tmp[0] = a[0]
	for i in range(1, n):
		tmp[i] = tmp[i-1] * a[i]
		# print(tmp[i])s
	if(tmp[i] > 10**18):
			return '-1'
	
	return str(tmp[-1])

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
b = input()
b = list(map(int, b.split()))
c = 1
for d in range(a):
  c = c * b[d]
if c <= 1000000000000000000:
  print(c)
else:
  print(-1)

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
b = input()
b = b.split()
c = 1
for d in range(a):
  c = c * int(b[0])
  b.pop(0)
if c <= 1000000000000000000:
  print(c)
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 = ans * A[i]
if ans > 10**18:
    ans = -1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
kazu = int(input())
word = input()
score = word.split()
scin = [0]*kazu
zero = 0
for i in range(kazu):
    scin[i] = int(score[i])
    if scin[i] == 0:
        zero = 1

answer = 1
for j in range(kazu):
    answer *= scin[j]
    if answer > 10**18 and zero == 0:
        answer = -1

if zero == 1 and answer > 10**18:
    answer = -1

print(answer)

Submission status: Time Limit Exceeded

Solution code:
kazu = int(input())
word = input()
score = word.split()
scin = [0]*kazu
for i in range(kazu):
    scin[i] = int(score[i])

answer = 1
for j in range(kazu):
    answer *= scin[j]
    
if answer > 10**18:
    answer = -1

print(answer)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

from operator import mul

N=int(input())

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

if 10**18>=reduce(mul,list):
	print(reduce(mul,list))

else:
  	print("-1")

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

from operator import mul

N=int(input())

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

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

from operator import mul

N=int(input())

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

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

Submission status: Time Limit Exceeded

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

count = 1

for i in a:
    count*=i

x = 10**18

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

count = 1

for i in a:
    count*=i

x = 10**18

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

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

res = 1

for n in L:
    res *= n

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
data=list(map(int,input().split()))
s=1
for d in data:
    if d == 0:
        print(0)
        break
else:
    for d in data:
        s *= d
    if s > 10**18:
        print(-1)
    else:
        print(s)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def main():

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

    ans = 1

    for i in A:
        if A == 0:
            ans = 0
            break
        ans *= i
        if ans > 10 ** 18:
            ans = -1

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

def main():

    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)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

a = list(map(int, input().split()))
m = 1
for i in range(n):
  if a.count(0):
    m = 0
    break
  elif m > 10**18:
    break
  else:
    m *= a[i]
if m == 0:
  print(0)
elif m > 10**18:
  print('-1')
else:
  print(m)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

a = list(map(int, input().split()))
m = 1
for i in range(n):
  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()))
v = 1
m = int(1e+18)
for a in A:
    v *= a

if v > m:
    print(-1)
else:
    print(v)

Submission status: Time Limit Exceeded

Solution code:
def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))
n = inN()
a = inL()
sum = 1
for i in range(n):
    sum *= a[i]

if sum <= pow(10,18):
    print(sum)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))
n = inN()
a = inL()
sum = 1
for i in a:
    sum *= i
if sum <= pow(10,18):
    print(sum)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print (ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
number = input().split()
answer = 1
for i in range(N):
        answer *= int(number[i])
if answer < 10**18+1:
    print(answer)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

result = 1

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

Submission status: Time Limit Exceeded

Solution code:
import sys
N = int(input())
array = list(map(int,input().split()))

if not ( 2 <= N <= 10**5 ): sys.exit()
if not ( 0 <= min(array) and max(array) <= 10**18): sys.exit()

sum = array[0]
for I in range(1,len(array)):
    sum *= array[I]
print(sum) if sum <= 10**18 else print(-1)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import itertools
import math
import sys

INF = float('inf')


def solve(N: int, A: "List[int]"):
    ans = 1
    for a in A:
        ans *= a
    return -1 if ans > 10**18 else ans


def main():

    sys.setrecursionlimit(10 ** 6)

    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:
import math

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

product = math.prod(A)
if product <= 10 ** 18:
    print(product)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

p = 1

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

if nums.count(0):
    print(0)
    exit(0)

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

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

Submission status: Time Limit Exceeded

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

result=1
for i in nums:
    result *= 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()))
product = 1

for x in range(n):
    product = product*A[x]

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a_lis = list(input().split())

# 10^18を超えたら駄目

ans=1

for j in a_lis:
    ans=ans*int(j)

if ans>pow(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()]

result = 1

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

Submission status: Time Limit Exceeded

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

while count <= N - 1:
    ans *= S[count]
    count += 1

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul

input()
a = map(int, input().split())
x = reduce(mul, a)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
num = int(input())

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]

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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10*10)

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

Submission status: Time Limit Exceeded

Solution code:
num = int(input())

value = input().split(" ")

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

Submission status: Time Limit Exceeded

Solution code:
num = int(input())

value = input().split(" ")

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
mul1 = 1

mul2 = map(int, input().split(" "))
for i in mul2:
    mul1 = mul1 * i
    if mul1 == 0:
        print(0)
        break
else:
    if mul1 > 1000000000000000000:
        print(-1)
    else:
        print(mul1)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
mul1 = 1

mul2 = map(int, input().split(" "))
for i in mul2:
    mul1 = mul1 * i

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
mul1 = 1

mul2 = map(int, input().split(" "))
for i in mul2:
    mul1 = mul1 * i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    
    out = 1
    for n in A:
        out = n * out
    
    if out > 1000000000000000000:
        print(-1)
    else:
        print(out)



main()

Submission status: Time Limit Exceeded

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

def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    
    out = 1
    for n in A:
        out = n * out
    
    if out > 1000000000000000000:
        print(-1)
    else:
        print(out)



main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
numbers =[i for i in map(int,input().split())]
result =1
standard = 10**18
for i in range(N):
  result *= numbers[i]
  if result == 0:
    print("0")
    break
else:
  if result > standard:
    print("-1")
  else:
  	print(result)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
N_S = map(int, input().split())
n = 1
for i in N_S:
  if i == 0:
    print('0')
    break
  else:
    n *=i
else:
  if n > 10**18:
    print('-1')
  else:
    print(n)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
def multiplication():
    # 入力
    N = int(input())
    A = list(map(int, input().split()))
    # 計算処理
    multi = 1
    for i in range(N):
        multi = multi * A[i]
    # 10^18比較
    if multi > 10 ** 18:
        return -1
    else:
        return multi

result = multiplication()
print(result)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

final = 1

for i in a:
    final *= i
    
if final > 1000000000000000000:
    print(-1)
else:
    print(final)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**8)
def line_to_int(): return int(sys.stdin.readline())
def line_to_each_int(): return map(int, sys.stdin.readline().split())
def line_to_list(): return list(map(int, sys.stdin.readline().split()))
def line_to_list_in_iteration(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
# def dp(init, i, j): return [[init]*i for i2 in range(j)]
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
# from itertools import accumulate #A = [0]+list(accumulate(A))
# import bisect #bisect.bisect_left(B, a), bisect.bisect_right(B,a)

n = line_to_int()
a = line_to_list()

from functools import reduce, partial
from operator import mul

prod = partial(reduce, mul)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
al = list(map(int,input().split()))
al_p = 1

for i in range(n):
    al_p *= al[i]
print(['-1',al_p][al_p <= 10**18])