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

N = int(input())
l = [int(x) for x in input().split()]
if 0 in l:
  print(0)
  sys.exit()
ans = 1
for i in range(N):
  if ans > pow(10, 18):
    ans = -1
    break
  else:
    ans *= l[i]
if ans > pow(10, 18):
  print(-1)
else:
  print(ans)

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


if __name__ == "__main__":
    main()

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

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

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

for i in range(N):
    T*=A[i]
    if T>K:
        print(-1)
        exit()


print(T)

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

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

for i in a:
    s *= i
    if s > INF:
        s = -1
        break

print(s)

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

inf = 10**18
ans = 1

sorted(a, reverse=True)
if 0 in a:
    print(0)
    exit()
else:
    for i in a:
        ans *= i
        if ans > inf:
            print(-1)
            exit()

print(ans)

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

MAX = 10**18
ans = 1

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

print(ans)

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

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

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

if 0 in l:
    print(0)
    exit()
else:
    ans = 1

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

print(ans)

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

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

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

Solution (Python):

from collections import deque


def read(): return input()
def read_int(): return int(input())
def read_array(type=int): return list(map(type, input().split()))
def read_tupple(type=None):
    tmp = input().split()
    if type is None: return map(int, tmp)
    assert len(tmp) == len(type)
    return [type[i](tmp[i]) for i in range(len(tmp))]


N = read_int()
A = read_array()
A.sort()
ans = 1
for i in range(N):
    ans *= A[i]
    if ans > int(1e18):
        print(-1)
        exit()
print(ans)

Solution (Python):

from collections import deque


def read(): return input()
def read_int(): return int(input())
def read_array(type=int): return list(map(type, input().split()))
def read_tupple(type=None):
    tmp = input().split()
    if type is None: return map(int, tmp)
    assert len(tmp) == len(type)
    return [type[i](tmp[i]) for i in range(len(tmp))]


N = read_int()
A = read_array()
A.sort()
ans = 1
for i in range(N):
    ans *= A[i]
    if ans > int(1e18):
        print(-1)
        exit()
print(ans)

Solution (Python):
import sys
import itertools

import time

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = map(int, readline().split())

ans = 1
ng = False
for x in a:
    ans *= x
    if x == 0:
        print(0)
        exit()
    if ans > 10**18:
        ng = True
        ans = 1

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

Solution (Python):
N = input()
A = list(map(int, input().split()))
A.sort()
res = 1
for a in A:
    res *= a
    if res > 10**18:
        print(-1)
        break
else:
    print(res)

Solution (Python):
n=int(input())
ls=[int(s) for s in input().split(" ")]

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

  print(num)

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

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

Solution (Python):
import sys
N = int(input())
A = [int(n) for n in input().split()]
MAX = 10**18
ans = 1
if 0 in A:
    print("0")
    sys.exit()
for a in A:
    if ans > MAX:
        print("-1")
        sys.exit()
    ans *= a
else:
    if ans > MAX:
        print("-1")
    else:
        print(ans)

Solution (Python):
n=int(input())
ls=[int(s) for s in input().split(" ")]

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

  print(num)

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

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

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

if 0 in x:
  print(0)
else:
  res = 1
  ok = False
  for i in x:
    res = res * i
    if res > int(1e18):
      print(-1)
      ok = True
      break
  if not ok :
    print(res)

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

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

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

if a[0] == 0:
    print(0)
else :
    print(pro)

Solution (Python):
from collections import Counter

N = input()
A_str = input().split()

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

c = Counter(sorted(A_str))
res = 1
for i, v in c.items():
    res *= int(i) ** v

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

print(res)

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

a.sort()
tmp = a[0]
f = True
for i in range(1, n):
    tmp *= a[i]

    if tmp > 10 ** 18:
        f = False
        break

if f:
    print(tmp)
else:
    print(-1)

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

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

Solution (Python):
n =int(input())
limit = 10**18
re =1
 
l = list(map(int, input().split()))
 
l.sort()

if(l[0] == 0):
    re = 0
else:
  for i in l:
    re *= i
    
    if(re > limit):
      re = -1
      break
print(re)

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

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

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

if 0 in line:
    a = 0
else:
    a = 1
    for ele in line:
        a *= ele
        if a > 10**18:
            a = -1
            break

print(a)

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

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

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

if 0 in line:
    a = 0
else:
    a = 1
    for ele in line:
        if ele >= 10**18:
            a = -1
            break
        a = a * ele
        if a > 10**18:
            a = -1
            break

print(a)

Solution (Python):
n = int(input())
num_list = list()
string = input().split()
for i in range(n):
	num_list.append(int(string[i]))
del n
del string
num_list = sorted(num_list)
pro = 1
for number in num_list:
	pro *= number
	if pro > 10**18:
		pro = -1
		break
print(pro)

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

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


thre=10**18

if al.count(0)>=1:
    ans=0
