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

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


if 0 in a:
    print(0)
else:
    is_true = True
    ans = a[0]
    key = 10 ** 18
    for i in range(n-1):
        ans *= int(a[i+1])
        if ans > key:
            is_true = False
            break
    if is_true:
        print(ans)
    else:
        print('-1')

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

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

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

Solution (Python):
import math
import os
import random
import re
import sys
n= int(input())
arr=[int(s) for s in input().split()]
p=1;
count=0
for i in range(n):
    if arr[i]==0 : 
        count=1
        break
for i in range(n):
    p=p*arr[i]
    if(p>1000000000000000000):
        p=-1
        break
if(count==0) : print(p)
else : print(0)

Solution (Python):
def aaa():
	n = int(input())
	a = [int(i) for i in input().split()]
	ans = 1;
	for i in range(n):
		if a[i]==0:
			print(0)
			return
	for i in range(n):
		ans *= a[i]
		if ans>1000000000000000000:
			print(-1)
			return
	print(ans)

aaa()

Solution (Python):
import numpy as np
N = int(input())
a = list(map(int,input().split()))
ans=1
for i in range(N):
    ans *= a[i]
    if (ans > 1000000000000000000):
        ans = -1
        break
for i in range(N):
    if (a[i] == 0):
        ans = 0
        break
print(ans)

Solution (Python):
n = int(input())
A = [int(i) for i in input().split()]
the = pow(10,18)
ans = 1

if 0 in A:
    print(0)
else:
    for i in range(n):
        ans *= A[i]
        if ans >the:
            print(-1)
            break
        else:
            continue
    if ans <= the:
        print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = sorted([int(v) for v in input().split()])

    over = False
    ans = 1
    for a in A:
        ans *= a
        if ans > 1e18:
            over = True
            break
    
    if over:
        print(-1)
    else:
        print(ans)

if __name__ == '__main__':
    main()

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

Solution (Python):
res = 1

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

for x in N:
    res *= x
    if res > pow(10, 18):
        res = -1
        break

print(res)

Solution (Python):
from sys import stdin

nn = input()

N=int(nn)

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


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

res=1
for i in arr:
    res*=i
    if res>1000000000000000000:
        print(-1)
        exit();

print(res)

Solution (Python):
def main():
    N = int( input())
    t = 10**18
    A = list( map( int, input().split()))
    ans = 1
    
    
    
    A.sort()
    for a in A:
        ans *= a
        if ans > t:
            print(-1)
            return
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
a = int(input())
y=[]

	
x = list(map(int, input().split())) 
x.sort()



	
prod=1
f=0
for i in x:
	prod*=i
	if(prod>1000000000000000000):
		f=1
		print(-1)
		break
if(f!=1): 
	print(prod)

Solution (Python):
from sys import stdin

def main():
  N = int(input())
  P = stdin.readline().rstrip().split()
  if '0' in P:
    print(0)
    return
  
  ans = 1
  for a in P:
    ans *= int(a)
    if ans > 1000000000000000000:
      print(-1)
      return
  print(ans)

main()

Solution (Python):
n = int(input())
c = list(map(int, input().split()))
ans=1
max =10**18

if 0 in c:
    ans =0
else:
    for i in range(n):
        if ans< max:
            ans=ans*c[i]
            if ans > max:
                ans =-1
                break
        else:
            ans = -1
            break
print(ans)

Solution (Python):
leng=int(input())
nums=input().split()
x=1

if "0" in nums:
    print(0)
    exit()

for i in range(leng):
    a=int(nums[i])
    x=x*a
    if x>10**18:
        break

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()
lim = 10**18

ans = 1
for i in A:
    ans *= i
    if ans > lim:
        print(-1)
        exit()

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

Solution (Python):
N = int ( input().strip() ) ;
arr = list ( map ( int , input().strip().split(" ") ) ) ;
arr.sort() ;

c = 1 ;
m = pow ( 10 , 18 ) ;
for v in arr :
	c *= v ;
	if c ==0 : break ;
	if c > m : 
		c = -1 ;
		break ;
print  ( c ) ;

Solution (Python):
n = int(input())

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

ans = 1

