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

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

ans = 1
a_li = [a for a in a_li if a != 1 and a != 0]
a_li.append(1)
for a in a_li:
    ans *= a
    if ans > 1000000000000000000:
        print(-1)
        exit()
print(ans)

Solution (Python):
n=int(input())
l=list(map(int, input().split()))
dap=1
nodap=0
zeroexist=0
for i in range(n):
    zeroexist+=(l[i]==0)
if zeroexist>0:
    print("0")
else:
    for i in range(n):
        dap*=l[i]
        if dap>1000000000000000000:
            nodap+=1
            break
    if nodap==1:
        print("-1")
    else:
        print(dap)

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
sol = 1
nula = 0
over = 0
for i in l:
    if (i == 0):
        nula = 1
    sol = sol * i
    if sol>1000000000000000000:
        over = 1
        sol = 0
if (nula == 1):
    print(0)
elif (over == 1):
    print(-1)
else:
    print(sol)

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

if __name__ == '__main__':
	main()

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

ar=[]
total=1
big=False
lion = False
A=N-1
ar = list(map(int, input().strip().split(' ')))

if 0 in ar:
      print("0")
      big=True
      lion=False
      
while big == False and lion == False:
      for i in range (0,N):
            total=ar[i]*total
            if i == A:
                  lion = True
            if total>(1000000000000000000):
                  big=True
                  lion=True
                  break

if big == False and lion == True:
      print(total)

if big == True and lion == True:
      print("-1")

Solution (Python):
from functools import reduce
n = int(input())
A = list(map(int,input().split()))
b = sorted(A,reverse=True)
c = 1
if b[-1] == 0:
    c = 0
else:
    for i in range(n):
        if c > 10 ** 18:
            break
        c *= b[i]
    

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

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

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A.sort()
if A[0] == 0:
    print(0)
    exit()

ans = 1
check = 10 ** 18

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

print(ans)

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

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):
import numpy as np

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    ans = A[0]
    if 0 in A:
        ans = 0
    else:
        for i in A[1:]:
            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):
  ans *= a[i]
  if ans > 1000000000000000000:
    ans = -1
    break

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

print(ans)

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

arr.sort()
flag=0
pdt=1
for i in range(n):
  pdt=pdt*arr[i]
  if(pdt>1000000000000000000):
    flag=1
    break

if(flag==1):
  print(-1)
else:
  print(pdt)

Solution (Python):
N = int(input())
list = [b for b in input().split()]
a = 1
if "0" in list:
    print(0)
else:
    for l in range(N):
        a = a*int(list[l])
        if a > 10**18:
            print(-1)
            break
    else:
        print(a)

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

val = 1

if 0 in A:
  print('0');
else:
  LIMIT = pow(10, 18)
  for v in A:
    val = val * v
    if val > LIMIT:
      val = -1
      break
  print(val)

Solution (Python):
import sys
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = int(input())
a = inpl()
flag = 0
t = 1
for i in range(0, n):
    if a[i] == 0:
        flag = 1
        print(0)
        break

aaa = 0

if not flag:
    
    for i in range(0, n):
        t *= a[i]
        if t > 1000000000000000000:
            print(-1)
            aaa = 1
            break
    if not aaa:
        print(t)

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

def manipulate(A_i):
    if 0 in A_i:
        return 0
    
    ans = 1
    
    for a in A_i:
        ans *= a
        if ans > 10 ** 18:
            return -1
    
    return ans

print(manipulate(A_i))

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

print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
b=sorted(a,reverse=True)

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

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

if 0 in data:
    print(0)
    exit(

    )
answer = 1

for x in data:
    answer *= x
    if answer > 1e+18:
        answer = -1
        break

print(answer)

Solution (Python):
def main():
    n = input()
    A = [int(i) for i in input().split()]
    if 0 in A:
        print("0")
        return
    ans = 1
    max_num = pow(10, 18)
    for a in A:
        ans *= a
        if ans > max_num:
            print("-1")
            return
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
input_num = int(input())
line = input().split(" ")
over_flg = False
if ("0" in line):
    print("0")
else:
    output = 1
    for i in range(input_num):
        output = output * int(line[i])
        if output > 10 ** 18:
            over_flg = True
            break
    if over_flg:
        print("-1")
    else:
        print(output)

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

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

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

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

print(ans)

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

