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:
s = int(input())
n = list(map(int, input().split()))
  # sys.exit()

ans = 1
for i in range(s):
  if (0 in n) == True:
    ans = 0
    break
  ans *= n[i]
  if ans > 10 ** 18:
    ans = -1
    break
  if ans == 0:
    break

print(ans)

Submission status: Time Limit Exceeded

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

result = 1

border = 10 ** 18

for i in A:
    if result == 0:
        break
    result = result * i

if result > border:
    result = -1

print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
L = []
for l in sys.stdin:
  L.append(l)
N = int(L[0])
A = list(map(int, L[1].split()))

answer = 1
for a in A:
  answer = answer * a
if answer <= 1000000000000000000:
  print(answer)
else:
  print(-1)

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    a = [int(_) for _ in input().split()]
    ans = 1
    for i in a:
        if i == 0:
            ans = 0
            
        ans *= i
        if ans > 10**18:
            ans = -1
            

    return ans

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
largenum = 10**18
from functools import reduce
from operator import mul
def main():
    n = int(input())
    a = list(map(int, input().split()))

    r = reduce(mul, a)
    if r > largenum:
        print(-1)
    else:
        print(r)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

from operator import mul
from functools import reduce

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a_list = list(map(int, input().split()))
res = 1
flag0 = False
if 0 in a_list:
  flag0 = True

for i in range(n):
  res = a_list[i]*res
  if res > 1000000000000000000 and flag0==False:
    res = -1
    break

print(res)

Submission status: Time Limit Exceeded

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

ans = 1

for x in range(n):
    if 0 in a:
        ans = 0
        break

    ans *= a[x]

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


print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math  
n = int(input())
a = list(map(int, input().split()))
p = math.prod(a)
   
if p <= 10**(18):
  print(p)
else:
  print(-1)

Submission status: Time Limit Exceeded

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

answer = 1

for x in data:
    answer *= x

if answer <= 1e+18:
    print(answer)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

n = int(input())
number = map(int,input().split())
X = functools.partial(functools.reduce, operator.mul)

s=X(number)
if s>pow(10,18):
    print(-1)
else:
    print(s)

Submission status: Time Limit Exceeded

Solution code:
n = input()
X = str(input())
em = 0
Return = []
for spam in range(len(X)):
    if X[spam] == " ":
        Return.append(int(X[em:spam]))
        em = spam+1
Return.append(int(X[em:]))
x = 1
for a in Return:
    x = x * a
if len(str(x-1)) >= 19:
    print(-1)
else:
    print(x)

Submission status: Time Limit Exceeded

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

for i in Alist:
    p *= i
    if 0 in Alist:
        p = 0
        break        
    elif p > 10**18:
        flag = False
        break
    else:
        continue
    
if flag:
    print(p)
else:
    print("-1")

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

if 0 not in a_list:
    for a_i in a_list:
        multi_sum*=a_i
    if multi_sum > LIMIT:
        multi_sum=-1
else:
    multi_sum=0

print(multi_sum)

Submission status: Time Limit Exceeded

Solution code:
#A
n = int(input())
a = list(map(int, input().split()))
ans = 1
b = 0
for i in a:
    ans *= i
    if ans > 10 ** 18:
        b = -1
if ans == 0:#例外ans=0のときは途中で10^18を超えても0となる
    b = 0
if b == -1:#10^18を超えてる
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def input(): return sys.stdin.readline().strip()
mod = 10**9 + 7

def power(x, y):
    if (y == 0): return 1
    temp = power(x, int(y / 2))
    if (y % 2 == 0):
        return temp * temp
    else:
        if (y > 0):
            return x * temp * temp
        else:
            return (temp * temp) / x

n = int(input())
arr =get_array()
sum = 1
for i in range(n):
    sum *= arr[i]
if sum > power(10,18):
    print(-1)
else:
    print(sum)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split(" ")))
total = 1
Triger = 0
for i in A:
  if total == 0:
    print(0)
    Triger = 1
    break
  else:
    total *= i

if total > 10**18:
  print(-1)
elif Triger == 0:
  print(total)

Submission status: Time Limit Exceeded

Solution code:
N = input()
A = list(map(int, input().split()))
num = 1
for i in A:
  if 0 in A:
    num = 0
    break
  elif num > 1000000000000000000:
    break
  num = num*int(i)
if num > 1000000000000000000:
  print(-1)
else:
  print(num)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

print(total)

Submission status: Time Limit Exceeded

Solution code:
N = (int(input()))
a = list(map(int, input().split()))
c = 1
for b in a:
    c = c*b

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

print(c)

Submission status: Time Limit Exceeded

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

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)
    
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 v in A:
    ans = ans * v
if ans > 10 ** 18:
        ans = -1    
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

ans = 1

for num in nums:
  ans *= num
  
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()))
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:
from functools import reduce
import operator
N = int(input())
A = list(map(int,input().split()))
reduce(operator.mul,A)
if reduce(operator.mul,A) > 10**18:
  print(-1)
else:
  print(reduce(operator.mul,A))

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

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

ans = reduce(mul, lis)

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:

