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:
from sys import stdin
input=stdin.readline
n=int(input())
list_a=list(map(int, input().split()))
result=1
for a in list_a:
  result = result*a
  
if result > 10**18:
  print('-1')
else:
  print(result)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = input().split()
i = 0
b = 1
while i <= n-1:
  b = b * int(a[i])
  i += 1
if b > 10 ** 18:
  b = -1
print(b)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

n=int(input())
a=list(map(int,input().split()))
ans=reduce(lambda x,y:x*y,a)
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(" ")))
total = 1

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul

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

if 0 in a_li:
    print(0)
    exit()

a_li = [a for a in a_li if a != 1 and a != 0]
a_li.append(1)
ans = reduce(mul, a_li)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

cum = 1
over = False
for x in a:
    if x == 0:
        cum = 0
        break

    cum *= x
    if (cum > 1e18):
        over = True

print(-1) if (over and cum != 0) else print(cum)

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

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

Submission status: Time Limit Exceeded

Solution code:
import math
N = int(input())
S = math.prod([int(i) for i in input().split()])
print(-1 if S>10**18 else S)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = input().split()
answer = 1
flag = 0
x = 10**18
for i in range(N):
  A[i] = int(A[i])
  answer *= A[i]
  if answer == 0:
    break

check = answer/x
if ((check) >= 1) and (answer != x):
  print(-1)
else:
  print(answer)

Submission status: Time Limit Exceeded

Solution code:
def main():
    _ = int(input())
    m = 10 ** 18
    x = 1
    for i in map(int, input().split()):
        x *= i
    print(-1 if m < x else x)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(val)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys

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

Submission status: Time Limit Exceeded

Solution code:

n = int(input())

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

_max = 10 ** (18)

ans = 1

for _a in a:
    ans *= _a

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

Submission status: Time Limit Exceeded

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


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from decimal import *
from operator import mul

def main():
    max_n = 10**18
    n = int(input())
    a = input_list()
    if 0 in a:
        print(0)
        exit()
    ans = reduce(mul, a)
    if ans > max_n:
        print(-1)
    else:
        print(ans)

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
# cook your dish here
n = int(input())
a = list(map(int,input().strip().split()))[:n]
ans = 1
limit = 1000000000000000000

for i in range(0,n):
    x = a[i]
    ans = ans*a[i]
    
if ans>limit:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

n = 1
for i in A_list:
  if 0 in A_list:
    print(0)
    break
  n = n * i
  if n > 1000000000000000000:
    print(-1)
    break
else:
  print(n)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
res =  1
for x in input().split():
    res *= int(x)
if res > 1000000000000000000:
    print(-1)
else:
    print(res)

Submission status: Time Limit Exceeded

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