def mp(a):
    b=[]
    if len(a)==1:
        b.append(a[0]) 
    elif len(a)%2==0:
        for i in range(0,len(a),2):
            b.append(a[i]*a[i+1]) 
    else:
        for i in range(0,len(a)-1,2):

            b.append(a[i]*a[i+1]) 

        b.append(a[len(a)-1]) 
    return b

c=aa.copy()
while len(c)>1:
    c=mp(c)   

    
if c[0]<=10**18:
    print(c[0])
else:
    print(-1)

Solution (Python):
MAX = 10 ** 18

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

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

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

Solution (Python):
N = int(input())
liste = input().split()
number = [int(x) for x in liste]
total = 1
i = 0
if 0 in number:
    total = 0
else:
    while i < N:
            total *= number[i]
            i = i + 1
            if total > 10**18:
                total = -1
                break
print(total)

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

Solution (Python):
def two(a):
    if 0 in a:
        return 0
    res = 1
    for el in a:
        res *= el
        if res > 1e18:
            return -1
    return res
n = int(input())
a = list(map(int, input().split()))
print(two(a))

Solution (Python):
input()
total = 1
A = sorted(map(int, input().split()))
if not A[0]:
    print(0)
    quit()
for n in A:
    if total * n > 10 ** 18:
        print(-1)
        break
    total *= n
else:
    print(total)

Solution (Python):
n=int(input())
lst=list(map(int,input().split()))
lst.sort()
mul=1
flg=0
for i in lst:
    mul=mul*i
    if mul>1e18:
        flg=1
        print(-1)
        break
if flg==0:
    print(mul)

Solution (Python):



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





ans = 1

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


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

if ans > int(1e18):
    print(-1)
else:
    print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
n0 = A.count(0)
n1 = A.count(1)
import math
ans = 1
if N-n0-n1>60:
  ans = -1
for i in range(N):
  if A[i] == 0 or ans == 0:
    ans = 0
    break
  elif ans <0:
    ans = -1
  elif math.log10(A[i])+math.log10(ans)>18:
    ans = -1
    b = 1
  else:
    ans *= A[i]

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

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

aaa = list(map(int, input().split()))
ans = 1

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


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


print(ans)

Solution (Python):
def total_power(n, a):
    half_total = []
    start = 0
    end = len(a)
    if n%2 == 0:
        start = 0
    else:
        start = 1 
        half_total.append(a[0])

    for i in range(start, end, 2):
        half_total.append(a[i]*a[i+1])
    if len(half_total) == 1:
        return half_total[0]
    else:
        return total_power(len(half_total), half_total)


n = int(input())

a_str = input()
a_strs = a_str.split(' ')
a = [int(s) for s in a_strs]
total = total_power(n, a)

if total <= 1e+18:
    print (total)
else:
    print('-1')

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007



def main():
	a = int(input())
	
	
	al = lin()
	if min(al) == 0:
		return 0
	ret = 1
	for v in al:
		ret *= v
		if ret > 10**18:
			return -1
	return ret
		
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
def main():    
    t =  int(input())
    n = 1
    a = list(map(int,input().strip().split()))[:t]
    for i in range(t):
        if a[i]==0:
            return 0
    for i in range(t):
        n*=a[i]
        if n>1e18:
            return -1
    if n>1e18:
        return -1
    else:
        return n
        
if __name__ == '__main__':
    print(main())

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

ans=1

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

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

print(ans)

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

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

ans=1

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

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


print(ans)

Solution (Python):
s = [input() for i in range(2)] 
li = list(map(int, s[1].split()))
s0 = int(s[0])
f1 = 1
if 0 in li:
    print(0)
if 0 not in li:
    for i in range(s0):
        f1 = f1 * li[i]
        if f1 > 1000000000000000000:
            print(-1)
            break
    if f1 <= 1000000000000000000:
        print(f1)

Solution (Python):

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

MAX_A= 10**18
aa = 1

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

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

n = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans = ans * A[i]
    if ans > 10**18:
        for j in range(i+1,n):
            if A[j] == 0:
                print(0)
                exit()
        print(-1)
        exit()
print(ans)

Solution (Python):
n = int(input())
ans = 1
lst = list(map(int, input().split()))
flg = 0
if 0 in lst:
    print(0)
else:
    for _ in lst:
        ans *= _
        if ans > 10**18:
            print(-1)
            flg = 1
            break
    if not flg :
        print(ans)

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):
import math
import sys

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


ans = 1
num = 1000000000000000000

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

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

print(ans)

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

q = 1000000000000000000
b = 1
cek = True
zero = a.count(0)
if zero > 0 :
	print("0")
