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 = list(map(int, input().split()))

ans=1
flag0=0
flag1=0
inf=1000000000000000000

for a in A:
	if(a==0):
		flag0=1
		
if flag0==1:
	print(0)
	
else:
	for a in A:
		ans=ans*a
		if(ans>inf):
			flag1=1
			break

	if flag1==1:
		print(-1)
	else:
		print(ans)

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

Solution (Python):
N = int(input())
A = input().split()
answer = 1
flag = 0
x = 10**18

if '0' in A:
  print(0)
  flag = 1
  


if flag == 0:
  for i in range(N):
    answer *= int(A[i])
    if answer > x:
      print(-1)
      flag = 1
      break

if flag == 0:    
  print(answer)

Solution (Python):
N = int(input())
As = list(map(int, input().split()))
 
A = set(As)
 
if 0 in A:
  print(0)
  exit()

rlt = 1
for i in As:
  if i > 1e18:
    print(-1)
    exit()
  else:
    rlt *= i
    if rlt > 1e18:
      print(-1)
      exit()
      
print(rlt)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
 
tmp = 1
for num in A:
    tmp *= num
    if tmp > 1e18:
      break
  
if tmp <= 1e18:
    print(tmp)
elif 0 in A:
    print(0)
else:
    print(-1)

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

A.sort()


res = 1
for a in A:
    res *= a
    if res > 10 ** 18:
        res = -1
        break

print(res)

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

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

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

Solution (Python):
import sys
n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 1
for i in l:
    count= count*i
    if count == 0:
        print("0")
        sys.exit()
    elif count > 10**18:
        print("-1")
        sys.exit()
if count > 10**18:
    print("-1")
    sys.exit()
print(count)

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

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

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

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

if cum == 0:
    print(0)
else:
    for x in a:
        cum *= x
        if (cum > 1e18):
            over = True
            break
    print(-1) if over else print(cum)

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

Solution (Python):
a = int(input())
A = [int(i) for i in input().split()]
total = 1
for i in A:
    if total != -1:
        total *= i
        if total > 10**18:
            total = -1
    else:
        if i==0:
            total = 0
            break
print(total)

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

Solution (Python):
n=int(input())
a = list(map(int,input().split()))
b=0 in a
c=1
d=0
for i in range(n):
    c=c*a[i]
    if c>1000000000000000000:
        d=1
        break
    
if c<=1000000000000000000:
    print(c)
if d==1:
    if b==True:
        print("0")
    else:
        print("-1")

Solution (Python):
n=int(input())
l = list(map(int,input().strip().split()))[:n] 
rs= 1
l.sort()
if l[0]==0 :
    rs=0
