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):

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

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

Solution (Python):
import functools
import operator

n=int(input())
a=list(map(int,input().split()))
b=0
r=1
if min(a)==0:
  print(0)
  exit()
for i in a:
  r*=i
  if r>10**18:
    print(-1)
    exit()
print(r)

Solution (Python):
from math import *

def cin(): 
    return map(int,input().split())

def cins(): 
    return input.split()

def cino(test=False): 
    if not test:
        return int(input())
    else: 
        return input()

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

def ssplit(): 
    return list(input().split())

def printlist(l): 
    for i in l:
        print(i,end=" ")

def main():
    a = cino()
    l = cina()
    check = True
    suma = 1
    l.sort()
    if l[0]==0:
        print(0)
    else:
        for i in l:
            suma = suma*i
            if suma>1000000000000000000:
                check = False
                break
        if check:
            print(suma)
        else:
            print(-1)


if __name__ == '__main__':
    main()

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

multi = 1

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

Solution (Python):
import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))
b = np.sqrt(a)

lim = 10**9
lim_1 = 10**18
ans_1 = np.prod(b)
ans = np.prod(a)

if ans_1 > lim:
  ans = -1
elif ans_1 < 0:
  ans = -1
    
if ans > lim_1:
  ans = -1
elif ans < 0:
  ans = -1
  
print(ans)

Solution (Python):
n = int(input())
s = input().split(' ')
s_i = [int(val) for val in s]
s_i.sort()
ans = 1
x = 1000000000000000000

for val in s_i:
    ans *= val
    if ans > x:
        ans = -1
        break

print(ans)

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

lim = math.pow(10,18)

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

    if x > 1000000000000000000:
        break

if x > 1000000000000000000:
    x = -1

if 0 in r:
    x = 0

print(math.floor(x))

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

ans = 1
for i in a:
    if i == 0:
      	ans = 0

if ans != 0:
	for i in a:
		ans = ans*i
		if ans > 1000000000000000000:
			break

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

Solution (Python):
n = int(input())
nums = list(map(int,input().split()))
limit = 10**18
res = 1
i = 0
if 0 in nums:
    print(0)
    exit()
while i<n:
    res *= nums[i]
    i += 1
    if res > limit:
        res = -1
        break
print(res)

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

pro = 1

if 0 in a:
    pro = 0
else:
    for i in a:
        if pro > 10 ** 18:
            pro = -1
            break
        else:
            pro = pro * i

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

Solution (Python):
import numpy as np
N = int(input())
list = list(map(int,input().split()))
ans = np.prod(list)
if ans > 10**18 or ans == 0:
  ans = -1
if 0 in list:
  ans = 0
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):
p=int(input())
k=list(map(int,input().split()))
if 0 in k:
    print(0)
else:
    t=k[0]
    for e in range(1,len(k)):
        t = t * k[e]
        if t > 10**18:
          break
    if t > 10**18:
        print(-1)
    else:
        print(t)

Solution (Python):
n = int(input())
A = map(int,input().split())
 
ans = 1
for num in A:
    ans*=num
    if (ans > 10**18):
        ans = -1
        break
if (0 in A):
    ans = 0;
print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
result = 1
target = 10**18
 
if a.count(0) >= 1:
  result = 0
else:
  for an in a:
    result = an*result
    if result > target:
      result = -1
      break
 
print(result)

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

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

i = 0
x = 1
while i < n:
    x = x * a[i]
    i += 1
    if x > 1000000000000000000:
        print(-1)
        exit()

print(x)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
prod = 1
for x in a:
	prod *= x
	if prod > 10**18:
		prod = -1
		break
print(prod)

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

Solution (Python):

from numba import njit
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))


@njit
def f(A):
    ans = 1
    limit = 10**18
    if np.sum(A == 0) > 0:
        return 0
    elif np.sum(np.log10(A)) > 18:
        return -1
    for i in A:
        ans = ans*i
    return ans if ans<=limit else -1



