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

N = int(input())
 
ans = 1
for val in input().split():
    ans = ans * int(val)
    if(int(val) == 0):
        print(0)
        sys.exit()

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys
input = sys.stdin.readline
 
n = int(input())
a = list(map(int,input().split()))
ans = 1

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

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

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
        exit

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=input().split()
a=list(map(int,a))
i=0
ans=1
if(n==0):
    print(0)
    exit()
elif(len(a)==0):
    print(0)
    exit()
for calc in a:
    if(0 in a):
        print(0)
        exit()
    ans=ans*calc
    if(ans>1000000000000000000):
        print(-1)
        exit()
    i+=1
    if(i==n):
        break
if(ans>1000000000000000000):
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
l = [int(n) for n in input().split()]

from functools import reduce
result = reduce(lambda x,y: x*y, l)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


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

print(number)

Submission status: Time Limit Exceeded

Solution code:
sub = input()
input = input().split(" ")
nl = list()
for ele in input:
  nl.append(int(ele))
def multiplyList(myList) : 
    result = 1
    for x in myList: 
         result = result * x
         if result > 1000000000000000000 and 0 not in nl:
            print("-1")
            exit()
    return result
res = multiplyList(nl)
if res > 1000000000000000000:
  print("-1")
else:
  print(res)

Submission status: Time Limit Exceeded

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

resultk = 1
for i in range(n):
  resultk = resultk * ls[i]

r = resultk


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

Submission status: Time Limit Exceeded

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

# for i in range(n):
#     res*=int(input())


res = 1

for i in range(len(a)//2):
    res = res*a[i] * a[-1*(i+1)]

# for i in range(0,len(a),2):
#     if i < len(a)-1:
#         res = res * int(a[i]) * int(a[i+1])
#     else:
#         res = res * int(a[i])

if len(a) % 2 != 0:
    res = res * a[len(a)//2+1]

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

Submission status: Time Limit Exceeded

Solution code:
a=[]
n=int(input())
ima=False
a=input().split()
for i in range(n):
  a[i]=int(a[i])
  if a[i]==0:
    ima=True
proz=1
if ima==True:
  print(0)
else:
  for i in range(n):
    proz = proz * a[i]
  if proz>1000000000000000000:
    print(-1)
  else:
    print(proz)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

sum=1
flag=0
fuck=0
a = list(map(int,input().strip().split()))[:n]
for i in a:
    if i==0:
        fuck=1
    #print(f)
    sum=sum*i
    if sum > 10**18:
        flag=1

if fuck == 1:
    print(0)
else:
    if flag==0:
        print(sum)
    else:
        print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

s = 1
for l in list:
  s = s * l

if s > 1000000000000000000 : s = -1
print(s)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
N = int(input())
L = list(map(int, input().split()))
ans = 1

for n in range(N):
 ans = L[n]*ans
 if ans >= 1000000000000000001: ans = -1
 if ans >= 1000000000000000001: break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
result = 1
flag = 0
for a in A:
    if a == 0:
        result = 0
        break
    else:
        result = result * a
        if result > pow(10, 18):
            flag = 1
            result = -1
if flag == 1 and result != 0:
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

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

ans = 1
INF = 1000000000000000000

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
li=list(map(int,input().split()))
li.sort()
ans=li[0]
for i in range(1,n):
    ans*=li[i]
    if ans>1000000000000000000:
        exit
    else:
        pass
    
if ans>1000000000000000000:
    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()))
for i in range(N-1):
   A[0]*=A[i+1]
   i+=1
if A[0]>10**18:
   A[0]=-1
print(A[0])

Submission status: Time Limit Exceeded

Solution code:
input()
total = 1
line = input().split(" ")

for x in line:
    total *= int(x)

if total > 1000000000000000000:
    print(-1)

else:
    print(total)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**6)
n=int(input())
lis=list(map(int, input().split()))
def calc(i, y):
  if y>10**18:
    return "-1"
  elif i==n-1:
    return y
  elif lis[i]==0:
    return 0
  else:
    return calc(i+1, lis[i+1])*y