else:
    for i in range(n):
        if(10**18 // rs < l[i]):
            rs = -1
            break
        rs=l[i]*rs
print(rs)

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
x = sorted(list(map(int, input().split())))
t = 1
for num in x:
    t = t * num
    if t > 10 ** 18:
        print(-1)
        sys.exit()

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

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

if 0 in listA:
    print(0)
    exit()
result = 1
maxA = 10 ** 18
for a in listA:
    result *= a
    if result > maxA:
        result = -1
        break
print(result)

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

    if 0 in set(A_list):
        print(0)
        exit()

    ans = 1
    for i in A_list:
        ans *= i
        if 1000000000000000000 < ans:
            print('-1')
            exit()
    else:
        print(ans)


main()

Solution (Python):
mul,f = 1, 0
input()
l = list(map(int, input().split()))
if l.__contains__(0):
    print(0)
    f = 1
else:
    for i in l:
        mul = mul * i
        if mul>1000000000000000000:
            print(-1); break;
    else:
        print( mul)

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

for i in range(N):
    if(A[i]==0):
        flag=1

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

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

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

a = [int(x) for x in input().split(" ")]
ans = 1
fail = False
zero = False
for i in range(N):
	if(not fail):
		ans*=a[i]
	if(not fail and ans>1000000000000000000 or ans<0) :
		fail = True
	elif(a[i]==0) :
		zero = True
		ans=0
		break

if(fail and not zero) :
	print("-1")
else:
	print(ans)

Solution (Python):
import sys

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

ans=1
if 0 in m:
  print(0)
  sys.exit()

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

if ans<=pow(10,18):
  print(ans)

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

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

Solution (Python):
ans = 1
n = input()
n = int(n)
nums = input().split()
for i in range(n):
    mul = int(nums[i])
    if mul == 0:
        print(0)
        exit()


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

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

exit()

Solution (Python):
n = int(input())
a= input().split()
level = pow(10, 18)
product = 1

if "0" in a:
  print(0)
else:
  for num in range(n):
    product *= int(a[num])
    if product > level:
      print("-1")
      break
  if product <= level:
    print(product)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
b=A[0]

if(A.count(0)!=0):
    print('0')
    exit()

for i in range(1,len(A)):
    b=b*A[i]
    if(10**18<b):

        print('-1')
        exit()
        
print(b)

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

Solution (Python):
import sys
n = int(input())
a =[ [int(c) for c in l.split()] for l in sys.stdin]
a =a[0]
m = 1

if (0 in a)==True:
 m=0
else:
 for i in range(n):
  m*=a[i]
  if m>10**18:
   m=-1
   break

print(m)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = 1
check = 0
for i in a:
  if i == 0 :
    check = 1

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
b = [i for i in a if i != 1]
ans = 1
if len(b) < 100:
    for i in range(len(b)):
        ans *= b[i]
else:
    ans = 10**18+1
if 0 in b:
    ans = 0
print(ans if ans <= 10**18 else '-1')

Solution (Python):
input_line1 = input()
N = int(input_line1)
input_line2 = input()
numbers = input_line2.split()
num_sum = 1
 
if '0' in numbers:
    print(0)

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

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 > 1000000000000000000):
        print(-1)
        exit()

print(ans)

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

Solution (Python):
import collections

N = int(input())
cNum = collections.Counter(list(map(int, input().split())))
ans = 1
if cNum[0] != 0:
  print("0")
  exit()
for n in cNum.keys():
  ans *= n**cNum[n]
  if ans > 10**18:
    ans = -1
    break
print(ans)

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

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
ans = 1
A.sort()
for i in A:
  ans *= i
  if i == 0:
    print(0)
    break
  if ans > 10**18:
    print("-1")
    break
if ans <= 10**18 and ans !=0:
  print(ans)

Solution (Python):
over = 10**18

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

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

Solution (Python):

import numpy as np
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
ans =1
if 0 in A:
    ans =0
else:
    for i in A:
        ans *=i
        if 10**18 < ans :
            ans = -1
            break
print(ans)

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

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

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

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

if 0 in A:
    print(0)
else:
    M = 1
    for a in A:
        M *= a
        if M > 1000000000000000000: break

    print(-1 if M > 1000000000000000000 else M)

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

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

ans = 1
keta = 0
if 0 in A:
  print(0)
  exit()

for x in A:
  ans *= x
  keta += len(str(x))
  if ans > 1000000000000000000:
    print(-1)
    exit()

print(ans)

Solution (Python):
def product(list):
    num = 1

    if any([i == 0 for i in num_list]):
        print(0)
        return
     
    for i in num_list:
        num *= i
        if num > 1000000000000000000:
            num = -1
            break

    print(num)


N = int(input())

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

product(num_list)

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

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

Solution (Python):
n = int(input())
lst = list(map(int, input().strip().split()))[:n]
mx = 1000000000000000000
if 0 in lst:
    print(0)
else:
    cur = lst[0]
    for x in lst[1:]:
        cur = cur * x
        if cur > mx:
            cur = -1
            break
    print(cur)

Solution (Python):
def main():
    n = int(input())
    ls = list(map(int, input().split()))
    ans = 1
    if 0 in ls:
        print(0)
        return
    for l in ls:
        ans *= l
        if (ans > 1000000000000000000):
            print(-1)
            return
    print(ans)
    return
if __name__ == '__main__':
    main()

Solution (Python):
import sys

