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

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

j = 1
ans = l[0]
while j < n:
    ans = ans * l[j]
    j += 1
    if ans > 10**18:
        print(-1)
        exit()

print(ans)

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

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

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

Solution (Python):
def solve(n, a):
  if 0 in a:
    return 0
  else:
    p = 1
    x = 10**18
    for i in a:
      if p<=x:
      	p*=i
      else:
        break
    if p>x:
      p = -1
    return p

n = int(input())
a = [int(x) for x in input().split()]
print(solve(n, a))

Solution (Python):
L = 1000000000000000000
r = 1
n = input()
A = list(map(int, input().split()))
A = sorted(A)
if A[0] == 0:
    print(0)
else:
    p = True
    while len(A) > 0:
        b = A.pop()
        r *= b
        if r > L:
            print(-1)
            p = False
            break
    if p: print(r)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort()
res=1
z=10**18
for i in a:
    if(i==0):
        res=0
        break
i=n-1
while(i>=0):
    if(a[i]==0):
        res=0
        break
    if(res>z/a[i]):
        res=z+1
        break
    res*=a[i]
    if(a[i]>z):
        break
    i-=1
if(res>z):
    res=-1
print(res)

Solution (Python):
def main ():
  N = int(input())
  A = list(map(int,input().split()))
  prod = 1 
  A.sort()
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  
  print(prod) 
 
main()

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

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

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

print(ans)

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

if __name__ == "__main__":
    main()

Solution (Python):
def q_b():
    k = int(input())
    a = map(int, input().split())
    a = list(a)

    is_finished = False
    for i in a:
        if i == 0:
            print(0)
            is_finished = True
            break

    if is_finished:
        return

    answer = 1
    for i in a:
        answer *= i
        if answer > 10 ** 18:
            print(-1)
            is_finished = True
            break

    if is_finished is False:
        print(answer)


if __name__ == '__main__':
    q_b()

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n = iinput()
a = iarr()

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())
i=list(map(int,input().split()))
s=1
i=sorted(i,reverse=True)
for a in i:
    s=s*a
    if s>10**18:
        s=-1
        break
if i[-1]==0:
    print("0")
else:
    print(s)

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

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

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

print(ans)

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)


main()

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

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

a = list(int(i) for i in input().split(" "))

prod = 1

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


print(prod)

Solution (Python):
import sys

n= int(input())
a = list(map(int,input().split()))
a.sort()
ans_max = 10 ** 18

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

print(ans)

Solution (Python):
import sys

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

zero_search = 0 in a_list
ans = 1

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

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

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

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

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

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ans = 1
if 0 in a:
    print(0)
    exit()
for x in a:
    ans *= x
    if ans >1e18:
        print(-1)
        exit()
print(ans)

Solution (Python):
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    ans = solve(n, a)
    print(ans)

def solve(n, a):
    if 0 in a:
        return 0
    lim = 10 ** 18
    ans = 1
    for i in a:
        ans *= i
        
        if ans > lim:
            return -1
    return ans

if __name__ == '__main__':
    main()

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

a = sorted(a)

ans = 1

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

print(ans)

Solution (Python):
n = input()
s = 1

int_list = [int(s) for s in input().split()]
if 0 in int_list:
  print(0)
else:
  for i in int_list:
    s = s * int(i)
    if s > 1e+18:
      s = -1
      break
  print(s)

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

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

print(ans)

Solution (Python):
import math

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

flag = True
if 0 in A:
    prod = 0
else:
    prod = 1
    for i in range(N):
        prod *= A[i]
        if prod > 10**18:
            flag = False
            break

if flag == True:
    print(prod)
else:
    print(-1)

Solution (Python):



def main():
    import sys
    input = sys.stdin.readline

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

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

    for ai in a:
        ans *= ai

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

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys

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

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

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

num.sort()

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

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

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

Solution (Python):
def calc(num_list) -> int:
    result = 1
    max = 10**18

    if 0 in num_list:
        return 0

    for num in num_list:
        result *= num
        if result > max:
            return -1
    return result

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

print(str(calc(num_list)))

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

ans = 1
ng = False
max = 10**18
for A in Aj:
	if A == 0:
		ans = 0
		break
	if ng or ans*A > max:
		ans = -1
		ng = True
	else:
		ans *= A
print(ans)

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

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

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

print(sum_l)

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

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

else:
    for i in range(1, N):
        ans = ans * A[i]
        if ans > 1E+18:
            ans = -1
            break
        else:
            continue
    print(ans)

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

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

def multiplication2(n,a):
    
    acc = 1
    a_sorted = sorted(a)
    if a_sorted[0] == 0:
        return 0
    
    for s in a_sorted:

        acc = acc*s
        if 10**18 < acc:
            acc = -1
            break
    return acc

