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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**6)
n=int(input())
lis=list(map(int, input().split()))
if 0 in lis:
  print(0)
  exit()

  
def calc(i, y):
  if i==n-1:
    return y
  elif y>10**18:
    return "-1"
  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()))

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

Submission status: Time Limit Exceeded

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

N = int(input())
A = list(map(int, input().split()))
i=1
sum=A[0]
while A[0]<=10**18 and i<=N-1:
   sum*=A[i]
   i+=1
if sum>10**18:
   sum=-1
print(sum)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
N = int(input())
A = list(map(int, stdin.readline().split()))
"""ans = 1
for a in A:
    ans = ans*a
    if ans == 0:
        break"""
from functools import reduce
ans = reduce(lambda x,y:x*y,A)
if ans >10**18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
a = []
x = 1

n = int(input())
a = input().split()

for i in range(n):
    a[i-1] = int(a[i-1])
    x = x * a[i-1]
    
if x <= 10**18:
    print(x)
elif x > 10**18:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
list = input().split(" ")
x = 1
for num in list:
  x = x * int(num)
  
if x <= 10**18:
  print(x)
else:
  print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
x1 = input()
x2 = list(map(int, input().split(" ")))
 
result =  1
for xv in x2:
  result = xv * result

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
import numpy as np
b = int(input())
a= [int(x) for x in input().split()]
prod = functools.partial(functools.reduce, operator.mul)

mm = prod(a)

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

Submission status: Time Limit Exceeded

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

print(-1) if ans > 1e+18 else print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = input().split()
cutoff = 10**18
res = 1
for n in range(N):
	res *= int(A[n])
if res > cutoff:
	res = '-1'
print(res)

Submission status: Time Limit Exceeded

Solution code:
def main():
    import numpy as np
    N = int(input())
    A = np.array(list(map(int,input().split())),dtype='object')
    ans = np.prod(A)
    if ans > 10**18:
        print('-1')
    else:
        print(f'{ans}')
main()

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
n = int(input())

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


pre = functools.reduce(operator.mul, a)
if pre <= 1000000000000000000:
    print(pre)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
A = input()
N = input().split()
N = [int(s) for s in N]
 
ans = 1
max = 1000000000000000000
for i in range(len(N)):
  ans = ans * N[i]
 
if ans > max:
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
nums = [int(a) for a in input().split()]
ans = 1;
for a in nums:
    ans = ans * a

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

Submission status: Time Limit Exceeded

Solution code:
import copy

def main():
    n = int(input())
    a = list( map( int, input().split()))
    sum = 1
    for i in a:
        k = copy.deepcopy(sum)
        sum = k * i
    if sum - 1000000000000000000 > 0:
        print(-1)
    else:
       print(sum)
    
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:

n =int(input())
s = list(map(int,input().split()))
k = 1
for _ in range(n):
  k *= s[_]

if len(str(k-1)) < 19:
  print(k)
else :
  print("-1")

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
from sys import stdin

n=int(stdin.readline().rstrip())
li=list(map(int,stdin.readline().split()))
L=deque(li)
ans=1
for i in range(n):
    x=L.popleft()
    ans*=x
if ans>10**18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
# import numpy as np
# from decimal import Decimal

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

# A = np.array(A).astype(np.int64)

# ans = int(np.prod(A))


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

ans = functools.reduce(lambda a, b: a * b, A)

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

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

ans = reduce(mul,A)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())


import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)
x = prod(map(int, input().split()))

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

Submission status: Time Limit Exceeded

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

from functools import reduce
from operator import add, mul
result =reduce(mul, P)

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())
a = list(map(int,input().split()))
tmp = sorted(a)
M = 10**18
s = 0
ans = a[0]
for i in range(1,n):
	if 0 in a:
		print(0)
		break
	else:
		ans *= a[i]
		if ans > M:
			print(-1)
			s = 0
			break
		else:
			s = ans
if s != 0:
	print(s)

Submission status: Time Limit Exceeded

Solution code:
def main():
    from sys import stdin
    input = stdin.readline
    n = int(input())
    inlis = list(map(int, input().split()))
    ans = 1
    for i in inlis:
        ans *= i
        #print(ans)
    if ans > 10 ** 18:
        ans = -1
    print(ans)
    
 
 
 
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
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]
  if n == 0:
      print(0)
      exit()
  