n = int(input())
num_list = list(map(int, input().split()))
num_list.sort()
a = 1;
for i in range(n) :
  a *= num_list[i]
  if a > 1000000000000000000 :
    print("-1")
    sys.exit()
    
print(a)

Solution (Python):


n = int(input())

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

ans = 1
flg = 1

for a in i:
  if(a == 0):
    print(0)
    flg = 0

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

if(flg==1):
  print(ans)

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

    if 0 in a:
        print(0)
        return

    maks = 10**18
    mnozenje = 1
    for i in a:
        mnozenje *= i

        if mnozenje > maks:
            print(-1)
            return

    print(mnozenje)


if __name__ == '__main__':
    main()

Solution (Python):
from sys import *
n = stdin.readline()
things = list(map(int, stdin.readline().split()))

if min(things) == 0:
    print(0)
    exit()
hue = things[0]
for i in range(1, len(things)):
    hue *= things[i]
    if hue > 10**18:
        print(-1)
        exit()
print(hue)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)

def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappop, heappush


def solve():
    n = II()
    A = LI()
    th = 1_000_000_000_000_000_000
    ans = 1
    if 0 in A:
        print(0)
        return

    for a in A:
        ans *= a
        
        if ans > th:
            print(-1)
            return
    print(ans)


if __name__ == '__main__':
    solve()

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]

reg = A[0]
flg=True
if 0 in A:
    print(0)
    flg=False
    reg=0
for i in range(1, N):
    reg *= A[i]
    if reg>10**18:
        print(-1)
        flg=False
        break
if flg:
    print(reg)

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

count=0
if 0 in s:
  print(0)
  count=1
else:
  a=1
  for i in s:
    a*=i
    if a>10**18:
      print(-1)
      break
if a<=10**18 and count!=1:
  print(a)

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

if 0 in A:
    print(0)
    exit(0)
    
ret = 1
for a in A:
    ret *= a
    if len(str(ret)) >= 19 and ret != 10 ** 18:
        print(-1)
        exit(0)
    

if len(str(ret)) >= 19 and ret != 10**18:
    print(-1)
else:
    print(ret)

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

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

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

print(a)

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

Solution (Python):
from sys import stdin, stdout
from collections import defaultdict

def main():
    n = int(stdin.readline())
    a = list(map(int,stdin.readline().split()))
    f = 1
    flag=0
    a = sorted(a)
    for i in range(n):
        f = f*a[i]
        if f>10**18:
            flag=1
            break
    if flag:
        print("-1")
    else:
        print(f)

main()

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

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

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

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

Solution (Python):
def fun(A):
    for i in A:
        if i == 0:
            return 0
    ans = 1
    for i in A:
        ans = ans*i
        if(ans > 1000000000000000000):
            return -1
    return ans

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

Solution (Python):
n = int(input())
arr = list(map(int, input().split()))
total = 1
if 0 in arr:
    print(0)
else:
    for num in arr:
        if total > 10**18:
            break
        total *= num
    if total > 10**18:
        print(-1)
    else:
        print(total)

Solution (Python):



count_num = int( input())
text = input()

num_data = text.split(' ')

ans = 1
for i in num_data:
        if i == '0':
                ans = 0
                break

if ans == 1:
        for i in num_data:
                ans = ans * int(i)
                if ans > 1000000000000000000:
                        ans = -1
                        break

print(ans)

Solution (Python):
n = int(input())
 
List = [int(i) for i in input().split()]
lst = sorted(List, reverse=True)
if lst[-1] == 0:
  print(0)
  exit()
total = 1
for i in lst:
  total = total*i
  if total > 1000000000000000000:
    print(-1)
    exit()
print(total)

Solution (Python):









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

print(answer)

Solution (Python):
n=int(input())
arr=input()
prod=1
k=1;
l=list(map(int,arr.split(' ')))


for x in l:
    if(x==0):
        k=0
        break

if(k==0):
    print(0)
else:
    for x in l:
        prod*=x
        if(prod>1000000000000000000):
            prod=-1
            break
    print(prod)