print(int(f(A)))

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

ans = 1

if 0 in A:
    ans = 0

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

Solution (Python):
a=[input() for i in range(2)]

a_num=a[1]
a_num=a_num.split()
a_list=[int(n) for n in a_num]

a_mul=1

if 0 in a_list:
	print(0)

else:
	for i in a_list:
		a_mul*=i

		if a_mul>10**18:
			a_mul=-1
			break

	print(a_mul)

Solution (Python):
n = int(input())
a_list = list(map(int,input().split()))
result = 1
if 0 in a_list:
  print(0)
else:
  for a in a_list:
    result = result *a
    if len(str(result)) >= 19:
      if result == 10**18:
        continue
      else:
        result = -1
        break
        
  print(result)

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

ans = 1
flag = True
for i in range(n):
    ans *= list[i]
    if ans>10**18:
        flag = False
        ans = ans%(10**18)
    if list[i]==0:
        flag = True
        break

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

Solution (Python):
n = int(input())
a = input().split()
ans = 1
if '0' in a:
    ans = 0
else:
    for i in a:
        ans = ans*int(i)
        if ans > 1000000000000000000:
            print(-1)
            exit()
print(ans)

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

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

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

check = 10 ** 18
ans = int_list[0]
for i in int_list[1:]:
    ans = ans * i

    if ans > check:
        ans = -1
        break

for i in int_list:
    if i == 0:
        ans = 0
        break

print(ans)

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

if min(As) == 0:
    print(0)