for i in range(int(aa),a):
    m *= b[i]
    if m == 0:
      print(0)
      exit()

if n * m <= 10**18:
    print(n*m)
    exit()
  
print('-1')

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
from functools import reduce
from operator import mul

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

ans = reduce(mul, b)
if ans > (10 ** 18):
    ans = -1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
c = int(1)
N = int(input()) #1行目のNを取得する
i = list(map(int, input().split())) #i_1 i_2を取得し、iに値を入れる
for k in range(N):
    c*=i[k]
if c>10**18:
    print('-1')
else:
    print(c)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

N = int(input())
A = list(map(int,input().split()))
a = functools.reduce(operator.mul, A)


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

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())
r = list(map(int,input().split()))

lim = math.pow(10,18)

for i in range(n):
    if i == 0:
        x = r[i]
    else:
        x = x * r[i]

if x > lim:
    x = -1

print(int(x))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
product = 1
vals = list(map(int,input().split()))

for i in vals:
	if i == 0:
		product = 0
		break

	product *= i;

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

import sys
n = int(input())
aa = input()
a = aa.split()

result = 1
for i in range(n):
    if(a[i] == 0):
        print(0)
        sys.exit()
    result *= int(a[i])

if(result > 1000000000000000000):
    print(-1)
    sys.exit()

print(result)

Submission status: Time Limit Exceeded

Solution code:
import collections
N=int(input())
A=list(map(int, input().split()))
A_dict=collections.Counter(A)
ANS=1

for i in A_dict.keys():
    ANS=ANS*(i**A_dict[i])

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def multiplyList(myList): 
    result = 1
    for x in myList: 
        result = result * x
    return result 

t=int(input())
l=list(map(int,input().split()))
n = multiplyList(l)
if(n > 1000000000000000000):
    print("-1")
else:
    print(n)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator



N = int(input())
A = list(map(int,input().split()))
x= functools.reduce(operator.mul, A)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
b = [int(x) for x in input().split()]
r = 1
max = 10**18

for i in b:
  r *= i
  
r = -1 if r > max else r
print(r)

Submission status: Time Limit Exceeded

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

for i in a:
    b=b*i

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

Submission status: Time Limit Exceeded

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

# res =1
# def func(i):
#     res = res * i

# a = func((input().split()))

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


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

Submission status: Time Limit Exceeded

Solution code:
x1 = input()
x2 = [int(s) for s in input().strip().split(" ") ]
 
result =  1
for xv in x2:
  result = xv * result

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
n=int(input())
ans=1

a=input().split()
for i in a:
    ans*=int(i)
if ans>pow(10,18):
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
# Nつの文字入力
S = input()

#数字入力
N =input()

# スペースで区切り処理
inputs = N.split(' ')

# 最終的結果の数字
final = int(1)

#配列inputsの中身をstrからintに変換する
intlist = list(map(int, inputs))

#Nの数字をnumberに1つずつ代入し全て掛け算して結果をfinalに代入する

for number in intlist:
 final = final * number

#finalが10の18乗を超えていたら'-1'を出力する
#超えていなければfinal(計算した値)を出力する

if final > 1000000000000000000 :
    print('-1')
elif final <= 1000000000000000000 :
    print(final)

Submission status: Time Limit Exceeded

Solution code:
N = input()
a = 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:
def multiply( array , n ): 
    pro = 1
    for i in range(n):
        pro = pro * array[i] 
    return pro 

n = int(input()) 
  
a = list(map(int,input().strip().split()))[:n]
    
ans = multiply(a, n)
if ans>1000000000000000000 : 
    print(-1)
else :
    print(ans)

Submission status: Time Limit Exceeded

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

m=li[0]
for i in range(1,N):
  a=m*li[i]
  m=a
 
if m>10**18:
  print(-1)
else:
  print(m)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Ans=1

flag=False

for a in A:
    if flag==False:
        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
    else:
        break


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

N = int(input())
input_int = [*map(int, input().split(" "))]
prod = functools.partial(functools.reduce, operator.mul)
result = prod(input_int)
if result > 1e+18:
  result = -1
print(int(result))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
i = 0
ans = 0
if 0 in a:
    print(0)
else:
    while ans<10**10 and i<len(a):
        ans*=a[i]
    if (ans<=10**18):
        print(ans)
    else:
        print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = input().split()