import sys 
input = sys.stdin.readline


n = int(input())

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

from operator import mul
from functools import reduce



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

Submission status: Time Limit Exceeded

Solution code:

from functools import *
import sys
sys.setrecursionlimit(100000)

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


N=input()
a=acinput()

if min(a)==0:
    print(0)
    sys.exit()
res=1

for sa in a:
    res*=sa
    if res>10**18:
        res=-1
        
    
print(res)

Submission status: Time Limit Exceeded

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

ans = 1
for i in range (n):
    if array[i] == 0:
        ans = 0

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

N = sys.stdin.readline()
A = sys.stdin.readline()

ans = 1
for i in A.split():
    ans = ans * int(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()))
# print(type(a), a)

limit = 1e18

ans = a[0]
# print(ans)

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

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

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

ans = 1
for a in A:
    ans = ans * a
if (ans > 1000000000000000000) :
    print(-1)
else :
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1#np.prod(A)
for i in A:
  ans = ans * i
print(ans if ans <= 10**18 else -1)

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

Submission status: Time Limit Exceeded

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

answer = 1

for i in A:
    answer = answer * i
    if i == 0:
        print(0)
        break
else:
    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()))
result=1
for i in a:
  result=result*i

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

N, result = eval(input()), 1
List = list(map(int, input().split()))
result = reduce(lambda x, y: x * y, List[:N])
print(result if result <= 10**18 else -1)

Submission status: Time Limit Exceeded

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

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

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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())
sum = 1
for num in input().split():
    sum *= int(num)
    if sum == 0:
        print(0)
        exit()
if len(str(sum)) > 19:
    print(-1)
    exit()
elif len(str(sum)) == 19:
    if str(sum).count("1") == 1 and str(sum).count("0") == 18:
        pass
    else:
        print(-1)
        exit()
print(sum)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
x = 0
m = A[0]
for x in range(1, N):
    m *= A[x]

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().strip().split()))
x = 1
for i in range(n):
    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()))  # 入力のときに N を使う必要はありません
Ans = 1
for num in range(N):
    if A[num] == 0:
        print(0)
        exit()

for num in range(N):
    Ans = Ans * A[num]

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()))
result = 1
for a in A:
    result = result * a
if result > pow(10,18):
    print(-1)
else:
    print (result)

Submission status: Time Limit Exceeded

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

for j in range(len(A)):
  if A[j] == 0:
    flag = 1
    ans = 0

if flag == 0:
  for i in range(N):
    ans = ans * A[i]
    if ans == 0:
      break


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
from operator import mul
from functools import reduce
count = input().split()

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

if reduce(mul, li_nam) > 1000000000000000000 :
    s=-1
else:
    s=reduce(mul, li_nam)
print(s)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
zero = int(0)
ans = int(1)
poss = int(1)
arr = [int(x) for x in input().split()]
for i in range(n):
    x = arr[i]
    if(x==0):
        zero = 1
    if(zero!=1):
        ans = ans*x
        if(poss!=0):
            if(ans > 1000000000000000000):
                poss = 0
if(zero==1):
    print(0)
elif(poss==0):
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

n = int(input())
num_list = list(map(int, input().split()))
sum=1

for i in num_list:
    if i==0:
        print(0)
        exit()
    i=str(i)
    sum=str(sum)
    
    i=int(i)
    sum=int(sum)
    sum=sum*i
    
if sum>10**18:
    print(-1)
    exit()
print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

prod = 1

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

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

Submission status: Time Limit Exceeded

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

if 0 in A:
    print(0)
else:
    sum=reduce(mul,A)
    if sum>1000000000000000000:
        print(-1)
    else:
        print(sum)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

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

ans = reduce(mul, l_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()))
thres = 10**18
res = A[0]
for i in range(N-1):
   res *= A[i+1]
if res > thres:
    res = -1
print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
n = int(input())
a = list(map(int,input().split()))
lim = 10**18
ans = functools.reduce(operator.mul, a)

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

Submission status: Time Limit Exceeded

Solution code:
str = input()
str2 = input().split(" ")

ans = 1
for x in str2:
    ans = ans * int(x)

if(ans > 1000000000000000000):
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = 1
for Ai in input().split(' '):
    a *= int(Ai)
    if a == 0:
        break

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def input(): return sys.stdin.readline().strip()
mod = 10**9 + 7

def power(x, y):
    if (y == 0): return 1
    temp = power(x, int(y / 2))

    if (y % 2 == 0):
        return temp * temp
    else:
        if (y > 0):
            return x * temp * temp
        else:
            return (temp * temp) / x

n = int(input())
arr =get_array()
sum = 1
for i in range(n):
    sum *= arr[i]
if sum > power(10,18):
    print(-1)
else:
    print(sum)

Submission status: Time Limit Exceeded

Solution code:
iCnt = int(input()) 
inStrArr = input().split()
kk = int(1)
for wStr in inStrArr:
 kk = kk * int(wStr)

kkLim = 10 ** 18

if (kk > kkLim) :
    print('-1')
else :
    print(kk)

Submission status: Time Limit Exceeded