else:
    ans = 1
    for i in As:
        ans *= i
        if ans > 10 ** 18:
            print(-1)
            break
    else:
        print(ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
lim = 10**18

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

  
ans = 1
A.sort(reverse = True)
for i in range(len(A)):
  ans = ans * A[i] 
  if ans > lim:
    print(-1)
    exit()

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

Solution (Python):
n=int(input())
list=[int(i) for i in input().split()]
k=1
list.sort()
x=list[0]
while k<n:
  y=x*list[k]
  x=y
  if y<=1000000000000000000:
    k=k+1
  else:
    k=n+1
    y=-1
print(y)

Solution (Python):
from operator import mul
from functools import reduce
N, *A = map(int, open(0).read().split())

while len(A) > 1:
  n = len(A)
  if n & 1:
    A.append(1)
    n += 1
  L, R = A[:n//2], A[n//2:]
  A = [x * y for x, y in zip(L, R)]
x = A[0]
if x > 10 ** 18:
  x = -1
print(x)

Solution (Python):
LIMIT = 1000000000000000000

def main():
    N = int(input())  
    a = list(map(int, input().split()))  
    answer = 1

    for i in range(N):
        answer *= a[i]
        if answer > LIMIT:
            if 0 in a[i:]:
                print(0)
                return
            else:
                print(-1)
            return

    print(answer)

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
p=list(map(int, input().split()))
i=0
ans=1
flag=0
k=1e18
while(n>i):
	if(p[i]==0):
		flag=1
	i+=1
if(flag==1):
	print(0)
else:
	flag=0
	i=0			
	while(n>i):
		ans*=p[i]
		if(ans>k):
			flag=1
			break
		i+=1		
	if( flag==1):
		print(-1)
	else:
		print(ans)

Solution (Python):
n = int(input())
num = input()
num = num.split()
if '0' in num:
    print(0)
    exit()
ans = 1
MAXX = 1000000000000000000
for item in num:
    ans = ans * int(item)
    if ans > MAXX:
        print(-1)
        exit()
print(ans)

Solution (Python):
n = int(input())
res = 1
a = list(map(int,input().split()))
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());
l=list(map(int,input().strip().split()))
l.sort()
if l[0] == 0 : 
    print("0")
else :    
    ans = l[0]
    c=0
    for i in range(1, n) :
        if l[i]*ans >  int(1000000000000000000) :
            print("-1")
            c=1
        if c == 1 : 
            break 
        ans = ans*l[i]    
    if c == 0 : 
        print(ans)

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

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

print(ans)

Solution (Python):
n = input()
a = input()
a = a.split()
x = 0;
mul = 1;

for num in a:
    if(int(num) == 0):
    	mul = 0;
    	break;
    	
for num in a:
	mul *= int(num)
	if(mul > 1000000000000000000):
		mul = -1;
		break;
    
print(mul);

Solution (Python):
n = int(input())
arr = []
p = 1
c = 0
l = 0
a = list(map(int,input().strip().split()))[:n] 

for i in range(n):
    if a[i]==0:
        c = 1
    if p > 1000000000000000000:  
        l = 1
    else:    
        p *= a[i]
if c == 1:
    print(0)
elif l == 1 or p > 1000000000000000000 :
    print(-1)
else:
    print(p)

Solution (Python):
import sys

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

for val in a:
    if val == 0:
        print("0")
        exit(0)

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

print(ans)

Solution (Python):
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n= ii()
a= li()

ans=1
a.sort()
a.reverse()

if a[-1] == 0:
    print(0)
    exit()

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

Solution (Python):
def main():
    N = input()
    listCulcNum = list(map(int, input().split()))

    answer = 1
    maxNum = 10 ** 18

    if(0 in listCulcNum):
        print(0)
        return

    for culcNum in listCulcNum:
        answer = answer * culcNum

        if(answer > maxNum):
            answer = -1
            break

    print(answer)

if __name__ == "__main__":
    main()

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

Solution (Python):
import numpy as np
import math
import functools
import operator
N=int(input())
A = list(map(int, input().split()))

if A.count(0)>0:
    ans=0
elif N>30 and A.count(1)<10:
    ans=-1
    
else:
    ans=functools.reduce(operator.mul, A)
if ans>10**18 :
    ans=-1
print(ans)

Solution (Python):
n=int(input()) 
alist=list(map(int,input().split()))
a=1
if 0 in alist:
    print("0")
else:
    for i in alist:
        if a<=10**18:
            a=a*i
        else:
            break
    if a>10**18:
        print('-1')
    else:
        print(a)

Solution (Python):
n = int(input())
num_list =list(map(int, input().split()))
res = 1
INF = int(1e18)
num_list.sort()
if num_list[0] == 0:
    print(0)
    exit()
for i in range(n):
    res *= num_list[i]
    if res > INF:
        print(-1)
        exit()
print(res)

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

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

Solution (Python):
n,*l=map(int,open(0).read().split())
a=1
for i in sorted(l):
  a*=i
  if a>10**18: a=-1; break
print(a)

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

ans = 1
if 0 in A_list:
    ans = 0
else:
    for l in A_list:

        if ans > (10**18):
            ans = -1
            break
        else:
            ans *= l

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

Solution (Python):
input()
a = sorted(map(int, input().split()))
if a[0] == 0:
    print(0)
else:
    ans = a[0]
    for ai in a[1:]:
        ans *= ai
        if ans > 10 ** 18:
            ans = -1
            break
    print(ans)

Solution (Python):
N = int(input())
sum = 1
keta = 0

numbers = input().split()
if not ("0" in numbers):
    for num in numbers:
        keta += len(num) - 1
        if keta > 19:
            print(-1)
            exit()
        sum *= int(num)
        if len(str(sum)) > 19:
            print(-1)
            exit()
        
    if len(str(sum)) == 19:
        if str(sum).count("1") == 1 and str(sum).count("0") == 18:
            pass
        else:
            print(-1)
            exit()
else:
    print(0)
    exit()
print(sum)

Solution (Python):

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

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

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

print(result)

Solution (Python):
n = int(input())
temparr = input()
temparr = temparr.split()
flag = 0 

arr = []
first = 0 
totallen = 0 
arr =[]
arr1 = []
for i in temparr:
    arr1.append(int(i))
arr1 = sorted(arr1)
for i in arr1:
    if i == 0 :
        flag = 1 
        break 
    if i == 1 :
        continue 
    
    if first == 0 :
        totallen += len(str(i))
        first = 1 
    else:
        totallen += len(str(i)) - 1 
    if totallen > 19:
        flag = 2
        break
    arr.append(i)
    
    
if flag == 2:
    print("-1")
elif flag == 1 :
    print("0")
else:
    ans = 1
    arr = sorted(arr)
    arr = arr[::-1]
    for i in arr:
        ans *= i 
        if ans > 1000000000000000000:
            flag = 1 
            break 
    if flag == 0 :
        print(ans)
    else:
        print(-1)

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

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


if 0 in a:
  pass

elif len(a) % 2 == 1: 
  for i in range(1, int(len(a)/2)+2):
    
    if ans > 10**18 or ans == 0:
      break
    if i == int(len(a)/2) + 1:
      ans = ans*a[i-1]
    else:
      ans = ans*a[i-1]*a[-1*i]
    
else:
  for i in range(0, int(len(a)/2)):
    if ans > 10**18 or ans == 0:
      break
    ans = ans*a[i]*a[-1 - i]
    

if ans > 10**18:
  print('-1')
elif 0 in a:
  print(0)
else:
  print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
w=pow(10,18)
p=1
a.sort()
if a[0]==0:
  print(0)
else:
  for k in range(n):
    p*=a[k]
    if p>w:
      print(-1)
      break
  if p<=w:
    print(p)

Solution (Python):
import numpy as np
from decimal import *
 
n = int(input())
a = list(map(Decimal, input().split()))
b = np.array(a)
temp = 1
 
if a.count(0) >0:
  print(0)
  exit()
 
for i in range(n):
  temp = b[i] * temp
  if temp > 10**18 or temp < 0:
    print('-1')
    exit()
 
print(temp)

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


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

print(ans)

Solution (Python):
import collections
import sys

N=int(input())
A=list(map(int, input().split()))
A_dict=collections.Counter(A)
ANS=1
if 0 in A_dict.keys():
    print("0")
    sys.exit()
    
for key, value in A_dict.items():
    ANS=ANS*(key**value)
    if ANS>10**18:
        print(-1)
        sys.exit()

print(ANS)

Solution (Python):
import sys
def main():
    N = int(input())
    A_list = [int(_) for _ in input().split()]
    ans = 1
    
    if 0 in A_list:
        out = 0
        print(out)
        sys.exit()
    
    for i in range(N):
        ans = ans * A_list[i]
        
        if ans>1000000000000000000:
            ans = -1
            break
    out = ans
    print(out)

main()

Solution (Python):
import numpy as np
n = int(input())
target = 1
List = list(map(int,input().split()))
if 0 in List:
  print(0)
  exit()
for i in range(len(List)):
  target*=List[i]
  if target>10**18 :
    print(-1)
    exit()
print(target)

Solution (Python):
n=int(input())
a=list(input().split())
ans=1
f=0
i=0
while(i<n):
    if f==0:
        ans=ans*int(a[i])
    if f==0 and ans>1000000000000000000:
        f=1
    if int(a[i])==0:
        print(0)
        exit()
    i+=1
if f==1:
    print(-1)
    exit()
print(ans)

Solution (Python):
import sys
n = int(input())
a = list(map(int, input().split()))
ans = 1
flag = True
if 0 in a:
    print(0)
    sys.exit()

for i in a:
    ans *= i
    if ans > 1000000000000000000:
        flag = False
        break

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

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

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

Solution (Python):

import math
def num():
    return map(int , input().split())
def nu():
    return int(input())
def li():
    return input().split()
def sli():
    return list(map(str, input().split()))
def lli ():
    return list (map(int, input ().split ()))
def fli():
    return [float(x) for x in input().split()]

n = nu()
a = lli()

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

Solution (Python):
import math
N=int(input())
risuto=list(map(int,input().split()))
ans=1
kari=0
if 0 in risuto:
    print(0)
else:
    for j in range(N):
        kari+=math.log10(risuto[j])

    if kari<18:
        for i in range(N):
            ans*=risuto[i]
        print(ans) 
    elif kari==18:
        for i in range(N):
            ans*=risuto[i]
        if ans>10**18:
            print(-1)
        else:
            print(ans)
    else:
        print(-1)

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):
n = input()
a = list(map(int,input().split()))
ans = 1
if 0 in a:
    print(0)
    exit()