result=calc(0, lis[0])
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()))
import operator
from functools import reduce
def mul(*numbers):
    return reduce(operator.mul, numbers)
if mul(*a)<=10**18:
  print(mul(*a))
else:
  print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
arr=list(map(int,input().split()))
pro=1;
ans=True;
for i in range(n):
    pro*=arr[i]
    if pro>1000000000000000000 or pro<0 :
        ans=False
    
    
if ans==False and pro!=0:
	print("-1")
else:
    print(pro)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
import numpy as np
from decimal import Decimal, ROUND_HALF_UP
N = int(input())
A_list = list(map(str,input().split()))
B_list = []

if '0' in A_list:
  print('0')
  sys.exit()
  
else:
  for i in range(N):
    logA = Decimal(A_list[i]).log10()
    B_list.append(logA)

sum = 0
for j in range(N):
  sum += B_list[j]

if sum > 18:
  print('-1')
else:
  pro = np.power(10,sum)
  print(Decimal(str(pro)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
mult = 1
for i in range(n):
    mult *= a[i]
    if mult == 0:
        print(0)
        break
if mult > 1e+18:
    print(-1)
elif mult != 0:
    print(mult)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


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

print(number)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
from decimal import *

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

getcontext().prec = 21

aa = [Decimal(b).log10() for b in a if a != 0]

ans = Decimal('0')

for c in aa:
    ans += c


if ans > 18.0:
    print(-1)
else:
    ans = 1
    for c in a:
        ans *= c
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
rows = int(input())
x = [int(i) for i in input().split()]
p = 1
for i in x:
  p=p*i
if p>1000000000000000000:
  print(-1)
else:
  print(p)

Submission status: Time Limit Exceeded

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

for i in range(n):
    if(a[i] == 0):
        exit
if n % 2 == 0:
    for i in range(n//2):
        ans *= a[i]
        ans *= a[n-i-1]
elif n % 2 == 1:
    for i in range(n//2):
        ans *= a[i]
        ans *= a[n-i-1]
    ans *= a[n//2]

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

ans = 1
for v in vec:
  if v == 1000000000000000000:
    ans = -1
    break
  elif v == 0:
    ans = 0
    break
  ans = ans * v
  
if ans > 1000000000000000000:
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in a:
    s*= i

if s > 1000000000000000000:
    s = "-1"

print(s)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

total = 1
li.sort()
for a in li:
    if a == 0:
        total = 0
        break
    total *= a

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

print(total)

Submission status: Time Limit Exceeded

Solution code:
def multiply(numbers):  
    total = 1
    for x in numbers:
        total *= x  
    if total>(10**18):
        return(-1)
    else:
        return(total)
    
n=int(input())
numbers=list(map(int,input().split()))
print(multiply(numbers))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
sub = input()
input = input().split(" ")
nl = list()
for ele in input:
  nl.append(int(ele))
def multiplyList(myList) : 
    result = 1
    for x in myList: 
         result = result * x
         if result > 1000000000000000000 and 0 not in nl:
            print("-1")
            exit()
    return result
res = multiplyList(nl)
if res > 1000000000000000000:
  print("-1")
else:
  print(res)

Submission status: Time Limit Exceeded

Solution code:
def main():
    from sys import stdin
    import functools,operator
    input = stdin.readline
    prod = functools.partial(functools.reduce, operator.mul)
    N = int(input())
    A = [0]*N
    A = [i for i in map(int,input().split())]
    ans = prod(A)
    if ans > 10**18:
        print(-1)
    else:
        print(ans)
main()

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 * int(a[i])
 
if result > 1000000000000000000 :
    print("-1")
else:
	print(result)

Submission status: Time Limit Exceeded

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

ans = 1
for i in range(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()))  # 入力のときに N を使う必要はありません
ans = 1;
flg = True
A.sort()
for i in range(N):
    ans*=A[i]
    if(ans>1000000000000000000):
        flg = False
if(flg):
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

# nums = [1,2,3,4,5]
# print(reduce(mul, nums)) #結果=>120

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

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce
    

if __name__ == '__main__':
    try:

        N = int(input())
        A = list(map(int, input().split()))
        ans = reduce(mul, A)
        if ans > 10 ** 18:
            print(-1)
        else:
            print(ans)
    except:
        if 0 in A:
            print(0)
        else:
            print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

main()

Submission status: Time Limit Exceeded

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


def main():
    n = int(input())
    a_list = tuple(map(int, input().split()))
    num = 1000000000000000000
    ans = 1
    n = 10**7
    for i in range(n):
        ans *= 10
    
    if ans <= num:
        print(ans)
    else:
        print(-1)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/local/bin/python3
# coding: utf-8
n = input()
hairu = input()
kita = hairu.split(" ")
seki = 1

try:
    for c in kita:
        seki = seki * int(c)
    if seki > 10**18:
        print("-1")
    else:
        print(seki)
except:
    print("-1")

Submission status: Time Limit Exceeded

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

total = 1
for i in range(N):
    total *= array[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

N = int(input())
A = list(map(int, input().strip().split()))
ans = reduce(mul, A)
if ans > 1000000000000000000:
    print('-1')
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
At = 1
for j in range(N) :
    At = At * A[j]

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

l = list(map(int, input().split()))
x = 1

for i in l:
	x *= i
if x <= 10**18:
	print(x)
else:
    print(-1)

Submission status: Time Limit Exceeded

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


if number>1000000000000000000:
    number = -1

print(number)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce
N = int(input().strip())
A = list(map(int,input().split()))
x = reduce(mul, A)
if x > 1000000000000000000:
    print("-1")
else:
    print(x)

Submission status: Time Limit Exceeded

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

if n % 2 == 0:
    for i in range(n//2):
        ans *= a[i]
        ans *= a[n-i-1]
elif n % 2 == 1:
    for i in range(n//2):
        ans *= a[i]
        ans *= a[n-i-1]
    ans *= a[n//2+1]

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

Submission status: Time Limit Exceeded

Solution code:
import sys
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
x = 1
for i in range(n):
  x *= a[i] 
if x > 1000000000000000000:
  x = -1
print(x)

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

Submission status: Time Limit Exceeded

Solution code:
t=int(input())

ans = 1
temp = input()
temp = temp.split(" ")
for i in temp:
    ans *= int(i);

b = 1e18;
if(ans > b):
    print("-1\n")
else:
    print("{}\n".format(ans))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
An=[]
An=input().split()
An=[int(n) for n in An]
X=1

for i in range(0,N):
    X=X*An[i]

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

print(X)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce
O = pow(10, 18)
N = int(input())
L = list(map(int, input().split()))
M = reduce(mul, L)
if O < M:
    M = -1
print(M)

Submission status: Time Limit Exceeded

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

answer = 1
for a in A_list:
    answer *= int(a)

if len(str(answer-1))>18:
    print(-1)
else:
    print(answer)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
A=list(map(int,input().split()))
from collections import deque
q=deque(A)
 
ans=1
while len(q)>0:
    p=q.popleft()
    ans=ans*p
if ans>1000000000000000000:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    from sys import stdin
    import functools,operator
    input = stdin.readline
    prod = functools.partial(functools.reduce, operator.mul)
    N = int(input())
    A = list(map(int,input().split()))
    ans = prod(A)
    if ans > 10**18:
        print(-1)
    else:
        print(ans)
main()

Submission status: Time Limit Exceeded

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

total = 1
for i in range(N):
    total = total * array[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
a = int(input())
i = input().split()
i = [int(j) for j in i]
result = reduce(lambda x, y: x*y, i)
if result<=1000000000000000000:
    print(result)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
# your code goes here
n=int(input())
a=1
f=1
x = list(map(int,input().strip().split()))[:n] 
  
for i in range(0,n):
    a*=x[i]
if(a>1000000000000000000):
    print("-1")
else:
    print(a)

Submission status: Time Limit Exceeded

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

ans = 1
for A in Aj:
	ans *= A
if ans > 10**18:
	ans = -1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
numIntegers = input()
total = 1
line = input().split(" ")

for x in line:
    total *= int(x)

if total > 1000000000000000000:
    print(-1)

else:
    print(total)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul

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

ans = reduce(mul, A)

if ans <= 1000000000000000000:
    print(ans)
    exit()

print(-1)

Submission status: Time Limit Exceeded

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

ans = 1
for x in li:
    ans = ans * x
print(ans) if ans <= pow(10, 18) else print(-1)

Submission status: Time Limit Exceeded

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

ans = 1
for v in vec:
  ans = ans * v
  
if ans > 1000000000000000000:
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
x = 1
for i in range(n):
  x *= a[i] 
if x > 1000000000000000000:
  x = -1
print(x)

Submission status: Time Limit Exceeded

Solution code:
n=map(int , input())
arr=list(map(int , input().split()))
p=1000000000000000000
f=0
res=1
for i in arr:
	res=res*i
	if res>p:
		f=1
if res==0:
	print(res)
elif f:
	print(-1)
else:
	print(res)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
N = int(input())
L = list(map(int, input().split()))
ans = 1

for n in range(N):
 ans = L[n]*ans

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

A = list(map(int, input().split()))
  
res = A.pop(0)

for i in A:
  res *= i

max_num = pow(10,18)

if res > max_num:
  print(-1)
else:
  print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
n=int(input())
li=list(map(int,input().split()))

ans = functools.reduce(operator.mul, li)
if ans>1000000000000000000:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

N = int(input())
L = list(map(int, input().split()))
M = reduce(mul, L)
if 10 ** 18 < M:
    M = -1
print(M)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
a = int(input())
i = input().split()
list = []
i = [int(j) for j in i]
result = 1
result = reduce(lambda x, y: x*y, i)
if result<=1000000000000000000:
    print(result)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
from decimal import Decimal, ROUND_HALF_UP
N = int(input())
A_list = list(map(str,input().split()))
B_list = []

if '0' in A_list:
  print('0')
  sys.exit()
  
else:
  for i in range(N):
    logA = Decimal(A_list[i]).log10()
    B_list.append(logA)

sum = 0
for j in range(N):
  sum += B_list[j]

if sum > 18:
  print('-1')
else:
  pro = 10**sum
  print(Decimal(str(pro)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
_=input()
val=1
for i in input().split():
  val*=int(i)
if val>10**18:
  print(-1)
  exit()

print(val)

Submission status: Time Limit Exceeded

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

s = 1
for l in list:
  s = s * l

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

Submission status: Time Limit Exceeded

Solution code:
n = input()
nums = [int(e) for e in input().split()]

reans = nums[0]
ans = 0
for i in range(1, int(n)):
    ans = nums[i] * reans
    reans = ans

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
from operator import mul
from functools import reduce

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

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

Submission status: Time Limit Exceeded

Solution code:
def m(list1): 
      
    mul=1
    for x in list1: 
         mul=mul*x  
    return mul 
      
n=int(input())
arr=list(map(int,input().split()))
ans=m(arr)
if ans>pow(10,18):
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
mlt = 1
for num in a:
  mlt *= num
if mlt > 1000000000000000000:
  print("-1")
else:
  print("{}".format(mlt))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())#リストの要素数
L = list(map(int,input().split()))
ASW = L[0]
for i in range(0,N-1):
  ASW = ASW*L[i+1]
  
if ASW > pow(10,18):
  ASW = -1
  
print(ASW)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=input().split()
a=list(map(int,a))
i=0
ans=1
for calc in a:
    if(0 in a==True):
        print(0)
        exit()
    ans=ans*calc
    i+=1
    if(i==n):
        break
if(ans>1000000000000000000):
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

N = int(input())
v = ((map(int, input().split())))
answer = functools.reduce(operator.mul,v)
answer = answer if answer <= 1000000000000000000 else -1
print(answer)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

total = 1
if 2 <= N <= pow(10, 5):
    for i in range(N):
            total = total * array[i]
            #print(total)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

n = int(input())
a = list(map(int, input().split()))
b = 1
mod = 10**9+7

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

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