for i in range(n):
    if(hoge[i] == 0):
        print(0)
        exit()

for i in range(n):
    ans *= hoge[i]
    if(ans > 1000000000000000000):
        print(-1)
        exit()

print(ans)

Solution (Python):
a = int(input())
b = input().split(" ")
i = 0
s = 1
f = 0
while i < a :
    if b[i] == "0" :
        print(0)
        f = f + 1
    i = i + 1
i = 0
while (i < a) and f == 0 :
    s = s * int(b[i])
    i = i + 1
    if s > (10 ** 18):
        print("-1")
        break
    if (s <= 10 ** 18) and (i == a):
        print(s)

Solution (Python):
import math
import itertools
import functools
import numpy as np










n = int(input())
v = [int(i) for i in input().split()]
v.sort()

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

Solution (Python):


import numpy as np
n = int(input())
a_list = np.array(list(map(int, input().split())))
y = np.argsort(a_list)
if a_list[y[0]] == 0:
    print(0)
else:
    ans = 1
    flag = 1
    for i in range(0, n):
        ans *= int(a_list[y[n - 1 - i]])
        if ans > 10 ** 18:
            flag = 0
            break
    if flag == 0:
        print(-1)
    else:
        print(ans)

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

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

aa=sorted(a)
th=10**18
ans=1

for i in range(len(aa)):
    if aa[i]==0:
        print(0)
        break
    ans*=aa[i]
    if ans>th:
        print(-1)
        break
    if i==len(aa)-1:
        print(ans)

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

A.sort()

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

print(ans)

Solution (Python):

import sys

input()
l = list(map(lambda x: int(x), str(input()).split(" ")))
r = 1
finished = False

for i in l:
  if i == 0:
    print(str(0))
    sys.exit()
    
for i in l:
    r = r * i
    if r > 10 ** 18:
        print(str(-1))
        sys.exit()

print(str(r))

Solution (Python):
N = int(input())
a =[int(n) for n in input().split()]

product = 1
if 0 in a:
    print(0)
else:
    for i in range(N):
        product *= a[i]
        if product > 10 ** 18:
            print('-1')
            break
    if product <= 10 ** 18:
        print(product)

Solution (Python):
n= int(input())
a_list = list(map(int, input().split()))
 
a_list = [n for n in a_list if n!=1]  

ans=1

if 0 in a_list:
  ans=0
elif len(a_list)>56:
  ans=-1
else:
  for i in a_list:
    ans=ans*i
  if ans>1000000000000000000:
      ans=-1
  
print(ans)

Solution (Python):
INF = 10 ** 18
N = int(input())
a = list(map(int, input().split()))
ans = 1

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

print(ans)

Solution (Python):
def ABC_169_B():
    N=int(input())
    A = input().split()
    A = [int(s) for s in A]
    sum=1
    flg=0

    if A.count(0)>=1:
        print(0)
        flg=1

    if flg==0:
     for i in range(len(A)):
         sum=(sum*A[i])
         if sum>10**18:
             print(-1)
             flg=1
             break
    if flg==0:
        print(sum)
        
if __name__ == '__main__':

    ABC_169_B()

Solution (Python):
n = input()
a = [int(i) for i in input().split()]
if 0 in a:
    print(0);exit()
ans = 1
for i in a:
    ans = ans * i
    if ans > 10**18:
        print(-1);exit()
print(ans)

Solution (Python):

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

t = A[0]
for i in range(1,N):
    t *= A[i]
    if int(t) > 1e18:
        for j in range(i,N):
            if A[j] == 0:
                t = 0
        break
if int(t) <= 1e18:
    print(int(t))
else:
    print(-1)

Solution (Python):

import sys
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 1
TH = 1e18
for i in range(n):
	ans = ans * a[i]
	if ans > TH:
		print(-1)
		sys.exit()
print(ans)

Solution (Python):
N=int(input())
S=list(map(int,input().split()))
D=sorted(S)
A=1

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

Solution (Python):
def main():    
    N = int(input())
    a = list(map(int,input().split()))
    res = 1
    if 0 in a:
        print(0)
        return
    for i in a:
        res *= i
        if res > 10**18:
            print(-1)
            return
    print(res)