for ai in a:
    ans = ans * ai
    if ans > 10 ** 18:
        print("-1")
        exit()
print(ans)

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

Solution (Python):
import sys
N=int(sys.stdin.readline())
values = []
res = 1
values=sys.stdin.readline().split()
for v in values:
    if int(v) == 0:
        print(0)
        exit(0)

for v in values:
    res *= int(v)
    if res > 1000000000000000000:
        print(-1)
        exit(0)
print(res)

Solution (Python):
from operator import mul
from functools import reduce
n = input()
tmp = input().split(" ")
l = sorted([int(e) for e in tmp])
def solve():
    res = 1
    for e in l:
        res = e*res
        if res > 1e+18:
            print("-1")
            return
    print(res)
solve()

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

import sys
if l.count(0) > 0:
    print(0)
    sys.exit()

ans = 1
for x in l:

    ans = ans * x

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

print(ans)

Solution (Python):
import sys
N = int(input())
A = list(map(str,input().split()))
for i in range(N):
    if A[i] == '0':
        print('0')
        sys.exit()

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

print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
sum  = 1
flag = 0
for i in A:
    if(i == 0):
        print(0)
        flag=2
        break
if(flag==0):
    for i in A:
        sum = sum * i
        if(sum > 10**18):
            flag=1
            break