Solution code:
def chn(c):
	tot=1
	for i in range(len(c)):
		tot=tot*c[i]
		
	if tot>pow(10,18) and 0 in c:
		return 0
	elif tot>pow(10,18) and 0 not in c:
		return -1
		
	return tot


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

print(chn(c))

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input())
A = [None]*n
A = input().split()
T = 1
for i in A:
    T *= int(i)
if T > pow(10,18):
    print(-1)
else:
    print(T)

Submission status: Time Limit Exceeded

Solution code:
if __name__ == "__main__":

    N = int(input())

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

    mult = 1
    for i in P:
        mult *= i

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
num = int(input())
s = list(map(int,input().split()))
res = 1
for i in s:
    res *= i
    
if res <= 10 ** 18:    
    print(res)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
alis=list(map(int,input().split()))
p=alis[0]

for i in range(1,n):
  p*=alis[i]
  
if len(list(str(p)))>18:
  sa=list(map(int,list(str(p))))
    
  if sum(sa)!=1:
    print(-1)
    exit()
print(p)

Submission status: Time Limit Exceeded

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

for i in range(0, n):
    result = result * a[i]
    # print(i)

# print(result)
# print(101*9901*999999000001)
# print(pow(10, 18))

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

print(result)

Submission status: Time Limit Exceeded

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

mul = 1
for i in A:
    mul = 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()))
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 functools import reduce
from operator import add, mul
n = map(int, input().split())
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:
# -*- coding: utf-8 -*-
# 整数の入力

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

    output = 1
    ketasuu = 0
    
    for i in INPUT:
        output = output * i
        
        if output > 10 ** 18:
            output = -1

    print(output)

Submission status: Time Limit Exceeded

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

ans = 1
for i in input_line:
    ans = 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()))

from math import log10

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
def readInt():
    return list(map(int, input().split()))

from operator import mul
from functools import reduce

n = int(input())
a = readInt()
a.sort()
ans = reduce(mul, a, 1)
if ans > 10**18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines 
MOD = 10**9+7
INF = 1<<60

from operator import mul
from functools import reduce
def resolve():
    N = int(inp())
    A = list(map(int, inp().split()))
    limit = 10**18
 
    _prod = reduce(mul, A)
    if _prod <= limit:
        print(_prod)
    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 range (0, N):
	if A[i] == 0:
		ans = 0
		break
	else:
		ans *= A[i]

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

n=int(input())

m=list(map(int,input().split()))
result = functools.reduce(operator.mul, m)

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

Submission status: Time Limit Exceeded

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

for i in range(N):
    x *= A[i]
if x > y:
    print("-1")
else:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
N=int(input())
A=[]
A.extend((int(x) for x in input().split()))
ans=functools.reduce(operator.mul, A)
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()))
pre = a[0]

s=1
while True:
    score = pre * a[s]
    pre = score
    s += 1
    if s==len(a):
        break
if score <= 10 ** 18:
    print(score)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
tmp = 1
dat = list(map(int, input().split(" ")))
for d in dat:
    tmp *= d

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

Submission status: Time Limit Exceeded

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

Ans=1

flag=False

for a in A:
    Ans=Ans*a
    if 0 in A:
        if flag==False:
            print(0)
            flag=True
        break
    elif Ans > 10**18:
        if flag==False:
            print(-1)
            flag=True
            break
    else:
        pass

if Ans <= 10**18:
    if flag==False:
        print(Ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
input()
A = list(map(int,input().split()))
if 0 in A:
    print(0)
    quit()
ans = 1
for a in A:
    ans*=a
print(-1 if ans>10**18 else ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
a = int(input())
b = list(map(int,input().split()))

n = 1
m = 1

aa = a/2

if a%2 == 1:
    aa = (aa*2+1)//2

for i in range(int(aa)):
  n = n * b[i]
  
for i in range(int(aa),a):
    m *= b[i]

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

Submission status: Time Limit Exceeded

Solution code:
A = int(input())
hoge=list(map(int, input().split()))
  
sum=1
for i in range(A):
  sum = sum*hoge[i]

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

Submission status: Time Limit Exceeded

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

limit = 10**18
ans = 1
for val in A:
    ans *= val

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

Submission status: Time Limit Exceeded

Solution code:
import math

n = int(input()) 
arr = [int(x) for x in input().split()] 
newpatient = 1
total = 1
for x in arr:
    total*=x

if(total>1000000000000000000):
    total=-1;
print(total)

Submission status: Time Limit Exceeded

Solution code:
import sys
L = []
for l in sys.stdin:
  L.append(l)
N = int(L[0])
A = list(map(int, L[1].split()))

answer = 1
for a in A:
  answer = answer * a
if answer > 1000000000000000000:
    print(-1)
else:
  print(answer)

Submission status: Time Limit Exceeded

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

for n in range(N):
    if A[n] == 0:
        result = 0
        break
    else:
        result = result*A[n]

if result >= 1000000000000000001:
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

N, result = eval(input()), 1
List = list(map(int, input().split()))
result = reduce(lambda x, y: x * y, List)
print(result if result <= 10**18 else -1)