Problem:


Score : 200 points

Problem Statement

Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.

However, if the result exceeds 10^{18}, print -1 instead.

Constraints

2 \leq N \leq 10^5

0 \leq A_i \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

Print the value A_1 \times ... \times A_N as an integer, or -1 if the value exceeds 10^{18}.

Sample Input 1

2
1000000000 1000000000

Sample Output 1

1000000000000000000

We have 1000000000 \times 1000000000 = 1000000000000000000.

Sample Input 2

3
101 9901 999999000001

Sample Output 2

-1

We have 101 \times 9901 \times 999999000001 = 1000000000000000001, which exceeds 10^{18}, so we should print -1 instead.

Sample Input 3

31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0

Sample Output 3

0



Sample input:
2
1000000000 1000000000


Sample output:
1000000000000000000

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#take the value of N
#take the all the value

#multiply all the value
#print answer

def multiplyList(myList) : 
      
    # Multiply elements one by one 
    result = 1
    for x in myList: 
         result = result * x  
    return result  

N = 0 #0(1)
Number = [] #0(1)
total = 1 #0(1)


N = int(input()) #0(1)

Number = list(map(int, input().split())) #0(N)

total = multiplyList(Number)

if total > 10**18: #0(1)
    total = -1

print(total) #0(1)

Submission status: Time Limit Exceeded

Solution code:
#first take the number of the input
#declare list A then input all the list value
#multiply all the value using operation
#if exceed 10^18 print -1
#if not just print the answer

N=int(input()) #O(1)
A=[]
A=list(map(int,input().split())) #O(n)
answer=1 #O(1)
z=0 #O(1)

while z<N: #O(n)
    answer=answer*A[z] #O(1)
    z=z+1 #O(n)

total=answer    
if total > 10**18: #O(1)
    print("-1") #O(1)
elif total <= 10**18: #O(1)
    print(total) #O(1)

Submission status: Time Limit Exceeded

Solution code:
#take the value of N
#take the all the value

#multiply all the value
#print answer

N = 0 #0(1)
Number = [] #0(1)
total = 1 #0(1)


N = int(input()) #0(1)

Number = list(map(int, input().split())) #0(N)

for i in Number: #0(N)
    total = total*i

if total > 10**18: #0(1)
    total = -1

print(total) #0(1)

Submission status: Time Limit Exceeded

Solution code:
a=int(input())
tem = 1
if a == 0: #do nothing if 0
    a=1
else:
    b=input().split(" ")
    for i in range(a): #calculate until'a' number only
        tem = tem * int(b[i]) #multiply the list
    if tem> 10**18: #check exceed
        tem = -1
    print(tem)

Submission status: Time Limit Exceeded

Solution code:
a=int(input())
tem = 1
if a != 0:
    b=input().split(" ")
    for i in range(a):
        tem = tem * int(b[i])
    if tem> 10**18:
        tem = -1
print(tem)

Submission status: Time Limit Exceeded

Solution code:
import sys

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

ans = 1

if 0 in A:
    print(0)
    sys.exit()

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

print(ans)

Submission status: Time Limit Exceeded

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

ans = 1

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

ans = 1
for i in alist:
    ans *= 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()))
b = 1
c = 10**18
for i in a:
    b *= i 
if b > c :
	 print(-1)
else :
	print(b)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lst = list(map(int, input().split()))
if (0 in lst):
  print(0)
else:
  product = 1
  for i in lst: #iというlist中の数字
    product *= i #これが(i + 1)番目

  if(product > 1000000000000000000):
      #これをfor文に書くことで掛け終える前に超えたらやめることができる（処理を短縮できる！）
    print(-1)
  else:
    print(product)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

product = 1
for i in lst:
  product *= i #これが(i + 1)番目

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l = map(int, input().split())
ans = 1
for a in l:
    if ans * a > 1e18:
        ans = -1
    else:
        ans *= a

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

cnt = 1

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
sss = [int(s) for s in input().split()]
ans = 1
for j in range(num):
    ans *= sss[j]
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()))
x = 1
for i in range(N):
    x *= A[i]
if x > 10**18:
    x = -1
print(x)

Submission status: Time Limit Exceeded

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

for num in nums:
    ans *= num

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

print(ans)

Submission status: Time Limit Exceeded

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