else :
	for i in range(n) :
		b = b*a[i]
		if b > q :
			cek = False
			break
	if cek :
		print(b)
	else :
		print("-1")

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

print(ans)

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

ans=1

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

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


print(ans)

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

Solution (Python):
n = input()
a = sorted(map(int, input().split()), reverse=True)

i = 1
result = a[0]
flag = False
if a[-1] == 0:
    result = 0
else:
    for i in range(len(a)-1):
        result = result * a[i+1]
        if result > 10 ** 18:
            flag = True
            break

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

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

Solution (Python):
n = int(input())
num = list(map(int,input().split()))
ans = 1
limit = 1000000000000000000
if 0 in num:
  print(0)
else:
  for item in num:
    ans *= item
    if ans>limit:
      ans = -1
      break

  print(ans)

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

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




if a.count(0) > 0:
    print(0)
else:
    ret = 1
    for ai in a:
        ret *= ai
        if ret > 10**18:
            print(-1)
            break
    else:
        if ret > 10**18:
            print(-1)
        else:
            print(ret)

Solution (Python):

def hanbun(L):
    N = len(L)
    flag = N % 2
    N = N // 2
    ans = []
    for i in range(N):
        ans.append(L[2 * i] * L[2 * i + 1])
    if flag == 1:
        ans.append(L[-1])
    return(ans)

N = int(input())
A = list(map(int, input().split()))
while len(A) > 1:
    A = hanbun(A)
ans = A[0]
if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A = sorted(A,reverse=True)
B = 1
if 0 in A:
    print(0)
    quit()
else:
    for i in A:
        B *= i
        if B> 10**18:  
            print(-1)
            quit()
print(B)

Solution (Python):
import sys
N = int(input())
data = [int(i) for i in input().split()]
sum = 1

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

for j in data:
    sum *= j
    if sum > 10 ** 18:
        print(-1)
        sys.exit()
        
else:
    print(sum)

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

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

Solution (Python):
N = int(input())
Nums = input().split()

AA = set(Nums)

if '0' in AA:
  print(0)
else:
  A = 1
  for i in range(N):
    A*=int(Nums[i])
    if A > 10**18:
      A = -1
      break
  print(A)

Solution (Python):
N = int(input())
A = input().split()
result = 1
line = pow(10,18)

if "0" in A:
  result = 0
else:
  for i in range(N):
    result *= int(A[i])
    if result > line:
      result = -1
      break

print(result)

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

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

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

print(ans)

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()

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

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

A.sort(reverse=True)
out = 1
if A[-1] == 0:
  out = 0
else:
  for i in A:
    out *= i
    if out > 1e18:
      out = -1
      break
print(out)

Solution (Python):


num = int(input())
arr = list(map(int,input().split(" ")));

maxi = 1000000000000000000

val = 1;
arr.sort()

if arr[0]==0:
        print(0)

else:
        for i in arr:
                val = val*i;
                if val>maxi:
                        val = -1
                        break
        
        
        print(val)

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

result = 1
flag = 0
zero_flag = False
for x in range(N):
  if(i[x]==0):
    zero_flag = True
    result = 0

if(zero_flag==False):
  for x in range(N):
    result *= i[x]
    if(result>pow(10,18)):
      flag = 1
      break

if(flag==1):
  print('-1')
else:
  print(result)

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

ans = int(A[N])

if 0 in A:
    ans = 0
else:
    while N > 0:
        ans = ans * A[N-1]
        N = N-1
        if ans > 10 ** 18:
            N = 0
        else:
            N = N

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

Solution (Python):

a = int(input())
b = list(map(int, input().split()))
c = 1
if 0 in b:
    print(0)
else:
  while c < 10 ** 18 and len(b) != 0:
    c = c * b[0]
    del b[0]
  if c > 10 ** 18:
    print(-1)
  else:
    print(c)

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

print(ans)

Solution (Python):

import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
import numpy as np
from decimal import *
from collections import deque
from math import gcd
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') 
def lcm(a,b):return (a*b) // gcd(a,b) 
def iin(): return int(sys.stdin.readline()) 
def ifn(): return float(sys.stdin.readline()) 
def isn(): return sys.stdin.readline().split() 
def imn(): return map(int, sys.stdin.readline().split()) 
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) 
def fmn(): return map(float, sys.stdin.readline().split()) 
def iln(): return list(map(int, sys.stdin.readline().split())) 
def iln_s(): return sorted(iln()) 
def iln_r(): return sorted(iln(), reverse=True) 
def fln(): return list(map(float, sys.stdin.readline().split())) 
def join(l, s=''): return s.join(l) 
def perm(l, n): return itertools.permutations(l, n) 
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) 
def comb(l, n): return itertools.combinations(l, n) 
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')

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

