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())
s=input().split()
result=1
if '0' in s:
  print(0)
else:
  for i in range (N):
    result=result*int(s[i])
    if result> 10**18:
      print(-1)
      break
    elif i==N-1 and result<=10**18:
      print(result)

Solution (Python):
def getN():
    return int(input())


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


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


from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
from heapq import *
import sys


INF = 10 ** 17
MOD = 1000000007

from fractions import *


def inverse(f):
    
    return 1 / f


def combmod(n, k, mod=MOD):
    ret = 1
    for i in range(n - k + 1, n + 1):
        ret *= i
        ret %= mod

    for i in range(1, k + 1):
        ret *= pow(i, mod - 2, mod)
        ret %= mod

    return ret


def bunsu(n):
    ret = []
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            tmp = 0
            while (True):
                if n % i == 0:
                    tmp += 1
                    n //= i
                else:
                    break
            ret.append((i, tmp))

    ret.append((n, 1))
    return ret

MOD = 998244353
def solve():
    n = getN()
    nums = getList()

    if 0 in nums:
        print(0)
        return
    ans = 1
    for num in nums:
        ans *= num
        if ans > 10 ** 18:
            print(-1)
            return

    print(ans)
def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    solve()

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

if 0 in A :
    ans = 0

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

print(ans)

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

if 0 in A :
    ans = 0

for x in range(N) :
    ans *= A[x]
    if ans > 10E+17 :
        ans = -1
        break

print(ans)

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

if 0 in A :
    ans = 0

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

print(ans)

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

if 0 in A:
    ans = 0
    N = 0

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

print(ans)

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

if 0 in A:
  ans = 0
  N = 0

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

print(ans)

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

if 0 in A:
  ans = 0
  N = 0

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

print(ans)

Solution (Python):
N = int(input())
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):
k=input()
a=list(map(int,input().split()))
p=1
count=0
if(len(a)==0):
    print("0")
elif 0 in a:
    print("0")
else:
    while(count<len(a)):
        p*=a[count]
        count+=1
        if(p>pow(10,18)):
            print("-1")
            break
    if(p<=pow(10,18)and len(a)>0):
        print(p)

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

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

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

a = 1

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

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

Solution (Python):
N = int(input())
A_list = list(map(int, input().split()))
limit = 10**18
sum = 1

if 0 in A_list:
    print(0)
else:
    for i in  A_list:
        sum = sum * i
        if sum > limit:
            sum = -1
            break
    print(sum)

Solution (Python):
from functools import reduce

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

MAX  = 10 ** 18

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

result = 1
  
for x in xs:
  result *= x
  
  if result > MAX:
    print(-1)
    exit(0)
    
print(result)

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

ans = 1
if a[0] == 0:
    ans = 0
else:
    for ai in a:
        ans *= ai
        if ans > 10**18:
            ans = -1
            break

print(ans)

Solution (Python):


n = int(input())
a = list(map(int, input().split()))
limit = 10 ** 18
for i in range(1, n):
    a[i] = min(a[i] * a[i - 1], limit + 1)

print(a[-1] if a[-1] <= limit else -1)

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
limit = 1000000000000000000
ans = 1
for i in range(N):
    if A[i] == 0:
        ans = 0

flag = False
for i in range(N):
    ans *= A[i]  
    if ans > limit:
        flag = True
        break
print(-1) if flag else print(ans)

Solution (Python):
n = int(input())
a = sorted(map(int, input().split()))
p = 1
for i in a:
    p *= i
    if p > 1e18:
        p = -1
        break
print(p)

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

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

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

Solution (Python):
n = int(input())
lst = list(map(int, input().split()))
zero = False
fl = False
x = 1
for i in lst:
    if(i==0):
        zero = True
        break
    if not fl:
        x*=i
    if(x>1e18):
        fl = True
if zero:
    print(0)
elif fl:
    print(-1)
else:
    print(x)

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


main()

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

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

Solution (Python):
def multiply(num_list):
  
  if 0 in num_list:
    return 0
  
  
  MAX = pow(10,18)
  res = 1
  for i in num_list:
    res *= i
    if res > MAX:
      return -1
  return res

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

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

count = 1

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

Solution (Python):
def multiply(num_list):
  
  if 0 in set(num_list):
    return 0
  
  
  MAX = pow(10,18)
  res = 1
  for i in num_list:
    res *= i
    if res == 0:
      return 0
    if res > MAX:
      return -1
  return res

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

Solution (Python):
def multiply(num_list):
  
  if 0 in num_list:
    return 0
  
  
  MAX = pow(10,18)
  res = 1
  for i in num_list:
    res *= i
    if res == 0:
      return 0
    if res > MAX:
      return -1
  return res

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

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

Solution (Python):
import sys
n = int(input())
an = list(map(int, input().split()))
condition = an.count(0)
if condition > 0:
    print(0)
    sys.exit()
a0 = an[0]
for i in range(len(an) - 1):
    a0 = a0 * an[i+1]
    if a0 > 10 ** 18:
        a0 = -1
        break
print(a0)

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

answer=1
for a in alist:
  answer*=a
  if answer==0:
    print(0)
    break
  elif answer>10**18:
    print(-1)
    break