if __name__ == "__main__":
    main()

Solution (Python):

import sys
from functools import reduce

input = sys.stdin.readline

N = int(input())
A = input().rstrip().split()

def main():
    result = 1
    if '0' in A:
        return 0

    for a in A:
        a = int(a)
        result *= a

        if result > pow(10, 18):
            return -1

    return result

ans = main()
print(ans)

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

print(ans)

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

Solution (Python):
import sys
N=int(input())
A=list(map(int,input().split()))
if 0 in A:
  print('0')
  sys.exit()
x=1
for i in A:
  x*=i
  if x>1000000000000000000:
    print('-1')
    sys.exit()
print(x)

Solution (Python):
import numpy as np
n=int(input())
a=list(map(int,input().split()))
ans=1
if 0 in a:
    print(0)
    exit()
for i in range(n):
    ans=ans*a[i]
    if ans>10**18 and not 0 in a:
      print(-1)
      exit()
if ans>10**18:
    anscheck=False
else:
    anscheck=True
print(ans if anscheck else -1)

Solution (Python):
n = int(input())
arr = [int(x) for x in input().split()] 
arr.sort()
prod = 1
flag = 0
for each in arr:
	prod = each * prod
	if prod > 1000000000000000000:
		flag = 1
		break
if flag == 0:
	print(prod)
else:
	print("-1")

Solution (Python):
count = int(input())
list = input().split(" ")
state = False
i = 0
num = int(list[i])
i += 1
limit = 10 ** 18
if "0" in list:
  num = 0
  count = 0

while i < count:
  num = num * int(list[i])

  if num > limit:
    print(-1)
    state = True
    break
    
  i += 1

if not state:
  print(num)

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

Solution (Python):
n = int(input())
lis = list(map(int, input().split()))

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

res = 1
for i in lis:
    if res > 10**18:
        print(-1)
        exit()
    else:
        res *= i
print(res if res <= 10**18 else -1)

Solution (Python):
lines = []
for i in range(2):
    lines.append(input())
num = int(lines[0])

out = 1
split = lines[1].split()
if "0" in split:
    out = 0
for i in range(num):
    out = int(split[i]) * out 
    if out > 1000000000000000000:
        out = - 1    
        break
print(out)

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

ans = 1
if 0 in array:
  ans = 0
else:
  for x in array:
    ans *= x
    if ans > 1000000000000000000:
      ans = -1
      break
print(ans)

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

Solution (Python):
def main():
	k = int(input())
	h = tuple(map(int,input().split()))
	ans = 1
	avoid = 0
	if (0 in h):
		print(0)
	else:
		for i in range(k):
			ans = h[i] * ans
			if ans > 10 **18:
				print(-1)
				avoid = 1
				break
		if avoid == 0:
			print(ans)
	


if __name__ == '__main__':
	main()

Solution (Python):

import sys

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

A.sort()
A.reverse()

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

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

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

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

abc=0

for i in range(n):
	if(a[i]==0):
		abc=1
		break
if(abc==1):
	print(0)
else:
	ans=1
	for i in range(n):
		ans*=a[i]
		if(ans>1000000000000000000):
			break

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

Solution (Python):
import sys
input = sys.stdin.readline

n = input()
n_list = sorted([int(i) for i in input().split()])
value = 1
for i in n_list:
    value = value * i
    if value > 10 ** 18:
        value = -1
        break
print(value)

Solution (Python):
import sys


def _i(): return int(sys.stdin.readline().strip())


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    _ = _i()
    m = 10**18
    ret = 1
    for ai in sorted(_ia()):
        ret *= ai
        if ret > m:
            return -1
    return ret


if __name__ == "__main__":
    print(main())

Solution (Python):
n=int(input())
B = list(map(int,input().split()))
if 0 in B:
  print(0)
else:
  c = 1
  ok = 1
  for i in range(n):
      c=c*B[i]
      if c>1000000000000000000:
          print(-1)
          ok = 0
          break
  if ok==1:
	  print(c)

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

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

count = 1
for i in A:
    count *= i
    if 10 ** 18 < count:
        break

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