ans=1
a=0
for i in range(n):
    ans*=l[a]
    a+=1

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

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
p = input().split()
s = 1
for i in range(len(p)):
    s = s * int(p[i])
if 10 ** 18 < s:
    s = -1
print(s)

Submission status: Time Limit Exceeded

Solution code:
X = int(input())
p = input().split()
s = 1
for i in range(len(p)):
    s = s * int(p[i])
if s > 10 ** 18:
    s = -1
print(s)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

Submission status: Time Limit Exceeded

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

for i in range(N):
  b *= a[i]
  if b==0:
    break

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

LIM= 10**18
ans=1
for e in a:
    ans*=e
    if ans > LIM:
        ans = -1

if ans <0:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# cook your dish here
n=int(input())
a=[int(x) for x in input().split()]
ans=1  
sorted(a)
for i in range(n):
    ans*=a[i]
    if ans==0:
        break
    if ans>(int)(1e18):
        ans=-1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math  # noqa: F401
from typing import Dict, List, Optional, Tuple, Union  # noqa: F401


def main(N: int, A: List[int]):
    ans = 1
    for a in A:
        ans *= a
        if ans > 10 ** 18:
            ans = -1
    print(ans)


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

Submission status: Time Limit Exceeded

Solution code:
#169B
#Multiplication2

n = int(input())
A = map(int,input().split())
ans=1
for a in A:
    ans*=a
if ans>10**18:
    print(-1)
    exit()
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A_list = list(map(int,input().split()))
output = 1
flug = 0

if 0 in A_list:
    print(0)
    flug = 1

for i in range(N):
    output *= A_list[i]

    if (output > 10 ** 18 and flug != 1):
        print(-1)
        flug = 1
        break
if(flug != 1):
    print(output)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A_list = list(map(int,input().split()))
output = 1
flug = 0

for i in range(N):
    output *= A_list[i]
    if 0 in A_list:
        print(0)
        flug = 1
        break
    if (output > 10 ** 18):
        print(-1)
        flug = 1
        break
if(flug != 1):
    print(output)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
data = stdin.readlines()

a = int(data[0])
b = [int(s) for s in data[1].split()]

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
data = stdin.readlines()

a = int(data[0])
b = [int(s) for s in data[1].split()]

i = 0
ans = 1
while i <= a-1:
    ans = ans * b[i]
    i += 1
if ans > 10 ** 18:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

res = 1
overflow = False

for a in A:
  res *= a
  if res > 10**18:
    overflow = True

if overflow == True and res != 0:
  print(-1)
else:
  print(res)

Submission status: Time Limit Exceeded

Solution code:
def main():
    a = int(input())
    b = input()
    lst2 = b.split()
    if 0 in lst2:
        print(0)
        return

    pro = 1
    for i in lst2:
        pro *= int(i)

    if (pro > 1000000000000000000):
        print(-1)
    else:
        print(pro)
main()

Submission status: Time Limit Exceeded

Solution code:
a=int(input())
b=input()
lst2=b.split()

pro=1
for i in lst2:
    pro*=int(i)

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

Submission status: Time Limit Exceeded

Solution code:
a=int(input())
b=input()
lst=b.split()
lst2=[]
for i in lst:
    lst2.append(int(i))
pro=1
for i in lst2:
    pro*=i
    
if (pro > 1000000000000000000):
        print(-1)
else:print(pro)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x=list(map(int,input().split()))
ans=1
for i in x:
  ans=ans*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
a = sorted(a,reverse=True)
for i in a:
	ans *=i
	if(0 in a):
		print(0)
		exit()
	if(ans>1000000000000000000):
		print(-1)
		exit()
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    num = int(input())
    num_list = list(map(int, input().split()))

    ans = 1
    for i in num_list:
        ans = ans * i
        if ans == 0:
            break

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a_list = map(int, input().split())
total = 1
for a in a_list:
    total *= a

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A  = [int(x) for x in input().split()]
total = 1
for a in A:
    total *= a 

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

Submission status: Time Limit Exceeded

Solution code:
#inport
import sys
import numpy as np
#import itertools as itlt
#from collections import deque

#input 
N = int(sys.stdin.readline())
A = [int(x) for x in sys.stdin.readline().split()]
ans = 1

for _ in range(N):
    ans = ans * A[_]
    
if ans > 10**18:
    ans = -1
        


print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