else:
  print(answer)

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

Solution (Python):
import numpy as np
n=int(input())
ans=1
a=input().split()

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

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

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

total = 1
for j in a:
    total = total*j
    
    if total>10**18:
        print(-1)
        sys.exit()

print(total)

Solution (Python):
import numpy as np
import sys



def xnxn(n=0):
    """
    args:
        int n: a number of lows to read
    example:
        input   1
        retrun  1

        input   1 2 3
        return  [1,2,3]
        input   1 2 3
                4 
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        temp = list(map(int, input().split()))
        if len(temp) == 1:
            return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        temp = [list(map(int, input().split())) for _ in range(n)]
        return temp


def sp_xnxn(n=0):
    """
    args:
        int n: a number of lows to read
    example
        input   1
        retrun  [1]

        input   123
        return  [1,2,3]

        input   123
                4 
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        return [int(k) for k in xsxs()]
    else:
        return [[int(k) for k in xsxs()] for _ in range(n)]


def xsxs(n=0):
    """
    args:
        int n: a number of lows to read 
    example:
        input   AA
        retrun  AA

        input   A BBB CC
        return  ["A","BBB","CC"]

        input   A BB CCC
                D
        return  [["A","BBB","CC"],
                ["D"]]
    """
    if n == 0:
        temp = list(input().split())
        if len(temp) == 1:
            return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        return [list(input().split()) for _ in range(n)]


def sp_xsxs(n=0):
    """
    args:
        int n: a number of lows to read 
        example:
            input   A
            retrun  ["A"]

            input   ABC
            return  ["A","B","C"]

            input   ABC
                    D
            return  [["A","B","C"],
                    ["D"]]
    """
    if n == 0:
        return [s for s in xsxs()]
    else:
        return [[s for s in xsxs()] for _ in range(n)]


n = xnxn()
a = xnxn()

temp = 1

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

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

print(temp)

Solution (Python):
def main():
    n = int(input())
    sub = 1
    a_ls = list(map(int, input().split()))
    for i in range(n):
        if a_ls[i] == 0:
            print(0)
            return
    for i in range(n):
        sub*=a_ls[i]
        if 10**18 < sub:
            print(-1)
            return
    print(sub)
if __name__ == '__main__':
    main()

Solution (Python):
import math

def dict_sort(ans):
    ans=sorted(ans.items(),reverse=True,key=lambda kv:(kv[1]))
flag=[0]*1000002
def seive_primes():
    flag[0]=flag[1]=1
    i=2
    while i*i<=1000000:
        if flag[i]==0:
            j=i*i
            while j<=1000000:
                flag[j]=1
                j+=i
        i+=1
def sqr(n):
    return n*n
def inp():
    ls=list(map(int,input().split()))
    return ls
N=int(input())
ls=inp()
if 0 in ls:
    print(0)
    exit(0)
ans=1
for i in ls:
    ans*=i
    if ans>1000000000000000000:
        print(-1)
        exit(0)
print(ans)

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

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

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

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

Solution (Python):
n = int(input())
argList =list(map(int, input().split())) 
ret = 1
if 0 in argList:
    ret = 0
else:

    for i in argList:
        ret = ret*i
        if ret > 10**18 :
            ret = -1
            break
print(ret)

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

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

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

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

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

if 0 in a:
    print("0")
else:
    while i < n:
        p *= a[i]
        if p > 10**18:
            break
        i += 1
    if p <= 10**18:
        print(p)
    else:
        print("-1")

Solution (Python):
N = int(input())
num = sorted(list(map(int, input().split())), reverse=True)
prod = 1
if num[-1] == 0:
  prod = 0
for i in range(N):
  prod *= num[i]
  if prod > 10 ** 18:
    prod = -1
    break
print(prod)

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

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

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

now = 1

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

print(now)

Solution (Python):
num = input()
a = input().split()

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

print(b)

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

print(ans)

Solution (Python):
import sys
def v():
    N=int(sys.stdin.readline())
    A=list(map(int,sys.stdin.readline().split()))
    if A.count(0)>0:return 0
    else:
        A=list(filter(lambda x:x>1,A))
        x=1
        for a in A:
            x*=a
            if x>10**18:
                x=-1
                break
        return x
def main():print(v())
if __name__=='__main__':main()

Solution (Python):
N = int(input())
vals = [int(v) for v in input().split()]

rslt = 1

if 0 in vals:
  rslt = 0

for v in vals:
  rslt = rslt * v
  
  if rslt > 10 ** 18:
    rslt = -1
    break

print(rslt)

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

b = 1

a = sorted(list(map(int, input().split())), reverse=True)
if a[-1] == 0:
    print("0")
    sys.exit()
for i in a:
    b *= i
    if b > pow(10, 18):
        print("-1")
        sys.exit()
print(b)

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

Solution (Python):


N = int(input())
A_list = list(map(int, input().split()))
A_list.sort()
if A_list[0] == 0:
    print(0)
else:
    ans = 1

    for a in A_list:
        ans *= a

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

    print(ans)

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

Solution (Python):
from statistics import median