print(count)

Solution (Python):


N = int(input())
line = list(map(int,input().split()))
a=1
b=0
for i in range(N):
    a*=line[i]
    if a>1000000000000000000:
        for j in range(i,N):
            if line[j]==0:
                print("0")
                b=1
                break
            if j==N-1:
                print(-1)
                b=1
                break
        break
       
if b ==0:
    print(a)

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

Solution (Python):
import time
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    ans = 1
    inf = 10**18
    t = time.time()

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

    for i in range(len(A)):
        ans *= A[i]
        if ans > inf :
            print(-1)
            exit()

    print(ans)
    
if __name__ == "__main__":
    main()

Solution (Python):
_,a=open(0)
t=1
for b in sorted(a.split()):
 t*=int(b)
 if t>10**18:t=-1;break
print(t)

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

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

out = 1
for num in nums:
  out *= num
  if out > 1e18:
    print(-1)
    exit()
print(out)

Solution (Python):
import sys
input()
a = list(map(int, input().split()))
ans = 1
flag = False
for i in a:
    if i==0:
        print(0)
        sys.exit()
for i in a:
    ans *= i
    if ans>1000000000000000001:
        print(-1)
        sys.exit()
if ans<1000000000000000001:
    print(ans)
else:
    print(-1)

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

A.sort()

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

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

ans = 1

if 0 in N:
    ans = 0
else:
    for i in range(len(N)):
        ans *= N[i]
        if ans > 10**18:
            break

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

Solution (Python):
import numpy as np
N = int(input())
a = list(map(int, input().split()))
b = 1
for i in range(N):
    if b > 0:
        b *= a[i]
    if a[i] == 0:
        b = 0
    if b > 10**18:
        b = -1
 
print(b, end='')

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

ans = 1
l = 0;
flag = 0

for i in range(N):
    if A[i]== 0:
        print(0)
        exit(0)

    l+=(len(str(A[i])) -1)
    if l>18:
        flag=1
        continue
    
    ans*=A[i]
    if ans > 1000000000000000000:
        flag = 1

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

Solution (Python):
n = int(input())
res = 1
L = list(map(int, input().split()))
L.sort()
for elem in L:
    if res != -1:
        res *= elem
    if res > 1e18:
        res = -1
print(res)

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

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

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

print(ans)

Solution (Python):
n = int(input())
aa = sorted(list(map(int, input().split())))
if aa[0] == 0:
    print(0)
else:
    ret = 1
    ff = False
    for a in reversed(aa):
        ret *= a
        if ret > 10**18:
            ff = True
            break
    if ff:
        print(-1)
    else:
        print(ret)

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

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

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

def solve(N, A):
  ans = A[0]
  exist_zero = False
  if A[-1] == 0:
    exist_zero = True

  if exist_zero:
    print(0)
    return

  for i in range(1, N):
    ans *= A[i]
    if ans > 10**18 and not exist_zero:
      print(-1)
      return

  print(ans)

solve(N, A)

Solution (Python):
n=input()
flag=0
flag1=0
a=list(map(int,input().split()))
sum=1
a.sort()
for i in a :
    sum*=i
    if(i==0):
        flag1=1
    if(sum>1e18) :
        flag=1
        break
if(flag==0 or flag1==1):
    print(sum)
else : print(-1)

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

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

Solution (Python):
n = int(input())
arr = list(map(int, input().split()))

ans = 1

for x in arr:
    if x == 0:
        ans = 0

if ans == 0:
    print(ans)
else:
    for x in arr:
        ans *= x
        if ans > 1000000000000000000:
            break
    if ans > 1000000000000000000:
        print(-1)
    else:
        print(ans)

Solution (Python):
s=input()
n=input().split(" ")
a=1
flag=False
for i in n:
  if int(i)==0:
    print(0)
    exit(0)
  if flag==False:
    a=a*int(i)
  if a>1000000000000000000:
    flag=True
if flag==True:
  print(-1)
else:
  print(a)

Solution (Python):

n = int(input())
a_lst = list(map(int, input().split()))
x = 10 ** 18





ans = 1
if 0 in a_lst:
    
    ans = 0