pro=1
for i in range(n):
    pro *=List[i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import functools
import operator

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
N = input()
B = input().split()

if 2 <= int(N) <= 10**5 and int(N) == len(B):
    check = all(0 <= int(elem) <= 10**18 for elem in B)
    S = int(1)
    for i in range(len(B)):
        if check:
            S *= int(B[i])
        else:
            print("choose right value")
    if S > 10**18:
        print("-1")
    else:
        print(S)
else:
    print("choose right value")

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul

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

res = reduce(mul, N_s)

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

print(res)

Submission status: Time Limit Exceeded

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

for val in A:
    A_dict[val] = A_dict.get(val, 0) + 1

limit = 10**18
ans = 1
for val in A_dict:
    ans *= val ** A_dict[val]

if ans > limit:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator


N=int(input())
A=list(map(int,input().split()))
B=functools.reduce(operator.mul,A)
if B>1000000000000000000:
    print(-1)
else:
    print(B)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
re =1

list = [int(s) for s in input().split()]
  
for i in range(n):
    re *= list[i]
    
if(re > 1000000000000000000):
    print("-1")
else:
    print(re)

Submission status: Time Limit Exceeded

Solution code:
num=int(input())
date0=input().rstrip().split(" ")
date0=sorted(date0)
sum=1
if int(date0[0])==0:
    print(0)
else:
    for i in range(num):
        sum=sum*int(date0[i])
    if sum<=10**18:
      print(sum)
    else:
      print(-1)

Submission status: Time Limit Exceeded

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

kk = int(1)
for wStr in inList:
 kk = kk * int(wStr)

kkLim = int(10 ** 18)

if (kk <= kkLim) :
        print(kk) 
else :
        print('-1')

Submission status: Time Limit Exceeded

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

b=1
for j in a:
	b *=int(j)
if b >10**18:
	print(-1)
else:
	print(b)

Submission status: Time Limit Exceeded

Solution code:
from sys import *
ip = stdin.readline
n = int(ip())
arr = list(map(int,ip().split()))
mul = 1
for i in arr:
    mul *= i
print("-1" if mul > (10**18) else mul)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys

INF = 10e17
N = int(input())
A = list(map(int, sys.stdin.readline().rstrip().split()))
ans = 1
for i in range(N//2):
    ans = ans*A[i]*A[N-1-i]
    if ans == 0:
        print(0)
        sys.exit()
if N%2:
    ans = ans*A[N//2]
if ans > INF:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

res = 1

for a in A:
    res *= a

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

print(res)

Submission status: Time Limit Exceeded

Solution code:
from operator import mul
from functools import reduce

# A, B = tuple(map(int, input().split()))
N = int(input())
list_A = list(map(int, input().split()))
threshold = 10 ** 18

if 0 in list_A:
    print(0)
    exit()
if max(list_A) > threshold:
    print(-1)
    exit()

result = reduce(mul, list_A)

if result > threshold:
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

Solution code:
import operator
from functools import reduce
import sys
input = sys.stdin.readline

count = int(input())
list = list(map(int, input().split()))
sum = reduce(operator.mul, list, 1)

if sum > 1000000000000000000:
    sum = -1

print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

if Ans > Limit:
    print(-1)
else:
    print(Ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = int(input())
a = list(map(int, input().split()))


# ans = np.prod(a)
# if ans > 10**18:
#     print(-1)
#     exit()

# print(ans)

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

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


print(ans)

Submission status: Time Limit Exceeded

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

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

print(-1 if ans > limit else ans)

Submission status: Time Limit Exceeded

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

if tmp == 0:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

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

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)
N = int(input())
A = list(map(int, input().split()))
RedWine = prod(A)
if RedWine > 1000000000000000000:
    print(-1)
else:
    print(RedWine)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator
n=int(input())
li = list(map(int, input().split()))
result = functools.reduce(operator.mul, li)
if (result>(1000000000000000000)):
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

Solution code:
# import numpy as np
# import functools
# import operator

N = int(input())
A = [int(x) for x in input().split()]
# prod = functools.partial(functools.reduce, operator.mul)
# sum = functools.reduce(operator.mul, A, 1)
lim = False
zero = False
sum = 1
for i in A:
    sum = sum * i
    if i == 0:
        zero = True

if 1000000000000000000 < sum:
    print(-1)
elif zero:
    print(0)
else:
    print(sum)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

ans = 1
for x in A:
  ans *= x
  if ans < 0:
    print(-1)
    exit()

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


print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
 
n = int(input())
a = [int(x) for x in input().split(' ')]
 
sum = 1

for x in a:
    sum *= x;
 
if sum == 10**18:
    print(sum)
elif sum != 0 and math.log10(sum) >= 18:
    print(-1)
else:
    print(sum)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
li = list(map(int,input().split()))
ans = li[0]
for i,l in enumerate(li):
    if i == 0:
        if l == 0:
            print(0)
            exit()
        continue
    else:
        if l == 0:
            print(0)
            exit()
        #print(l,'l')
        ans *= l
        #print(ans)
if ans > 10**18:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
def pr(l):
	a = 1
	for i in l:
	#x = int(input())
		a=a*i
	if(a>1000000000000000000):
		print(-1)
	else:
		print(a)

t = int(input())
l = list(map(int, input().split())) 
pr(l)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    inlis = tuple(map(int, input().split()))
    ans = 1
    for i in inlis:
        ans *= i
    if ans > 10 ** 18:
        ans = -1
    print(ans)
    



if __name__ == "__main__":
    main()

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


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 e in arr:
	ans = ans * e

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

Submission status: Time Limit Exceeded

Solution code:
# cook your dish here
ans = 1
n = int(input())
a = list(map(int,input().split())) 
for i in range(n):
    ans *= a[i]
if ans > 1000000000000000000:
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
a=int(input())
b=input().split(' ')
m=0
s=1
while m<a:
    s=s*int(b[m])
    
    m=m+1
if s>10**18:
	print(-1)

else:
    print(s)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = input().split(" ")

sum = 1
for i in a:
  sum = sum * int(i)

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

Submission status: Time Limit Exceeded

Solution code:
def sieve():
    n = int(input())
    ans = 1
    nums = [int(e) for e in input().split()]
    for i in range(len(nums)):
        ans = ans * nums[i]

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

if __name__ == '__main__':
    sieve()

Submission status: Time Limit Exceeded

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

ans = 1

for v in l:
    ans *= v
if(ans > 1e18):
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

n = int(input())
multi = 1

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

for i in n:
    multi *= i
    
if(multi > 1000000000000000000):
    print(-1)
else:
    print(multi)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
array=list(map(int, input().split()))
k=1
for i in array:
    if i==0:
        print(0)
        exit()
    k*=i
if k>1000000000000000000:
    print(-1)
else:
    print(k)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import mul

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

if 0 in a_li:
    print(0)
    exit()

a_li = [a for a in a_li if a != 1 or a != 0]
ans = reduce(mul, a_li)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in num:
  a *= i
  
if a > 10**18:
    a = -1

print(a)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split()))
over_value = 10 ** 18 + 1
total = 1
cnt = 0
while cnt < len(A):
    total *= A[cnt]
    cnt += 1
    
if total >= over_value:
    total = -1
print(total)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
As = list(map(int,input().split()))
c = int(As[0])
f = True
for x in range(N):
  if 0 in As:
    print("0")
    f = False
    break
  if x == 0:
    continue
  c = int(c) * int(As[x])
  if 1000000000000000001 <= c:
    print("-1")
    f = False
    break
if f:
  print(c)

Submission status: Time Limit Exceeded

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

ans = 10**18
prod = 1
f = 0
f2 = 0

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

if f == 1:
    print(0)

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

Submission status: Time Limit Exceeded

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

result = 1
for i in range(len(a)):
  result = result*a[i]
  if result == 0:
    break

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
i = 0
while (i < n):
  res *= a[i]
  i += 1
  
if (res > 1000000000000000000):
  res = -1

print(res)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

import math


def main():
    N = int(input())
    A = [int(arg) for arg in input().split()]
    ans = 1
    for i in range(N):
        ans *= A[i]

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

result = 1

for tmp in AList:
    result *= tmp

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

Submission status: Time Limit Exceeded

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

res = 1
for i in arr:
    res*=i
if res >10**18:
    print('-1')
else:
    print(res)

Submission status: Time Limit Exceeded

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

cnt = 1
for i in d:
  cnt *= i
if cnt > 10**18:
  print('-1')
else:
  print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans =1

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


for i in a:
    ans *= i

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

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

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

if ans < 0:
  print(-1)
  exit()

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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 li:
         a *= i
    if a >= 10**18+1:
        print('-1')
    else:
        print(a)

Submission status: Time Limit Exceeded

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


def multiplyList(myList):
    result = 1
    for x in myList:
        result = result * x
    if result <= 1000000000000000000:
        return result
    else:
        return -1


print(multiplyList(results))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
Atxt=input()
Ans=1
Flag=0
j=0
for i in range(N):
    Ans*=int(Atxt.split(" ")[i])
if (Ans>10**18):
    Ans=-1
print(Ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math

N = int(input())

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

sum0 = str_list[0]

for n in range(1,N):
    sum0 = sum0 * str_list[n]
if sum0 > 10**18:
    print('-1')
else:
    print(sum0)

Submission status: Time Limit Exceeded

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
#print(A)
i = 10**18
ans = 1

for a in A:
    #print(a,ans)
    if a == 0:
        ans = 0
        break
    else:
        ans *= a
if ans > i:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
nums = list(map(int, input().split()))
ans = 1
 
for i in range(n):
  ans *= nums[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()))
result=1
a.sort()
for i in a:
    if i==0:
        result=0
        break
    result*=i
if result==1000000000000000000:
    print(result)
elif 18< len(str(result)):
    print(-1)
else:
    print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n=int(input())
s=input().split()
ans=1
for i in range(n):
    ans=ans*int(s[i])
if ans>np.power(10,18):
    print(-1)
else:
    print(ans)