Solution (Python):
import sys
N = int(input().strip())
array = list(map(int, input().strip().split()))
ans = 1
for i in array:
  if i == 0:
    print(0)
    sys.exit()
for i in array:
  ans *= i
  if ans > 1e18:
    print(-1)
    sys.exit()
if ans > 1e18:
  print(-1)
else :
  print(ans)

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
z,flag=1,0
m=10**18
mi=min(l)
if mi==0:
  print(0)
else:
  for i in l:
    z*=i  
    if z>m:
      flag=1
      break
  if flag==1:
    print(-1)
  else:
    print(z)

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

ans = 1

flag = True
for i in range(n):
    ans *= a[i]
    if ans > 1000000000000000000:
        flag = False
        break

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

Solution (Python):
n,*a=map(int,open(0).read().split())
s=1
if 0 in a:
    print(0)
    exit()
for i in a:
    s*=i
    if  s > 1e18:
        print(-1)
        exit()
print(s)

Solution (Python):
how_many = input()
a = []
a = list(map(int, input().split()))
st = set(a)

c = 0
for i in a:
    p = str(i)
    c += len(p)
if (0 in st):
    print(0)
    quit()

max = 1
for i in a:
    max = max * i
    if(1000000000000000000 < max):
        print('-1')
        quit()
    
print(max)

Solution (Python):

a=int(input())
li = list(map(int,input().split()))
if 0 in li:
  print(0)
  
else:
  result = 1
  for number in li:
    result = result * number
    if result > 10**18:
      print(-1)
      break

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

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

for a in A:
    if (a == 0):
        print(0)
        exit()
    
    if (calcneeded == 1):
        ans*=a
    
    if (ans > 10**18):
        calcneeded=0

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

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

if 0 in A:
    print(0)
    sys.exit()
else:
    for i in A:
        mult *= i
        if mult > 10**18:
            print('-1')
            sys.exit()

print(mult)

Solution (Python):
import sys
n=int(input())
list=input().split(" ")
x=1

if "0" in list:
  print(0)
  sys.exit()
for i in list:
  x*=int(i)
  if x>1e18:
    print(-1)
    sys.exit()
print(x)

Solution (Python):
N = int(input())
A = [1] * N + [int(a) for a in input().split()]
for i in range(N-1, 0, -1):
    A[i] = A[2*i] * A[2*i+1]
print(A[1] if A[1] <= 10 ** 18 else -1)

Solution (Python):
import numpy as np
N = int(input())
A = list(map(int, input().split()))
se = 1
c = True
for n in range(N):
  se *= A[n]
  if se >  10**18:
    c = False
    break
for n in range(N):
  if A[n] == 0:
    se = 0
    c = True
if c:
  print(se)
else:
  print("-1")

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

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

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

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

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

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

Solution (Python):
from functools import reduce
from math import log10

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

mul = 1

for a in A:
    mul *= a
    if mul > 10**18:
        print('-1')
        break
else:
    print(mul)

Solution (Python):
n = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)
res = 1
flag0 = False
if 0 in a_list:
  res = 0
else:
  for i in range(n):
    res = a_list[i]*res
    if res > 1000000000000000000:
      res = -1
      break

print(res)

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

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A = [1] * N + [int(a) for a in input().split()]
for i in range(N-1, 0, -1):
    A[i] = A[2*i] * A[2*i+1]
print(A[1] if A[1] <= 10 ** 18 else -1)

Solution (Python):
max_number = 10 ** 18
len_number = int(input())
number_list = list(map(int, input().split()))

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

number_list.sort(reverse=True)

is_over_max = False
answer = 1
for n in number_list:
    answer *= n
    if max_number < answer:
        is_over_max = True
        break

if is_over_max:
    print(-1)
else:
    print(answer)

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 > 1000000000000000000:
        print(-1)
        exit()

print(ans)

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

s=1
if min(A) == 0:
    s = 0
    print(s)
elif max(A) > 10**18:
    s = -1
    print(s)