else:
    ans=al[0]
    for i in range(1,n):
        ans=ans*al[i]
        if ans >thre:
            ans=-1
            break
print(ans)

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

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

if line.count(0) > 0:
    a = 0
elif line.count(10**18) > 0:
    a = -1
else:
    a = line[0]
    for i in range(len(line)):
        if i == 0:
            pass
        else:
            a = a * line[i]
            if a > 10**18:
                a = -1
                break

print(a)

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

Solution (Python):
def solve():
    n = int(input())
    lst = list(map(int,input().split()))
    if 0 in lst:
        print(0)
        return
    mul = 1
    for ele in lst:
        mul = mul * ele
        if mul > 1e18:
            print(-1)
            return
    
    print(mul)
    
solve()

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

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

prod = 1
for a in A:
    prod *= a
    if prod > 1e18:
        print(-1)
        exit()

print(prod)

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

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

count = 1
if 0 in a:
    print(0)
else:

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

Solution (Python):
n = int(input())
a = [int(x) for x in input().split()]
lim = 10**18
flag = True

ans = a[0]

if a.count(0) >= 1:
    ans = 0
else:
    for i in range(1,n):
        ans *= a[i]
        if ans > lim:
            flag = False
            break
            
if flag:
    print(ans)
else:
    print(-1)

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

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

print(ans)

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

s = 1

A_list.sort()
if A_list[0]==0:
    print("0")
    sys.exit()
for i in range(len(A_list)):
        s = s*A_list[i]
        if s>pow(10,18):
            print("-1")
            sys.exit()

print(s)

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

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

Solution (Python):
N = int(input())
A = input().split()
A = [int(a) for a in A]
p = 1 if (len([n for n in A if n == 0]) == 0) else 0
for i in range(len(A)):
  p *= A[i]
  if p > 1000000000000000000:
    p = -1
    break
print(p)

Solution (Python):



if __name__ == "__main__":
    
    N = int(input())
    INPUT = list(map(int, input().split()))


    if 0 in INPUT:
        output = 0
    else:
        output = 1
        for i in INPUT:
            output = output * i
            
            if output > 10 ** 18:
                output = -1
                break

    print(output)

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


print(ans)

Solution (Python):
def sol():
    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)
    
sol()

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

main()

Solution (Python):

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

def Answer(a):
    if 0 in a:
        return(0)

    ans = 1

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

    return(ans)

print(Answer(a))

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

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

    print(ans)

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

if __name__ == "__main__":
    main()

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 > int(10**18):
			print(-1)
			return
 
	print(prod)
 
main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
result = 1
overflow = False
for i in a:
    result *= i
    if result > 1e18:
        result = 1
        overflow = True
if result != 0 and overflow:
    print(-1)
else:
    print(result)

Solution (Python):
import sys

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

if 0 in a_list:
    print(0)
    sys.exit()
else:
    cul = 1
    for a in a_list:
        cul *= a
        if cul > 10 ** 18:
            print(-1)
            sys.exit()
    print(cul)

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

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

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

	print(prod)

main()

Solution (Python):
import sys

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

if 0 in a:
    print(0)
else:
    cur = 1
    for x in a:
        cur *= x
        if cur > 10 ** 18:
            print(-1)
            sys.exit()
    print(cur)

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

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

Solution (Python):
N=int(input())
total=1
A=list(map(int,input().split()))
flag=True
high=1*(10**18)+1
if A.count(0)>=1:
  total=0
else:
  for i in range(N):
    total*=A[i]
    if high<=total:
      flag=False
      break

if not flag:
  print("-1")
else:
  print(total)

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):
a=int(input())
b=input().split(' ')
m=0
s=1
i=0
o=0
while i<a:
    if int(b[i])==0:
        print(0)
        o=o+1
    i=i+1
while m<a and o==0:
    s=s*int(b[m])
    m=m+1
    if s>10**18 and o==0:
        print(-1)
        o=o+1
        break

if o==0:
    print(s)

Solution (Python):
import sys
n = int(input())
A = [int(i) for i in input().split()]
mx = 10**18
if 0 in A:
    print(0)
    sys.exit(0)
p = 1
for a in A:
    if p * a <= mx:
        p *= a
    else:
        print(-1)
        sys.exit(0)
print(p)

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

if 0 in x :
    print(0)
