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_MAX = 10**18
n = input()
a = list(map(int, input().split()))
sum = 1
for i in a:
    sum *= i
if 0 in a:
    sum = 0
elif sum > N_MAX:
    sum = -1
print(sum)

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

Submission status: Time Limit Exceeded

Solution code:
def main():
  n = int(input())
  nums = list(map(int, input().split()))
  result = 1
  if 0 in nums:
    print(0)
    return
  else:
    for i in nums:
      result *= i
    if result > 1000000000000000000:
      print(-1)
      return
    else:
      print(result)
      return


if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

Solution code:
_ = input()
inputs = list(map(lambda x: int(x), input().split()))

if 0 in inputs:
    value = 0
else:
    value = inputs[0]
    for n in range(1, len(inputs), 1):
        value *= inputs[n]

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

Submission status: Time Limit Exceeded

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
if __name__ == "__main__":
  n = int(input())
  nums = list(map(int, input().split()))
  result = 1
  if 0 in nums:
    print(0)
  else:
    for i in nums:
      result *= i
    if result > 1000000000000000000:
      print(-1)
    else:
      print(result)

Submission status: Time Limit Exceeded

Solution code:
_ = input()
inputs = list(map(lambda x: int(x), input().split()))

if 0 in inputs:
    value = 0
else:
    m = 0
    for n in inputs:
        if m == 0:
            value = n
            m += 1
            continue
        value *= n
        m += 1

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

Submission status: Time Limit Exceeded

Solution code:
if __name__ == "__main__":
  n = int(input())
  nums = list(map(int, input().split()))
  result = 1
  if 0 in nums:
    print(0)
  else:
    for i in nums:
      result *= i
    print(result if result <= 1000000000000000000 else "-1")

Submission status: Time Limit Exceeded

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

ans = 1
inf = 10**18 + 1
for i in a:
    ans *= i

ans = min(ans, inf)
if ans == inf:
    ans = -1

print(ans)

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 A:
    ans = ans * i
if ans > pow(10, 18):
    print(-1)
    exit()
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 *= 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()))
 
m=li[0]
if 0 in li:
  print(0)
else:
  for i in range(1,N):
    m=m*li[i]
    if m>10**18:
      m=-1
      
  print(m)

Submission status: Time Limit Exceeded

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

ans = 1
inf = 10**18 + 1
for i in a:
    ans *= i

ans = min(ans, inf)
if ans == inf:
    print(-1)
else:
    print(ans)

Submission status: Time Limit Exceeded

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

arr.sort()
res = 1
flg = True
for i in arr:
    res*=i
    if res >10**18:
        flg = False
        print('-1')
if(flg):print(res)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
li=list(map(int,input().split()))
li.sort()
if li[0]==0:
  print(0)
else:
  ans=1
  for i in li:
    ans*=i
    if ans>1000000000000000000:
        ans=-1
        exit
    else:
        continue
    
  if ans<1000000000000000001:
      print(ans)
  else:
      print(-1)

Submission status: Time Limit Exceeded

Solution code:
if __name__ == "__main__":
  n = int(input())
  nums = list(map(int, input().split()))
  result = 1
  for i in nums:
    result *= i
  print(result if result <= 1000000000000000000 else "-1")

Submission status: Time Limit Exceeded

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

arr.sort()
if arr.count(0):
    print(0)
else:
    res = 1
    flg = True
    for i in arr:
        res*=i
        if res >10**18:
            flg = False
            print('-1')
    # print(res, res >=10**18)
    if(flg):print(res)

Submission status: Time Limit Exceeded

Solution code:
import sys

n = int(input())
list_input = list(map(int, sys.stdin.readline().strip().split()))

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

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


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

Submission status: Time Limit Exceeded

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





if __name__ == '__main__':
    N = int(input())
    main(N)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import add, mul

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

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

Submission status: Time Limit Exceeded

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

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

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 if res>=0 else -1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

c = 0
d = 0

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

for i in b:
    if i == 0:
        c += 1
    elif i > 10**18:
        d += 1
        