from fractions import gcd
from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
if A.count(0):
    print(0)
    exit()
A = sorted(A)
ans = 1
for i in range(n):
    if ans * A[i] > 10**18:
        print(-1)
        exit()
    ans *= A[i]
print(ans)

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

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

Solution (Python):
from math import *
n = int(input())
a = [int(x) for x in input().split()]
ans = 1
ok = False
fail = False
for x in a:
  if (x == 0):
    ok = True
    break
for x in a:
  if (ans * x > 1000000000000000000):
    fail = True
    break
  ans *= x
if (ok):
  print(0)
else:
  if (fail):
    print("-1")
  else:
    print(ans)

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
if 0 in A:
	print(0)
	exit()

ans = 1

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

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

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

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

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

now = 1

for Ai in A:
    if now*Ai>10**18:
        print(-1)
        exit()
    
    now *= Ai

print(now)

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

t = 1

for i in A:
    t *= i

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

print(t)

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

if 0 in A:
    print(0)
else:
    ans = 1
    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()))

if min(a) == 0:
    print(0)
    exit()

ans = 1
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()))
A.sort()

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

Solution (Python):
totalNumbers = int(input())
array = list(map(int, input().split()))
answer = 1
if 0 in array:
    print(0)
else:
    for number in array:
        answer*=number
        if answer>10**18:
            answer=-1
            break
    print(answer)

Solution (Python):
def main():
  
  

  
  

  
  
  
  if 'get_ipython' in globals(): 
    
    n = 2
    A = [1000000000, 1000000000]

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

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

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

Solution (Python):


def solve():
    N = int(input())
    As = list(map(int, input().split()))
    MAX = 10**18

    if 0 in As:
        print(0)
        return

    ans = 1
    for a in As:
        ans *= a
        if ans > MAX:
            print(-1)
            return
    print(ans)


if __name__ == "__main__":
    solve()

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

Solution (Python):
import math
import sys
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    aList = list(map(int, readline().rstrip().split()))
    ans = 1

    if 0 in aList:
        print(0)
        return

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


if __name__ == '__main__':
    main()

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

ans = 1
for a in As:
    ans *= a
    ans = min(ans, 10**18+1)

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

print(ans)

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

ans = 1
flag = True
flag_zero = False
for a in A:
    ans *= a
    if ans > 10 ** 18:
        flag = False
        break
    if a == 0:
        flag_zero = True
        break

if flag:
    if not flag_zero:
        print(ans)
    else:
        print(0)
else:
    print(-1)

Solution (Python):

import sys


def solve(N: int, A: "List[int]"):
    if(0 in A):
        print(0)
        sys.exit()

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

    print(sum_l)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)

if __name__ == '__main__':
    main()

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

ans = 1

if 0 in a:
  ans = 0
else:
  for num in a:
    ans *= num
    if ans > 1000000000000000000:
      ans = -1
      break

print(ans)

Solution (Python):

a=int(input())

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


sum=1


if 0 in li:
    sum = 0
else:
    for i in range(a):
        sum = sum*li[i]
        if sum > 10**18:
            break

if sum <= 10**18:
    print(sum)
else:
    print(-1)

Solution (Python):
n = int(input())
l = [int(item) for item in input().split()]
l.sort()
product = 1
flag=0
for i in l:
	product *= i
	if product > int(10**18):
		print("-1")
		flag=1
		break
 
if flag == 0:
	print(product)

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

Solution (Python):
n = int(input())
l = [int(item) for item in input().split()]
l.sort()
product = 1
flag=0
for i in l:
	product *= i
	if product > int(10**18):
		print("-1")
		flag=1
		break

if flag == 0:
	print(product)

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

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())
  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)
      return
  print(ans)

main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = 1
if a.count(0) > 0:
    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()))
A.sort()
if A[0]==0:
    print(0)
    exit()

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

print(ans)

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

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

print(result)

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

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

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

lim = 10 ** 18
ans = 1

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

print(ans)

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

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

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

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

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

res = 1

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

print(res)

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):
N = int(input())
A = list(map(int, input().split()))
ans = 1

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

Solution (Python):
N = int(input())
m = 1
for n in input().split():
  i = int(n)
  m = m * i
  if m > 10 ** 18 or m < 0:
    m = -1
print(m)

Solution (Python):
def main():
    lim = 1e18
    n = int(input())
    nums = list(map(int,str(input()).split(" ")))
    if 0 in nums:
        print(0)
        return
    ans = 1
    for num in nums:
        ans *= num
        if ans > lim:
            print(-1)
            return
    print(ans)
    return

main()

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())
l=list(map(int,input().split()))
a=l[0]
for i in range(1,n):
    a*=l[i]
    if a>10**18:
        break
if a>10**18 and l.count(0)==0:
    print(-1)
elif l.count(0)>0:
    print(0)
else:
    print(a)

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

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

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

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

print(str(ans))

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

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

print(str(ans))

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

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

ans = 1

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

Solution (Python):
import sys

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

for i in A:
    count *= i

    if i == 0:
        print(0)
        sys.exit()
    elif count > 10 ** 18:
        print(-1)
        sys.exit()
    else:
        pass

print(count)