else :
    ans = 1
    con = True
    for i in range(0, n):
        ans *= x[i]
        if ans > 1000000000000000000:
            print(-1)
            con = False
            break
    if con : print(ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
U = 10 ** 18
p = 1
for x in A:
    p *= x
    if p > U:
        p = U + 1
 
if p > U:
    print(-1)
else:
    print(p)

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

    if 0 in A:
        print(0)
        return

    m = 1
    for x in A:
        m *= x
        if m > 10**18:
            print(-1)
            return
    print(m)
main()

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

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

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

print(ans)

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

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

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

Solution (Python):
n = int(input())
A = map(int, input().split())
INF = 10**18+1
ans = 1
for a in A:
    ans = min(ans*a, INF)
if ans == INF:
    print(-1)
else:
    print(ans)

Solution (Python):
n = int(input())
A = map(int, input().split())
INF = 10**18+1
ans = 1
for a in A:
    ans *= a
    ans = min(ans, INF)
if ans == INF:
    print(-1)
else:
    print(ans)

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

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

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

print(ans)

Solution (Python):
def main():

    MAX = 1e18

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

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

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

    print(prod)


if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, cos, radians, pi, sin
from operator import mul
from functools import reduce
from operator import mul
from decimal import Decimal

mod = 998244353
INF = 10 ** 13
sys.setrecursionlimit(2147483647)
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]

n = I()
A = LI()
ret = 1
flg = 0
for a in A:
    if a == 0:
        print(0)
        exit()
    if flg == 0:
        ret *= a
        if ret > 10 ** 18:
            flg = 1

if flg:
    print(-1)
else:
    print(ret)

Solution (Python):



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

ans = 1

if 0 in a:
  ans = 0

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








print(ans)

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

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

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

def main():
  if 0 in A:
    print(0)
    return
 
  count = 1
  for i in A:
    count *= i
    if count > 1e18:
      print(-1)
      return
 
  print(count)

main()

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

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

def main():
  if 0 in A:
    print(0)
    return
 
  count = 1
  for i in A:
    count *= i
    if count > 1000000000000000000:
      print(-1)
      return
 
  print(count)

main()

Solution (Python):
n = int(input())
arr = [ int(x) for x in input().strip().split(' ') ]
isZ = False
for x in arr:
    if x == 0:
        isZ = True

if isZ:
    print ("0")
    exit(0)

res = 1
for x in arr:
    res *= x
    if res > 1000000000000000000:
        print ("-1")
        exit(0)
print (res)

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

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

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

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

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

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

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())




n = I()
a = LI()
ans = 1
a.sort()
for i in range(n):
    ans *= a[i]
    if ans >= 10**18+1:
        print(-1)
        sys.exit()
    elif ans == 0:
        print(0)
        sys.exit()
print(int(ans))

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

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

Solution (Python):




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

    A.sort(reverse=True)

    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)


if __name__ == "__main__":
    main()

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

Solution (Python):

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

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)
    break
else:
    print(ans)

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

Solution (Python):
def main():
  n = int(input())
  values = list(map(int, input().split()))
  if 0 in values:
    print(0)
    return

  mult = 1
  for i in values:
    mult *= i
    if mult > 1000000000000000000:
      print(-1)
      return
  print(mult)

main()

Solution (Python):
def finish(t):
    print(t)
    exit()

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

if 0 in a:
    finish(0)

mod = pow(10, 18)
s = 1
for i in range(n):
    s *= a[i]
    if s > mod:
        finish(-1)
else:
    finish(s)

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

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

Solution (Python):
import sys

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

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

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

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

Solution (Python):
def main():
    num_1 = input()
    lis = list(map(int,input().split()))
    s = 1
    num_2 = int (num_1)
    num = 10 ** 18
    if 0 in lis:
        print(0)
        return
    for x in range(num_2):
        s = s * int(lis[x])
        if s > num:
            print(-1)
            return
    print(s)
    return

main()

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

print(ans)

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

Solution (Python):
n=int(input())
line=input().split(" ")
f=0

for i in line:
  if int(i)==0:
    print("0")
    f=1

g=1
if f==0:
  for i in line:
    g=g*int(i)
    if g>10**18:
      print("-1")
      f=1
      break
  if f==0:
    print(g)

Solution (Python):

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

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

Solution (Python):
n = int(input())
arr = map(int, input().split())
ans = 1
for i in arr:
  if i == 0:
    ans = 0
    break
  if ans < 10 ** 18:
  	ans *= i
if ans > 10**18:
  ans = -1
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 a:
    ans *= i
    if ans > 1000000000000000000:
      ans = -1
      break
print(ans)

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

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

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

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

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

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

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

INF = 10 ** 18 + 1

ans = 1
for e in a:
    ans *= e
    ans = min(ans, INF)

if ans == INF:
    ans = -1

print(ans)

Solution (Python):


iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = int(input())
    A = list(iim())
    mx = 10**18
    A.sort()

    if  0 in A:
        print(0)
        return

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

    print(ans)

if __name__ == "__main__":
    resolve()

Solution (Python):
import sys

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

def inZero(nums):
  return 0 in nums

def isOverDigits(nums):
  digits = 0

  for i in range(len(nums)):
    digits += len(str(nums[i])) - 1

  if digits > 18:
    return True
  else:
    return False

def calcAns(nums):
  ans = 1
  for i in range(len(nums)):
    ans = ans * nums[i]
    if ans > 10**18 :
      return False
  return ans

if inZero(a_list):
  print(0)
  sys.exit()

ans = calcAns(a_list) 

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