if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    print(multiplication2(n,a))

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

Solution (Python):
import sys
input_num = input()
input_list = input()
 
total_pow = 1
for num in input_list.split(" "):
    total_pow *= int(num)
    if total_pow > 10**18:
        if "0" in input_list.split(" "):
            print("0")
        else:
            print("-1")
        sys.exit()

print(total_pow)

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

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

Solution (Python):
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]

def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]

def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)

MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

N = I()
A = LI()
ans = 1
if 0 in A:
    print(0)
else:
    for i in A:
        ans *= i
        if ans>10**18:
            print(-1)
            break
    else:
        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 = ans * a[i]
    if ans > 10**18:
        print(-1)
        exit()

print(ans)

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

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

print(result)

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

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

print(result)

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

resolve()

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

A = input().split()

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

print(M)

Solution (Python):
n = int(input())
an = list(map(int, input().split()))
if 0 in an:
  out = 0

else:
  out = 1
  for a in an:
    out = out * a
    if out > 10 ** 18:
      out = -1
      break
print(out)

Solution (Python):
x = int(input())
pro = 1
n = input().split(' ')
li = 10 ** 18
flag = 1
for i in range(x):
    pro = pro * int(n[i])
    if pro > li:
        flag = 0
        break;
if '0' in n:
    flag = 1
    pro = 0
if flag:
    print(pro)
else:
    print(-1)

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
mul=1
key=0
for i in range(len(a)):
    if a[i]==0:
        key=1
        print(0)
        break;
if key==0:
    for i in range(len(a)):
        mul=mul*a[i]
        if mul>1000000000000000000:
            break
    if(mul<1000000000000000001):
        print(mul)
    else:
        print(-1)

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

limit = 10**18
a.sort()
ans = a[0]

if ans == 0:
    print(0)
else:
    for i in a[1:]:
        ans *= i
        if ans > limit:
            print(-1)
            exit()
    print(ans)

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

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

Solution (Python):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)
 
def input():
    return sys.stdin.readline().strip()
 

def get_nums_l():
    return [ int(s) for s in input().split(" ")]
 

def get_nums_n(n):
    return [ int(input()) for _ in range(n)]
 

def get_all_int():
    return map(int, open(0).read().split())
 
def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break
 
def log(*args):
    print("DEBUG:", *args, file=sys.stderr)
 
INF = 999999999999999999999999
MOD = 10**9+7
 
n,*A = get_all_int()
 
if min(A) == 0:
    print(0)
    exit()
 
ans = 1
for a in A:
    ans *= a
 
    if ans > 10**18:
        print(-1)
        exit()
 
print(ans)

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

ans = 1
if 0 in a:
    ans = 0
    print(ans)
    exit()
else:
    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()))
a.sort(reverse=True)

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

Solution (Python):
import sys
def input():
    return sys.stdin.readline().rstrip('\n')


def calc(N, A):
    result = 1
    A.sort()
    if A[0] == 0:
        return 0
    for i in range(N):
        result *= A[i]
        if result > 10 ** 18:
            return -1
    return result
    

N = int(input())
A = [int(s) for s in input().split()]
print(calc(N, A))

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

ans = 1
can = 1
zero = 0

if 0 in a:
    zero = 1
    ans = 0

if(zero==0):
    for i in range(N):
        ans = ans * a[i]
        if(ans>1000000000000000000):
            can = 0
            break

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
ans = 1
lim = int(1e+18)
if a.count(0):
    print(0)
    exit()
for i in range(n):
    ans *= a[i]
    if lim < ans:
        print(-1)
        exit()
print(ans)

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

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

Solution (Python):

n = int(input())
v = list(map(int, input().split(' ')))

ans = 1

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

for item in v:
	ans = ans * item
	if ans > 1000000000000000000:
		print(-1)
		exit(0)
print(ans)

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

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

ans = 1

a.sort(reverse=True)

if 0 not in a:
    for x in range(n):
        ans *= a[x]

        if ans > 10**18:
            ans = -1
            break
else:
    ans = 0

print(ans)

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

Solution (Python):
from functools import reduce

n = int(input())

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

sim = False
if 0 in numeros:
    print(0)

else:

    multiplicacao = 1

    for i in numeros:
        multiplicacao *= i
        if multiplicacao > 1e18:
            print(-1)
            sim = True
            break
    if sim == False:
        print(multiplicacao)

Solution (Python):
import sys
N = int(input())
s = list(map(int, input().split()))
if 0 in s:
    print(0)
    sys.exit()
result = 1
for value in s:
    result *= value
    if result > pow (10,18):
        print(-1)
        sys.exit()
print(result)

Solution (Python):
def main ():
	n = int(input())
	a = list(map(int,input(). split ()))
    
	if 0 in a:
		print(0)
		return
	prod = 1
	for i in a:
		prod *= i
		if prod > 1000000000000000000:
			print(-1)
			return
	print(prod)