MultipliedNum=1
index=0

for i in Alist:
    MultipliedNum*=i
    

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

Submission status: Time Limit Exceeded

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

sum_A = 1
for i in range(0,len(A)):
  if(A[i] == 0):
        print(0)
        exit()
  sum_A *= A[i]
if(sum_A > 1000000000000000000):
        print("-1")
        exit()
print(sum_A)

Submission status: Time Limit Exceeded

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

sum_A = 1
for i in range(0,len(A)):
    sum_A *= A[i]
if(sum_A > 1000000000000000000):
        print("-1")
        exit()
print(sum_A)

Submission status: Time Limit Exceeded

Solution code:
def main ():
    N = int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return
    ans = 1
    for a in A:
        ans *= a
    if ans > 1000000000000000000:
        print(-1)
        return
    print(ans)
 
main()

Submission status: Time Limit Exceeded

Solution code:
def main ():
    N = int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
    if prod > 1000000000000000000:
        print(-1)
        return
    print(prod)

main()

Submission status: Time Limit Exceeded

Solution code:
def main ():
    N = int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return
    ans = 1
    for a in A:
        ans *= a
    if ans > 1000000000000000000:
        print(-1)
        return
    print(ans)

main()

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

Submission status: Time Limit Exceeded

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

for i in A:
    A_ *= i
        
if A_ > 1000000000000000000:
    print(-1)
else:
    print(A_)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

if 1e18 < res:
    print(-1)
else:
    print(res)

Submission status: Time Limit Exceeded

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

ans = 1
for i in range(len(array)):
  ans = ans*array[i]
  
if(ans > 1_000_000_000_000_000_000):
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

if value > 10e+17:
  print('-1')
else:
  print(value)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

ans = 1
if 0 in l:
  print(0)
else:
  for i in l:
    ans *= i
  if ans >= 1000000000000000001:
    print(-1)
  else:
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
input()
ans=1
for i in sorted(map(int,input().split())):
    ans*=i
    if ans==0:break
print(int(ans)if ans<=10**18 else -1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N = ni()
ans = 1
a_array = na()
for a in a_array:
    ans = ans * a
    if ans == 0:
        break
    if ans > 10 ** 18:
        ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

a=1

for i in A:

    a=a*i

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

Submission status: Time Limit Exceeded

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

a = 1
b = 10**18

for i in range(0,N):
  
  a = n_list[i] * a
  #print(a)
 
if a > b:
   print(-1)
else : 
  print(a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

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

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

ans = 1
for i in A:
  ans = ans * i
 
if ans > 1e18:
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
sum = 1
for i in range(n):
    sum *= a[i]
    if(sum > 10 ** 18 and 0 not in  a):
        print(-1)
        break
else:
    print(sum)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a1=input().split()
a2=[int(i) for i in a1]
prod=1
for i in a2:
    prod=prod*i
if prod<=1e18:
    print(prod)
else:
    print('-1')

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

max = 10 ** 18

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = math.prod(A)

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

Submission status: Time Limit Exceeded

Solution code:
# import numpy as np
import sys
from collections import defaultdict
import math
import itertools
import bisect
from copy import deepcopy
from collections import deque
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000)

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

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


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

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

def solve():
    if 0 in l:
        return (0)
        sys.exit()

    x = 1
    for i in range(N):
        x = x * l[i]

    if x > (1000000000000000000):
        x = -1
        return str(x)
    else:
        return str(x)

print(solve())

Submission status: Time Limit Exceeded

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

def solve():
    x = 1
    for i in range(N):
        x = x * l[i]

    if x > (1000000000000000000):
        x = -1
        return str(x)
    else:
        return str(x)

print(solve())

Submission status: Time Limit Exceeded

Solution code:
input()
a=1
b=map(int,input().split())
for i in b:
  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()))
p = 1
x = True

for i in a:
    p *= i
if p > (10 ** 18):
    x = False


if x == True:
    print(p)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
threshold = 10**18
n = input()
list_ = list(map(int, input().split()))

ans = 1
for i in list_:
  ans *= i
if ans > threshold:
  ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
t = int(input())
arr = [int(x) for x in input().split()]
n = 1
flag = True
for i in range(t):
    n *= arr[i]
    if n > 10**18:
        flag = False
    else:
        flag = True
if flag:
    print(n)
else:
    print(-1)