print(ans)

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

if 0 in numbers:
  print("0")
else:
 result=1
 for n in numbers:
    result *= n
    if result > 10**18:
      result = -1
      break
 print(result)

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

if 0 in A:
    print(0)
else:

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

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

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

result = As[0]
if 0 in As:
    print(0)
else:
    for i in range(n-1):
        result = result*As[i+1]
        if result > 10**18 :
            print(-1)
            break
        else:
            continue
    if result <= 10**18 :
        print(result)

Solution (Python):
import sys

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

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

ans = 1
for i in A :
  ans *= i
  if ans > 1000000000000000000 :
    print("-1")
    sys.exit()

print(ans)

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

ans = 1
c=0

A.sort()

for x in A:
    ans = ans * x
    if ans == 0:
        print(0)
        c=1
        break
    elif ans > 10**(18):
        print(-1)
        c=1
        break

if c==0:
    print(ans)

Solution (Python):
n = int(input())
a = input().split()
b = 0
is_include_zero = False
too_big = False
for i in a:
    if int(i) > 10 ** 18:
        print(-1)
        too_big = True
    if int(i) == 0:
        is_include_zero = True
if too_big:
    pass
elif is_include_zero:
    print(0)
else:
    for i in range(n):
        if b > 10 ** 18:
            break
        if i == 0:
            b = int(a[i])
        else:
            b = b * int(a[i])
    if b > 10 ** 18:
        print(-1)
    else:
        print(int(b))

Solution (Python):



n = int(input())
num_list = list(map(int, input().split()))
sum=1

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

for i in num_list:
    
    if i==0:
        print(0)
        exit()
    i=str(i)
    sum=str(sum)
    
    if len(i)+len(sum)>21:
        print(-1)
        exit()
    i=int(i)
    sum=int(sum)
    sum=sum*i
    if sum>10**18:
        print(-1)
        exit()
print(sum)

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

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

ans = 1
for ni in A:
  ans = ans * ni
  if ans > 1000000000000000000:
    print(-1)
    exit()
    
print(ans)

Solution (Python):
import math
import sys
import functools
import operator

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


ans = 1
INF = 1000000000000000000

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

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

print(ans)

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

ans = 1

A = sorted(A, reverse=True)

if 0 not in A:
    for i in A:
        ans *= i
        if ans > 10 ** 18:
            break
else:
    ans = 0

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

Solution (Python):




n = int(input())
a = [int(s) for s in input().split(" ")]
output = 1

if a.count(0) >= 1:
    output = 0
else:
    number = 1
    for i in a:
        number = number*i
        output = number
        if number > 1000000000000000000:
            output = -1
            break;
        
print(output)

Solution (Python):
N = int(input())
numList = list(map(int, input().split()))
product = 1
toPrint = True
isZero = False
for j in numList:
    if j == 0:
        isZero = True
if not isZero:
    for i in numList:
        product = product * i
        if product > 10**18:
            toPrint = False
            break
if isZero:
    print(0)
else:
    if toPrint:
        print(product)
    else:
        print(-1)

Solution (Python):

import sys
N = int(input())
A = list(map(int, input().split()))
A.sort()
tar = 1
for i in A:
    tar *= i
    if tar > 10 ** 18:
        print('-1')
        sys.exit()

print(tar)

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

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

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

result=1
for i in X:
  result*=i
  if result>10**18:
    result=-1
    break
for i in X:
  if i==0:result=0

print(result)

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

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

Solution (Python):
import math
n = int(input())
m = 10**18
l = [int(x) for x in input().split()]
l.sort();
prod = 1
for i in l:
	prod *= i
	if prod > m:
		prod = -1
		break
	elif prod == 0:
		break
print(prod)

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

ans = A[0]
isOver = False

if 0 in A:
    print(0)
else:
    for i in range(1, N):
        ans *= A[i]
        ans_size = int(math.log10(ans) + 1)
        if ans_size >= 19 and ans - (10**18) >= 1:
            isOver = True
            break

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

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

if A.count(0) > 0:
  print(0)
else:
  ans = 1
  for i in A:
    ans = ans * i
    if ans > 10 ** 18:
      ans = -1
      break
  
  print(ans)

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

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