main ()

Solution (Python):
import sys

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

for i in A:
    if i == 0:
        print(0)
        sys.exit(0)

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

print(ans)

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

Solution (Python):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    if 0 in a:
        print(0)
        return
    prod = 1
    for i in a:
        prod *= i
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
main()

Solution (Python):
import sys
import math


input = sys.stdin.readline
 

def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))



n=inp()
ara=inara()
for num in ara:
	if num==0:
		print(0)
		exit(0)

ans=1
for num in ara:
	ans*=num
	if ans>1000000000000000000:
		print(-1)
		exit(0)

print(ans)

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

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

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

Solution (Python):
n = int(input())
li = list(map(int,input().split()))
a = 1
if 0 in li:
    print(0)
else:
    li = sorted(li, reverse=True)
    for i in li:
        if a >= 10**18+1:
            break
        else:
            a *= i
    if a >= 10**18 + 1:
        print('-1')
    else:
        print(a)

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

print(ans)

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

Solution (Python):
N = int(input())
list_num = [int(_) for _ in input().split(" ")]

product = 1

if 0 in list_num:
    print(0)
else:
    checker = True
    for i, num in enumerate(list_num):
        product *= num
        if product > 10**18:
            checker = False
            break
        
    if checker:
        print(product)
    else:
        print(-1)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
for aa in a:
  if aa==0:
    print(0)
    exit(0)

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

Solution (Python):
n = int(input())
num = list(map(int, input().split()))
limit = 10**18
 
num.sort()
result = num[0]

if result == 0:
    print(0)
else:
    for i in num[1:]:
        result *= i
        if result > limit:
            print(-1)
            exit()

    print(result)

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()
if ans > 1e18:
    print(-1)
else:
    print(ans)

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

limit = 10 ** 18
A.sort()
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)

Solution (Python):
N = int(input())
S = [int(s) for s in input().split()]
if 0 in S:
  l = 0
else:
  l = 1
  for s in S:
    l = l * s
    if l > 10**18:
      l = -1
      break
print(l)

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

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

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

    if 0 in A:
        print(0)
        return
    A1 = A[::2]
    A2 = A[1::2]

    if N%2 ==1:
        ans *= A1[-1]
    for i,j in zip(A1,A2):
        ans *= i*j
        if ans >10**18:
            return print(-1)

    return print(ans)


if __name__ == '__main__':
    solve()

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

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

ans = 1
for a in A:
  if ans > 10**(18)//a:
    ans = -1
    break
  else:
    ans *= a

if 0 in A:
  print(0)
else:
  print(ans)

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

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

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

ans = A[0]

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

print(ans)

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

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

A = sorted(A)

if A[0] == 0:
    print("0")
else:
    ans = 1
    for item in A:
        ans = ans*item
        if ans > 10**18:
            print("-1")
            exit()

    print(ans)

Solution (Python):
a = int(input())
ar = list(map(int,input().split(" ")))
if 0 in ar:
    print(0)
    exit()
b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        exit()
print(b)

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

Solution (Python):
def main():
    n=int(input())
    aa=map(int,input().split())
    x=1
    for a in aa:
        if a == 0:
            print(0)
            return
        if x<1000000000000000000:
            x*=a
    if x>1000000000000000000:
        print(-1)
    else:
        print(x)
main()

Solution (Python):
a = int(input())
ar = list(map(int,input().split(" ")))
if 0 in ar:
    print(0)
    exit()
b = 1
for r in ar:
    b *= r
    if b > 10 ** 18:
        print(-1)
        exit()
print(b)

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

A.sort(reverse=True)

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

r = 1
upper = pow(10, 18)
for i in range(N):
    r *= A[i]

    if r > upper:
        print(-1)
        exit()

print(r)

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

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

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

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

Solution (Python):
import math
import sys
N = input()
i = list(map(int, input().split()))
result = 1
if 0 in i:
  print(0)
  sys.exit()
for x in i:
  result *= x

  if(result > 10**18):
    print(-1)
    sys.exit()
print(result)

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

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

Solution (Python):
import math
import sys
N = input()
i = list(map(int, input().split()))
result = 1
if 0 in i:
  print(0)
else:
  for x in i:
    result *= x
    if(result >= 10**18):
      break
  if(result > 10**18):
    print(-1)
  else:
    print(result)

Solution (Python):
from sys import stdin
from functools import reduce 


inputs = [list(map(int, input().split())) for _ in range(2)]
inputs = inputs[1]

if (0 in inputs):
  output = 0
else:
  output = reduce((lambda x, y: -1 if (x * y) > 1e18 or x < 0 or y < 0  else (x * y)), inputs)

print(output)