else:
    for i in range(n):
        ans *= a_lst[i]
        if ans > x:
            ans = -1
            break
        
        
    




print(ans)

Solution (Python):
n = int(input())
t = list(map(int, input().split()))
t.sort()
r = 1
for i in t:
    r *= i
    if(r > 1000000000000000000):
        r = -1
        break
print(r)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
finish = 0
result = 1

if 0 in A:
    print(0)
    finish = 1
else:
    for n in range(N):
        result = result*A[n]
        if result > 10**18:
            print(-1)
            finish = 1
            break

    if finish == 0:
        print(result)

Solution (Python):
n = int(input())
flag = False
limit = 1000000000000000000
a = [int(item) for item in input().split()]
ans = 1
for i in a:
    if(i == 0):
        flag = True
        break
for i in a:
    ans = ans*i
    if(ans > limit):
        break
if(flag):
    print(0)
elif(ans > limit):
    print(-1)
else:
    print(ans)

Solution (Python):
import sys
n=int(input())
List=list(map(int,input().split()))
List.sort(reverse=True)
if 0 in List:
    print(0)
    sys.exit()
ans=1
for i in List:
    if ans<=10**18:
        ans*=i
    else:
        print(-1)
        sys.exit()
if ans<=10**18:
    print(ans)
else:
    print(-1)

Solution (Python):


N = int(input())

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

ans = 1
flag = True

for i in A:
    if i == 0:
        ans = 0
        flag = False

if flag:
    for i in A:
        ans = ans * i
        if ans > (10 ** 18):
            ans = -1
            break   

print("{}".format(ans))

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

X = 1
c = 0
for i in range(0,N):
    X = X * A[i]
    if X <= 10**18:
        c = c + 1
    else:
        break

if c == N:
    print(X)
else:
    print("-1")

Solution (Python):

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

def main():
  if(0 in A):
    print(0)
    return

  products = 1
  for a in A:
    products *= a
    if(products > 1000000000000000000):
      print(-1)
      return
  print(products)
  return

main()

Solution (Python):
INF = 10 ** 18
N = int(input())
a = list(map(int, input().split()))
ans = 1
if a.count(0) > 0:
    print(0)
    exit()
for i in a:
    ans *= i
    if ans > INF:
        print(-1)
        exit()

print(ans)

Solution (Python):

n = int(input())
ans = 1
MAX = 1e18
lst = input().split(' ')
for x in lst:
	ans = ans*int(x)
	if ans > MAX or ans < 0:
		ans = -1
		
print(ans)

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

ans = 1
a.sort()
for i in range(n):
    ans = ans * a[i]
    if ans == 0:
        ans = 0
        break
    if ans > pow(10,18):
        ans = -1
        break

print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
m =  10**18 
ans = 1
A.sort()
for i in range(N):
  ans *= A[i]
  if ans > m:
    print(-1)
    exit(0)
  if ans == 0:
    break;

print(ans)

Solution (Python):
N = input()
A = list(map(int, input().split()))
newA = sorted(A,reverse=True)
num = 1
if 0 in A:
  num = 0
else:
  for i in newA:
    if num > 1000000000000000000:
      break
    num = num*int(i)
if num > 1000000000000000000:
  print(-1)
else:
  print(num)

Solution (Python):


import sys

n = int(sys.stdin.readline())
ns = sys.stdin.readline().split()

for i in range(0, len(ns)): 
    ns[i] = int(ns[i]) 

ns.sort()

if ns[0] == 0:
	print(0)
else:
	res = 1
	for i in ns:
		res = res * i
		if res > 1000000000000000000:
			res = -1
			break
	print(res)

Solution (Python):
input()
a = input().rstrip().split()
a = [int(a_i) for a_i in a]

res = 1
if 0 in a:
    print(0)
else:
    for a_i in a:
        a_i = int(a_i)
        res = res * a_i
        if res > 1000000000000000000:
            print(-1)
            break
    else:
        print(res)

Solution (Python):
ans = 1
flag = 0

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

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

Solution (Python):
n = int(input())
Sum = 1
Max = 1000000000000000000