ans = 1
#float
for i in range(N):
    A = int(S[i])
    ans *= A
if ans>1000000000000000000:
    ans = -1
print (ans)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
input = stdin.readline
n = int(input())
a = list(map(int, input().split()))  # n個の数字がリストに格納される
b = 0
ans = 1
for i in range(n):
  if(a[i] == 0 and b == 0):
    print(0)
    b = 1
for i in range(n):
  ans = ans * a[i]
  if(ans > 1000000000000000000 and b == 0):
    print(-1)
    b = 1
if(b == 0):
  print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# your code goes here
n=int(input())
arr=list(map(int,input().split()))
ans=arr[0]
for i in range(1,n):
	ans=ans*arr[i]
if(ans>pow(10,18)):
	print(-1)
else:
	print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys


try:
    sys.stdin = open(sys.path[0] + '/input.txt', 'r')
    sys.stdout = open(sys.path[0] + '/output.txt', 'w')
except FileNotFoundError:
    pass


def solve():
    n = int(input())
    arr = list(map(int, input().split()))
    
    res = 1
    for i in arr:
        res *= i

    if res > 10 ** 18:
        return -1
    
    return res


print(solve())

Submission status: Time Limit Exceeded

Solution code:
# import numpy as np
# from decimal import Decimal

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

# A = np.array(A).astype(np.int64)

# ans = int(np.prod(A))


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

ans = prod(A)

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

Submission status: Time Limit Exceeded

Solution code:

import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)
N = int(input())
li = list(map(int, input().split()))

k = prod(li)
if 10 ** 18 >= k:
    print(k)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
def multiplyList(l): 
    result = 1
    for x in l: 
        result = result * x 
    return result 

t=int(input())
l=list(map(int,input().split()))
b=multiplyList(l)
if(b>1000000000000000000):
    print("-1")
else:
    print(b)

Submission status: Time Limit Exceeded

Solution code:
import math

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


ans = 0
res = 1
flag = False
for b in a:
    if b == 0:
        flag = True
        break
    ans += math.log10(b)
    res *= b

if flag:
    print(0)
else:
    if ans > 18:
        print(-1)
    else:
        res2 = res - 1000000000000000000
        if res2 > 0:
            print(-1)
        else:
            print(res)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
L=list(int(x) for x in input().split())
sum=1
for i in range(N):
	sum=sum*L[i]
if sum > 1000000000000000000:
	print("-1")
else:
	print(sum)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
 
p = 1
 
for e in a:
  if a == 0:
    print(0)
    exit()
  
  p *= e
  
if p > 10**18:
  print(-1)
else:
  print(p)

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
num_list = input().split(" ")
result = 1
con = num >= 2 and num <= 100000
if con == True and num == len(num_list):
    for i in num_list:
        if int(i) >= 0 and int(i) <= 1000000000000000000:
            result = result * int(i)
        else:
            break
    if result > 1000000000000000000:
        print(-1)
    else:
        print(result)
else:
    print()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce
n=input()
nums = map(int,input().rstrip().split(' '))

ans = reduce(mul, nums)
if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
x = input()
nums = input().split()
max_value = 10 ** 18
ans = 1
for num in nums:
    ans = ans * int(num)

if ans > max_value:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

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

if(f == 0):
    print(0)
elif(f == 1):
    print(-1)
else:
    print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
def multiplyList(myList) : 
	
	# Multiply elements one by one 
	result = 1
	for x in myList: 
		result = result * x 
	return result 
	
# Driver code 
n=int(input())
lst=[]
lst=list(map(int,input().strip().split()))[:n]
ans=multiplyList(lst)
if ans>1000000000000000000:
  print("-1")
else:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

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

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

x = n(A)


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
result = 1
checker =False
for j in a:
  if j > 1000000000000000000:
    result = -1
    checker =True
if 0 in a:
  result = 0
  checker=True
while checker==False:
  i = 0
  while i != len(a):
    result = result*a[i]
    i += 1
  checker = True
    

if result <= 1000000000000000000:
  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(N):
    ans *= A[i]
if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

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

a.sort()

ans = 0
res = 1
flag = False
for b in a:
    if b == 0:
        flag = True
        break
    ans += math.log10(b)
    res *= b

if flag:
    print(0)