if c > 0:
    print(0)
    exit()
if d > 1 and c == 0:
    print(-1)
    exit()
    
for i in range(int(aa)):
  n = n * b[i]

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

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
num = 1
flag = 0
c=[int(i) for i in input().split()]
for i in c:
    if i == 0:
        flag = 1
        print("0")
if flag == 0:
    for i in c:
        num *= i
    if num > 1000000000000000000:
        print("-1")
    else:
        print(num)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
n = int(input()) 

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

ans = 1;
for i in range(n):
  if a[i] == 0:
    print(0)
    sys.exit()
    
  ans *= a[i]
  
if (ans > 1000000000000000000):
    print(-1)
    sys.exit()
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
b = input().split()
c = []
for i in range(a):
  d = int(b[i])
  c.append(d)
ans =1
for I in c:
  ans = 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()))
M=1
A.sort()
for j in A:
	M=M*j
	if M>10**18:
		M=-1
	if M ==0:
		M=0
		break
print(M)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
AList = input().split()
result = 1

for element in AList:
    result = result * int(element)
   
if result > 1e+18:
    print(-1)
else:
    print(result)

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

A = sorted(A, reverse=True)

M = 1

for i in range(N):
  if M <= 10**18 or M != 0:
    M = M * A[i]

  else:
    break

if M <= 10**18 :
    print(M)

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 > 1000000000000000000:
        ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline

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

if A.count(0):
    print(0)
else:
    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()))
M=1
for j in A:
	M=M*j
if M>10**18:
	M=-1
print(M)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
N, *A = map(int, open(0).read().split())
b = 1
for a in A:
  b *= a
print(-1 if b > 10**18 else b)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
# for i in range(n):
#     m = int(input())
#     k = k*m
op = 1
p = list(map(int,input().split()))
p.sort()
for i in p:
    op = op*i

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

x = 1
if 0 in a:
    print(0)
else:
    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())
li=list(map(int,input().split()))
li.sort()
if li[0]==0:
  print(0)
else:
  ans=1
  for i in li:
    ans*=i
    if ans>1000000000000000000:
        ans=-1
    else:
        continue
    
  if ans>1000000000000000000:
      print(-1)
  else:
      print(ans)

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:
N = input()
A = list(map(int, input().split()))
ans = 1
tmp = 1
is_overflow = False

for num in A:
  ans = ans * num
  if num != 0:
    if ans / num != tmp:
      is_overflow = True
      break
  elif num == 0:
    is_overflow = False
    ans = 0
    break
  
  for num in A:
    if num == 0:
      is_overflow = False
      ans = 0
      break

  tmp = ans

if (ans > 1e18 or ans < 0 or is_overflow): ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

ans = 1

for e in map(int, input().split()):
    ans *= e

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

Submission status: Time Limit Exceeded

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

for i in a:
    if number==0:
        print(0)
        exit(0)
    number *= i
    

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

print(number)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 1
flag = 0
a.sort()

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



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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

ans = 1

for e in [*map(int, input().split())]:
    ans *= e

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

Submission status: Time Limit Exceeded

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

for i in a:
    if number==0:
        print(0)
        exit()
    number *= i
    

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

print(number)

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:
    if 0 in a:
        print(0)
    else:
        print(-1)
else:
    print(x)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def main():
    n = int(input())
    a=sys.stdin.readline().rstrip().split()
    if '0' in a:
        print(0)
        return
    ans=1
 
    for i in a:
        ans=ans*int(i)
 
    if ans>1000000000000000000:
        print("-1")
    else:
        print(ans)
main()

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:
def main():
    n = int(input())
    a = list(map(int,input().split()))
    temp = 1
    for n in a:
        temp *= n
    if temp > (10 ** 18):
        temp = -1
    print(temp)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys

n = int(input())
a=sys.stdin.readline().rstrip().split()
 
ans=1
 
for i in a:
    ans=ans*int(i)
 
if ans>1000000000000000000:
    print("-1")