l = list(map(int, input().split()))
f = 0
for i in range(n):
  if l[i]==0:
    f = 1
for i in range(n):
  Sum=Sum*l[i]
  if Sum>Max:
     break
if f == 1:
  print("0")
elif Sum<=Max:
  print("%d" % Sum)
else :
  print("%d" % -1)

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

check = True
zero = False

for i in range(0,n):
    if a[i]==0:
        zero = True
        break;




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

    if ans>1000000000000000000:
        check = False
        break;




if zero:
    print(0)
else:
    if check:
        print(ans)
    else:
        print(-1)

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

sum = 1
if 0 in A:
  sum = 0
ans = 0
for x in A:
  sum *= x
  if sum > 1000000000000000000:
    ans = -1
    break
  if sum == 0:
    ans = 0
    break

if ans < 0:
  print(ans)
else:
  print(sum)

Solution (Python):
import sys
from decimal import Decimal
N = int(input())
A = list(map(int,input().split()))
A.sort()
cnt = Decimal('1')
for i in range(N):
  if cnt*Decimal(str(A[i]))>Decimal(10**18):
    print(-1)
    sys.exit()
  cnt = Decimal(cnt)*Decimal(A[i])


print(cnt)

Solution (Python):
import sys
N = int(input())
l = list(map(int,input().split()))

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

ans = 1

for i in l:
    ans *= i
    if ans > 10**18:
        print(-1)
        sys.exit()
print(ans)

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

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

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

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
         
if(0 in A):
  ans = 0 
else:
  ans = 1       
  for a in A:
    ans *= a
    if(ans > 10**18):
      ans = -1
      break
    if(len(str(ans))>=2):
     if(str(ans)[1] == 'e'):
      ans = -1
      break
         
print(ans)

Solution (Python):
n = int(input())
s = 1
l = list(map(int,input().split()))
if(l.count(0) > 0):
    print(0)
else:
    for i in l:
        s*= i
        if(s > 1e18):
            print(-1)
            break
    else:
        print(s)

Solution (Python):
import numpy as np
n = int(input())
data = list(map(int, input().split()))
if 0 in data:
    print(0)
    exit()
ans = 1
for a in data:
    ans*=a
    if ans > 10**18:
        print(-1)
        exit()

print(ans)

Solution (Python):
n = int(input())
lst = list(map(int, input().split()))
lst.sort()
ans = 1
for a in lst: 
    ans *= a
    if ans > 1e18:
        print(-1)
        break
else:
    print(ans)

Solution (Python):
n = int(input())
a_list = list(map(int, input().split()))
ans = 1
for i in a_list:
  ans *= i
  if ans > 1000000000000000000:
    break

if ans > 1000000000000000000 and 0 not in a_list:
              print("-1")
elif 0 in a_list:
              print(0)
else:
              print(ans)

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

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
a = 1
if 0 in A:
    a = 0
else:
    for i in range(N):
        a *= A[i]

        if a > 1000000000000000000:
            a = -1
            break
print(a)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort()
p = True
ans = 1
for i in a :
  ans *= i
  if(ans == 0) :
    print(0)
    p = False
    break
  if(ans > 1000000000000000000):
    print(-1)
    p =False
    break
if p:
  if ans > 1000000000000000000:
    print(-1)
  else:
    print(ans)

Solution (Python):
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 **18
N,*A = map(int, read().split())
if 0 in A:
  print(0)
  sys.exit()
ans = 1
for i in A:
  ans *= i
  if ans > INF:
    print(-1)
    sys.exit()
print(ans)

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

Solution (Python):
n = int(input())
ls = list(map(int, input().split()))
res = 1
if 0 in ls:
    print(0)
    quit()
for x in ls:
    res *= x
    if res > 10**18:
        print(-1)
        quit()
print(res)

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

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

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

print(ans)

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

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

Solution (Python):
from math import log10 as log10

n = int(input())

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

_max = 10 ** (18)

ans = a[0]
min_a = min(a)

for _a in a[1:]:
    if min_a == 0:
        break
    if ans > _max:
        break


    ans *= _a

if (ans > _max):
    print(-1)
elif min_a == 0:
    print(0)
else:
    print(ans)