else:
    for i in range(N):
        s = s*A[i]
        if s > 10**18:
            s = -1
            print('-1')
            break
    if s != -1:
        print(s)

Solution (Python):
n=int(input())
l=list(map(int, input().split()))
val=0
ans=1
num=10**18
if 0 in l:
    print(0)
else:
    for i in l:
        l1=len(list(str(ans)))
        l2=len(list(str(i)))
        if l1+l2>20:
            val=1
            break
        ans=ans*i
        if ans>num:
            val=1
            break
    if val==1:
        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())
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()))
if 0 in A:
    print(0)
    exit()
ans = 1
for a in A:
    ans *= a
    if ans > 10**18:
        print(-1)
        exit()
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())
alis=sorted(list(map(int,input().split())))
p=alis[0]
if p==0:
  print(0)
  exit()
bre=False
for i in range(1,n):
  p*=alis[i]
  
  
  if len(list(str(p)))>18:
    bre=True
    break


if bre:
  sa=list(map(int,list(str(p))))
  if sum(sa)!=1:print(-1)
  else:print(p)
else:print(p)

Solution (Python):
limit = 1E18
n = int(input())
total = 1

line = str(input())

if line.startswith("0 ") or " 0" in line:
    print(0)
    exit()

for i in line.split():
    x = int(i)
    total *= x
    if total > limit:
        print(-1)
        exit()

print(-1 if total > limit else total)

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

    ans = ans * i
    if ans == 0:
        break
    if ans > 1000000000000000000:
        ans = -1
        break

print(ans)

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

ans=1;
for i in a:
    ans*=i
    if(ans>1000000000000000000):
        break
if(ans>1000000000000000000):
    print(-1)
if(ans<=1000000000000000000):
    print(ans)

Solution (Python):
N = int(input())
A_list = list(map(int, input().split()))
A_list.sort(reverse=True)
n = 1
for i in A_list:
  if A_list[-1] == 0:
    print(0)
    break
  n = n * i
  if n > 1000000000000000000:
    print(-1)
    break
else:
  print(n)

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

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

limit = pow(10, 18)

ans = 1

if 0 in nums:
    ans = 0
else:
    for e in nums:
        if ans > limit / e:
            ans = -1
            break
        else:
            ans *= e

if ans > limit:
    ans = -1

print(int(ans))

Solution (Python):
import math
 
A = 1
N = int(input())
array = input().split()
flag = True
for i in range(N):
	A = (A * int(array[i]))
	if A > math.pow(10,18):
		flag = False
		break

if flag:
  print(A)
else:
  if '0' in array:
    print(0)
  else:
    print(-1)

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

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

if 0 in a:
    ans = 0
else:
    for i in a:
        ans *= i
        if ans >= LIMIT:
            ans = -1
            break

print(ans)

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

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

sum0 = str_list[0]

for n in range(0,N):
    if str_list[n] == 0:
        sum0 = 0

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

print(sum0)

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

P = 1
flag = 0

for i in range(N):
    P = P * newA[i]
    if P == 0:
        print(P)
        flag = 1
        break
    elif P > 1e18:
        print(-1)
        flag = 1
        break
        
if flag == 0:
    print(P)

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

pro=1
List.sort()
for i in range(n):
    pro *=List[i]
    if pro > 10**18 :
        print("-1")
        exit()

print(pro)

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

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

sum = 1
for i in a:
  sum = sum * int(i)
  if sum > 1000000000000000000:
    break

if "0" in a:
  print(0)
elif sum > 1000000000000000000:
  print(-1)
else:
  print(sum)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 1
check = 10 ** 18

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

print(ans)

Solution (Python):
N=int(input())
A=[int(x) for x in input().split()]
A.sort(reverse=True)
result=1
if 0 in A:
    print(0)

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

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

y = 1
q = 1
z = 1
for i in range(0, n):
  if a[i] == 0:
    q = 0

for i in range(0, n):
  z = z * a[i]
  if z > 1000000000000000000:
    y = -1
    break
 
if q == 0:
  print(0)
elif z <= 1000000000000000000:
  print(z)
else:
  print("-1")