if(flag==0):
    print(sum)
elif(flag==1):
    print(-1)

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

Solution (Python):

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1

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


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
l = input().split()
ans = 1
T = True
for i in range(n):
    if l[i] == '0':
        ans = 0
        break
if ans != 0:
    for i in range(n):
        if ans <= 10**18:
            ans = ans * int(l[i])
        else:
            T = False
            break
if False:
    print(-1)
elif ans > 10**18:
    print(-1)
else:
    print(ans)

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

Solution (Python):
import math

L = 10 ** 18

N = int(input())
A = [N]
A = list(map(int, input().split()))
ans = 1
for i in A:
    if i == 0:
        ans = 0
        break
    elif ans == -1:
        continue
    elif ans * i > L:
        ans = -1
    else:
        ans *= i

print(ans)

Solution (Python):
import numpy as np
N = int(input())
A = list(input().split())

Af =  np.array(A,dtype='float64')
Afans = np.prod(Af,dtype='float64')

if Afans == 0.:
    print('0')
elif Afans >=2e18:
    print('-1')
else:
    Ai =  np.array(A,dtype='int64')
    Aians = np.prod(Ai,dtype='int64')
    if Aians <=np.int64(1e18) and Aians >=np.int64(0):
        print(Aians)
    else:
        print("-1")

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

multi = 1
a = 1

for i in range(n):
    if n_list[i]==0:
        a = 0
        break

for i in range(n):
    if a == 0:
        multi = 0
        break

    multi *= n_list[i]

    if multi>1e18:
        break

if multi<=1e18:
    print(multi)
else:
    print(-1)

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

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

for item in a:
    if item == 0:
        print(0)
        exit()

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

print(ans)

Solution (Python):
a = int(input())
b = input().split()

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



state=1
for x in b:
    if x==0:
        state=0
        print("0")
        break

res=1
if state==1:
    for x in b:
        res*=x
        if res>1000000000000000000:
            print("-1")
            state=0
            break

if state==1:
    print(res)

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 sys
n = int(input())
l = list(map(int,input().split()))
if 0 in l:
  print(0)
  sys.exit()