else:
    print(ans)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

for i in a:
    if number==0:
        exit()
    number *= i
    

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

print(number)

Submission status: Time Limit Exceeded

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

i = []

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
res = 1
for i in range(N):
    if A[i] >= 0:
        res *= A[i];
    if res > 1e+18:
        res = -1

if res > 1e+18: print("-1")
else          : print(res)

Submission status: Time Limit Exceeded

Solution code:
import functools
import operator

#A,B,C=(int(x) for x in input().split())
N=int(input())
A=list(map(int, input().split()))

result = functools.reduce(operator.mul, A)

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
res = 1
for i in range(N):
    if A[i] >= 0:
        res *= A[i];

if res > 1e+18: print("-1")
else          : print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import copy

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
n = input()
a = input().split()
s = 1
for ta in a:
    s = s * int(ta)
if s > 1000000000000000000:
    s = -1
print(s)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

A = sorted(A, reverse=True)

M = 1

for i in range(N):
  if M <= 10**18 or M != 0:
    M = M * A[i]

  else:
    exit

if M <= 10**18 :
    print(M)

else:
  print("-1")

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
judge = True
ans = 1
for i in a:
    ans *= i
    if (ans > 1000000000000000000):
        judge = False

if judge:
    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):
    if 0 in a:
        x = 0
        break
    else:
        x *= a[i]
    
if x > 10**18:
    print(-1)
else:
    print(x)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

result=1

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

result=1

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

Submission status: Time Limit Exceeded

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

print(-1 if a > 1e18 else a)

Submission status: Time Limit Exceeded

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

for i in a:
    number *= i

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

print(number)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


count  = reduce(mul, nums)
if "0" in N:
        print("0")
elif count  > cnt :
        print(-1)
else:
         print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
data = list(map(int, input().split()))
 
a = 1
i = 0
while i<n:
  if data[i]==0:
    a = 0
    break
  a = a*data[i]
  i += 1

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

M = 1

for i in range(N):
  if M <= 10**18 or M != 0:
    M = M * A[i]

  else:
    exit

if M <= 10**18 :
    print(M)

else:
  print("-1")

Submission status: Time Limit Exceeded

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

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

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

print(b)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

M = 1

for i in range(N):
  if M <= 10**18 or M != 0:
    M = M * A[i]

  else:
    print("-1")
    exit

if M <= 10**18 :
    print(M)

else:
  print("-1")

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

result=1

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#A,B,C=(int(x) for x in input().split())
N=int(input())
A=list(map(int, input().split()))

t=A[0]
i=1
for k in range(N-1):
  t=t*A[i]
  i+=1
if t<=10**18:
  print(t)
else:
  print(-1)

Submission status: Time Limit Exceeded

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


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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(a) for a in input().split()]
max = 10**18
x=1
for a in range(N):
    x = x * A[a]
    
else:
    if x <= max:
        print(x)
    else:
        print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

result=1

if 0 in A:
    result=0

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

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

print(result)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

from operator import mul
from functools import reduce

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

Submission status: Time Limit Exceeded

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

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, *a = map(int, open(0).read().split())

ans = 1
for x in a:
    ans = ans * x
    if ans == 0:
      print(0)
      exit()

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()))
over_value = 10 ** 18 + 1
total = 1
cnt = 0
while cnt < N:
    total *= A[cnt]
    if total >= over_value:
        total = -1
    cnt += 1
    
for i in range(N):
    if A[i] == 0:
        total = 0
print(total)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import math
from functools import reduce


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

maxi = math.pow(10,18)
mult = reduce(lambda x,y: x*y, A)
    
if mult > maxi:
    print("-1")
else:
    print(mult)

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=list(map(int,input().split(' ')))
#print(l)
s=1
if 0 in l:
    s=0
else:
    for i in l:
        s=s*i
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()))
if 0 in a:
  print(0)
  quit()
ans = 1
for i in a:
    ans *= i
if ans <= 10 ** 18:
    print(ans)
else:
    print(-1)