else:
    if ans > 18:
        print(-1)
    else:
        res2 = res - 1000000000000000000
        if res2 > 0:
            print(-1)
        else:
            print(res)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
mul = 1
numbers = input().split()
for i in range(N):
  mul *= int(numbers[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()))

import math

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

b = int(math.pow(10,18))

if total-b>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 == 0:
        break
if ans > 10 ** 18:
    ans = -1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**6)
n=int(input())
lis=list(map(int, input().split()))
if 0 in lis:
  print(0)
  exit()
elif max(lis)>10**18:
  print(-1)
  exit()
def calc(i, y):
  if i==n-1:
    return y
  elif y>10**18:
    return "-1"
  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())
An=[]
An=input().split()
An2=[int(n) for n in An]
X=1

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

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

print(X)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
product =1
vals = list(map(int,input().split()))

for i in vals:
	if i == 0:
		product = 0
		break
	product *= i;

if product >= 1000000000000000001:
	print('-1')
else:
	print(product)

Submission status: Time Limit Exceeded

Solution code:
from fractions import Fraction
import numpy as np

n = int(input())
num = list(map(int, input().split()))
num = [ Fraction(i) for i in num ]
num = np.array(num)

if 0 in num:
    print(0)
else:
    mult = np.prod(num)
    if mult > 10**18:
        print(-1)
    else:
        print(int(mult))

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

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

ans = 1
ans = reduce(mul, a) #=> 1320

# for i in range(n):
#   ans *= a[i]
#   if a[i] == 0:
#     break
#   elif (ans*a[i]) > limit:
#     ans = -1
#     break

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

Submission status: Time Limit Exceeded

Solution code:
n = (int)(input())
str = input()
a = str.split(" ")
k=1
for i in range(n):
  k*=(int)(a[i])
if k>1000000000000000000:
  k=-1
print(k)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator


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

j = 1000000000000000000

ans = 1

'''
for i in range(n) :
    ans *= An[i]
'''
result = functools.reduce(operator.mul, An)

if result <= j:
    print(result)
    
else :
    print('-1')

Submission status: Time Limit Exceeded

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

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()))
mal = 1

for a in A:
    mal = mal * a
if mal <= 10 ** 18:
    print(mal)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
result = 1
checker =False
for j in a:
  if j > 1000000000000000000:
    result = -1
    checker =True
if 0 in a:
  result = 0
  checker=True
while checker==False:
  for i in range(len(a)):
    result *= a[i]
  checker = True
    

if result <= 1000000000000000000:
  print(result)
else:
  print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

n = int(input())
aa = input()
for i in range(n):
    a = aa.split()

result = 1
for i in range(n):
    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()))
B =1
for i in range(N):
  B *=A[i]
if B >1E18:
  print('-1')
else:
  print(B)

Submission status: Time Limit Exceeded

Solution code:
from math import prod
N = int(input())
B = [int(i) for i in input().split()]

if 2 <= N <= 10**5 and N == len(B):
    S = prod(B)
    if S > pow(10, 18):
        print("-1")
    else:
        print(S)
else:
    print("choose right value")

Submission status: Time Limit Exceeded

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

ans = 1
for num in nums:
    ans = 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()))
product = 1
for i in A:
  product = product*i
  if(product==0):
    break;
if(product>1000000000000000000):
  print("-1")
else:
  print(product)

Submission status: Time Limit Exceeded

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

maximum = 10**18

res = 1
for a in A:
  res *= a
  if res > maximum:
    res = -1
    
print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
 
ans = a[0]*a[1]
 
for i in range(n-2):
  ans *= a[i+2]
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()))
from operator import mul
from functools import reduce
b=reduce(mul, a)
if b>10**18:
    print(-1)
else:
    print(b)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

n = int(input())
a = [int(_) for _ in input().split()]
#mul = 0

#for i in range(n):
mul = reduce(lambda x,y: x*y, a)

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


print(mul)

Submission status: Time Limit Exceeded

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

for an in a:
  result = an*result
  
if result > 10**18:
  result = -1
  
print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
MAX = 10 ** 18

N = int(input())
liste = list(map(int, input().split()))
res = 1 


for i in range(N):
    #if(res/2 > MAX):
    #    print(-1)
    #    exit(0)
    res *= liste[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

A.sort()
if A[0] == 0:
    print(0)
    exit()

for i in A:
    ans = i*ans

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

print(-1)