flag = True
anz = 1
for i in l:
  anz *= i
  if anz > 1000000000000000000:
    flag = False 
    break
print (anz if flag else -1)

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

if nums.count(0) > 0:
  ans = 0
else:
  for i in range(n):
    ans *= nums[i]
    if ans > 10**18:
      ans = -1
      break

print(ans)

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

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

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
y = 1
x.sort()
for i in range(n):
  y *= x[i]
  if y > 1000000000000000000:
     y = -1
     break

print(y)

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


if __name__ == "__main__":
    main()

Solution (Python):
from sys import stdin, stdout  
  


def main(): 
  
    
    n = stdin.readline() 
  
    
    arr = [int(x) for x in stdin.readline().split()] 
  
    
    summation = 1
    for x in arr:
        if x==0:
            summation=0
            break
    
    for x in arr: 
        summation *= x
        if summation>1e18:
            summation=-1
            break
  
    
    if summation>1e18:
        print("-1");
    else:
        print(summation);


    
    
    
    
    
    
  

if __name__ == "__main__": 
    main()

Solution (Python):
import sys

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

limit = pow(10, 18)

nums = list(input().split())

for num in nums:
    num = int(num)
    if num == 0:
        print(0)
        sys.exit(0)

accum = 1
for num in nums:
    num = int(num)
    try:
        accum *= num
    except Exception:
        accum = -1
        break

    if accum > limit:
        accum = -1
        break

print(accum)

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

Solution (Python):
n = int(input())
num = list(map(int,input().split(" ")))
 
zero=num.count(0)
z= 10 **18
if zero != 0:
  print(0)
else:
  s = num[0]
  for i in range(1,n):
    s = s * num[i]
    if s > z:
      s=-1
      break
  print(s)

Solution (Python):
import numpy as np
import sys

n = int(input())
a = [list(map(int,input().split())) for i in range(1)]
arr = a[0]
list.sort(arr, reverse=True)

if arr[-1] == 0:
    print(arr[-1])
    sys.exit()

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

Solution (Python):
n = int(input())
li = list(map(int, input().split()))
li_k = list(map(lambda n: len(str(n))-1, li))

if 0 in li:
    print(0)
elif sum(li_k) > 18:
    print(-1)
else:
    ans = li[0]
    for i in li[1:]:
        ans *= i
        if ans > 1000000000000000000:
            break
    if ans > 1000000000000000000:
        print(-1)
    else:
        print(ans)

Solution (Python):
n = int(input())
res = 1
a = list(map(int,input().split()))
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 = [int(i) for i in input().split()]
x = 1
f = 0
a.sort()
for i in range(n):
    
    x = x*a[i]
    if x == 0:
        print(0)
        f = 1
        break
    elif x > 1000000000000000000:
        print(-1)
        f = 1
        break
if f == 0:
    print(x)

Solution (Python):
n=int(input())
ans=1
zero=False
minus=False
li = input().split()
for i in li:
  a=int(i)
  if a==0:
    zero=True
    break
  if minus:
    continue
  ans*=a
  if ans>1000000000000000000:
    minus=True

if minus:
  ans=-1
if zero:
  ans=0
print(ans)

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

b1=1
b2=0
b3=0

if 0 in a:
  print(0)
else:
  for i in range(n):
    b1*=a[i]
    b2*=a[i]
    if b1>=10**9:
      b2+=b1//(10**9)
      b1%=10**9
    if b2>=10**9:
      b3+=b2//(10**9)
      b2%=10**9
      break
  
  if b3>=1 and (b1!=0 or b2!=0):
    print(-1)
  else:
    print(b3*(10**18)+b2*(10**9)+b1)

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

Solution (Python):
import sys
n = int(input())
nums = [int(e) for e in input().split()]
g = 1;
for a in nums:
  if a == 0:
    print("0");
    sys.exit()
for i in nums:
  g*=i;
  if g>1000000000000000000:
    print("-1")
    sys.exit()
print(g)