Problem:
 Score : 200 points    Problem Statement Given N integers A_1, ..., A_N , compute A_1 \times ... \times A_N .  However, if the result exceeds 10^{18} , print -1 instead.      Constraints  2 \leq N \leq 10^5  0 \leq A_i \leq 10^{18}  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  A_1  ...  A_N       Output Print the value A_1 \times ... \times A_N as an integer, or -1 if the value exceeds 10^{18} .        Sample Input 1 2
1000000000 1000000000      Sample Output 1 1000000000000000000  We have 1000000000 \times 1000000000 = 1000000000000000000 .       Sample Input 2 3
101 9901 999999000001      Sample Output 2 -1  We have 101 \times 9901 \times 999999000001 = 1000000000000000001 , which exceeds 10^{18} , so we should print -1 instead.       Sample Input 3 31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0      Sample Output 3 0

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

p = 1

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

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

print(p)

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

Solution (Python):
num = int(input())
nums = input().split()

zero_flag = False
for item in nums:
  if item == '0':
    zero_flag = True
    break
    
if zero_flag:
  seki = 0
else:
  seki = 1
  for item in nums:
    seki *= int(item)
    if seki > 10**18:
      seki = -1
      break

print(seki)

Solution (Python):

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

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

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




def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))



def main():
	n=II()
	A=LI()
	A.sort()

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

	print(ans)








if __name__ == "__main__":
	main()

Solution (Python):






def print_hi(name):
    
    print(f'Hi, {name}')  



if __name__ == '__main__':
    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):
N = int(input())
A = list(map(int,input().split()))
S = 1
if 0 in A:
    print("0")
    exit()
    
for i in range(N):
    S *= A[i]
    if S > 1000000000000000000:
        print("-1")
        exit()

print(S)

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

print(str(ans))

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

if 0 in A:
  iszero = True
for i in range(N):
  if(iszero):
    ans = 0
    break
  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
threshold = 10 ** 18
if 0 in a:
    ans = 0
for i in range(n):
    ans *= a[i]
    if threshold < ans:
        ans = -1
        break

print(ans)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
if 0 in set(a):
    print(0)
    quit()
res = 1
for x in a:
    res *= x
    if res > 10**18:
        print(-1)
        quit()
print(res)

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

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


ans=1
for i in A:
    ans*=i
    if ans>10**18:
        ans=-1
        break
if 0 in S:
    ans=0


print(ans)

Solution (Python):
N = int(input())
A  = list(map(int, input().split()))
X = 10**18
ans = 1
if 0 in A:
  ans = 0
else:
  for i in range(N):
    ans = ans * A[i]
    if ans > X:
      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 a in A:
        prod *= a
        
        if prod > 10**18:
            print(-1)
            return
        
    print(prod)

main()

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re
import math















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


from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n = I()
A = sorted(readInts())
th = 10**18
if A[0] == 0:
    print(0)
else:
    ans = 1
    for i in range(n-1,-1,-1):
        ans *= A[i]
        if ans > th:
            print('-1')
            exit()
    print(ans)

Solution (Python):
n, *a = map(int, open(0).read().split())
a.sort()
if a[0] == 0:
    print(0)
    exit()
b = 1
for c in a:
    b *= c
    if b > 10 ** 18:
        print(-1)
        exit()

print(b)

Solution (Python):

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


N = int(input())
A = Li()

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

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

Solution (Python):
n = int(input())
A = sorted(list(map(int, input().split())))[::-1]
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 = 1
s = list(map(int, input().split()))
if 0 in s:
    print(0)
    exit()
for i in s:
    a*=i
    if a>10**18:
        print(-1)
        exit()
else:
    print(a)

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

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

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

c = 1
j = 0

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

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

    if 0 in A:
        print(0)
        return

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

    print(ans)

main()

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

A.sort()
ans = 1
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 > 10 ** 18:
            ans = -1
            break

print(ans)

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

r = 1
for v in A:
    if v == 0:
        r = 0
        break

    r *= v
    if r > 1000000000000000000:
        r = -1
        break

print(r)

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

Solution (Python):

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

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

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

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

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

Solution (Python):
N=int(input())
d_pre=input().split()
d=[int(s) for s in d_pre]
d.sort()
d_2=d[::-1]
ans=1
if 0 in d_2:
    print(0)
else:
    for i in range(N):
        ans*=d_2[i]
        if ans>10**18:
            print(-1)
            break
        elif i==N-1:
            print(ans)

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

a.sort(reverse=True)

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

    if 0 in A:
        print(0)
        return

    for a in A:
        SUM = SUM * a
        if SUM > 1000000000000000000:
            print(-1)
            return

    print(SUM)
main()

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

    if An[i] == 0:
        break

print(ans)

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

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

if 0 in A:
    print("0")
    f = 1
else:

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

if f == 0:
    print(ans)

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

Solution (Python):
n = int(input())
lst = list(map(int,input().split()))
lst = sorted(lst)
ans = 1
for i in range (n):
  ans = ans*lst[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

else:
  for i in range(0,N):
    Ans *= A[i]
    if Ans > 1000000000000000000:
      Ans = -1
      break
    
print(Ans)

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

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

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

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

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

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

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

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

print(ans)

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

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

flag = 0
ans = 1

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

for i in range(N):
    if flag == 1:
        break
    ans = ans * A[i]
    if ans > 1000000000000000000 :
        print('-1')
        flag = 1
        break
if flag == 0:
    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 range(0, N):
  ans *= A[i]
  if ans > 10 ** 18:
    print(-1)
    exit()
print(ans)

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

Solution (Python):
N=int(input())
*A,=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()))

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

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

print(sum)

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

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

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

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

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

if 0 in A:
    print(0)

else:

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

    print(a)

Solution (Python):
n = int(input())
A = [int(i) for i in input().split()]
product = 1
A.sort()

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

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

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

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

if A.count(0):
  print(0)
  exit(0)

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

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

Solution (Python):
from sys import stdin,stdout
for _ in range(1):
    n=int(stdin.readline());p=1
    
    a=list(map(int,stdin.readline().split()))
    if 0 in a:
        print(0)
        exit(0)
    for v in a:
        p*=v
        if p>(10**18):
            p=-1
            break
    print(p)

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

if c > 1000000000000000000:
  print(-1)
else:
  print(c)

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

Solution (Python):
def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 1
    for i in range(N):
        if ans == -1 and A[i] != 0:
            continue
        ans *= A[i]
        if ans > 10**18:
            ans = -1
    print(ans)

if __name__ == "__main__":
    solve()

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

try:
    idx = a.index(0)
    print(0)

except ValueError:

    ans = a[0]
    for i in range(1, len(a)):
        ans *= a[i]
        if ans > 10**18:
            print('-1')
            exit()

    print(ans)

Solution (Python):

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

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

if a_lst[0] == 0:
    answer = 0
else:
    answer = 1
    for i in range(n):
        a = a_lst[i]
        answer *= a

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

print(answer)

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

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

if a_lst[0] == 0:
    answer = 0
else:
    answer = 1
    for i in range(n):
        a = a_lst[i]
        answer *= a

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

print(answer)

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

print(s)

Solution (Python):
import sys
N = int(input())
An = list(map(int,input().split()))
a = 1
if 0 in An:
    print("0")
    sys.exit()
else:
    for i in range(N):
        a *= An[i]
        if a > 10**18:
            print("-1")
            sys.exit()
    if a <= 10**18:
        print(a)
        sys.exit()

Solution (Python):

def inputlist(): return [int(j) for j in input().split()]

N = int(input())
A = inputlist()
A.sort()
ans = 1
if A[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()))

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

print(n)

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

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

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

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

if 0 in a:
    ans = 0
else:
    ans = 1
    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()))
l.sort()
c = 1
i = 0
while i < n:
  c *= l[i]
  i += 1
  if c > 1000000000000000000:
    break
if c <= 1000000000000000000:
  print(c)
else:
  print(-1)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
ans = A[0]
if A.count(0) != 0:
    ans = 0
else:
    for i in range(1,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()))

prod_max = 10**18
prod = A[0]

if 0 in A:
    print(0)
else:
    for i in range(N-1):
        prod *= A[i+1]
        if prod > prod_max:
            print('-1')
            break
        if i == N - 2:
            print(prod)

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

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

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

Solution (Python):
limit=10**18
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 > limit:
      ans=-1
      break
print(ans)

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

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

    if 0 in l:
        print(0)
        return

    prod = 1
    for i in l:
        prod *= i
        if prod > 1000000000000000000:
            print(-1)
            return

    print(prod)

if __name__ == '__main__':
    main()

Solution (Python):
from functools import reduce
from operator import mul
import math

def main():
    n = int(input())
    l = list(map(int, input().split()))

    if 0 in l:
        print(0)
        return
    l_sorted = sorted(l, reverse=True)
    log = 0
    seki = 1
    for i in l_sorted:
        log += math.log10(i)
        if log > 18:
            print(-1)
            return
        elif log == 18:
            seki *= i
            if seki != 10 ** 18:
                print(-1)
                return
        else:
            seki *= i
    print(seki)
    return


if __name__ == '__main__':
    main()

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

ans = 1
A.sort()

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

print(ans)

Solution (Python):

import math
N = int(input())
A = sorted(list(map(int,input().split())))
ans = 1
for a in A:
    ans *= a
    if ans == 0:
        break
    elif ans > 10**18:
        ans = -1
        break
print(ans)

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

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

print(ans)

Solution (Python):
n = int(input())
a = input().split(" ")
kotae=1
listaa = [int(n) for n in a]
lista = sorted(listaa)
if lista[0]==0:
  print(0)
  exit()
for i in range(n):
  kotae*=lista[i]
  if kotae>10**18:
    kotae=-1
    break
if kotae>10**18:
  kotae=-1
print(kotae)

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

Solution (Python):
N = int(input())
a = [int(s) for s in input().split()]
b = int(1)
flag = int(0)
flag2 = int(0)


for i in range(N):
  if a[i] == 0:
    flag = 1
    break
  else:
    pass

for i in range(N):
  b = b * a[i]
  if b > 1000000000000000000:
    flag2 = 1
    break
  else:
    pass

if flag == 1:
  print("0")
elif flag2 == 1:
  print("-1")
else:
  print(int(b))

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

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

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

print(ans)

Solution (Python):
import sys

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

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

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

print(tmp)

Solution (Python):
import sys

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


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

product = 1
for i in range(N):
    product = product * p[i]
    if product > 10 ** 18:
        print(-1)
        sys.exit()
        break

print(product)

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

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

def main(a):
  if 0 in a:
    ans = 0
  else:
    ans = 1
    for item in a:
      ans *= item
      if ans > 1000000000000000000:
        ans = -1
        break
  return ans

ans = main(a)
print(ans)

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
ans = x[0]
if 0 in x:
	ans = 0
else:
	for i in range(1,n):
		ans = ans * x[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 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()))

def multi(lst):
  count = 1
  if 0 in lst:
    return 0
  for i in lst:
    if count*i > 10**18:
      return -1
    else:
      count *= i
  return count

print(multi(lst))

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

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

Solution (Python):
if __name__ == '__main__':
  n = int(input())
  a = input().split()
  a = [int(x) for x in a]
  ans = 1

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

Solution (Python):
n = int(input())
sum = 1
flag = 1
limit = 1000000000000000000
nums = list(map(int, input().split()))
for num in nums:
  if num == 0:
    sum = 0
    break;
  if flag == 1:
    sum *= num
  if sum > limit or sum == -1:
    flag = 2
    sum = -1
print(sum)

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

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

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    length = 1
    limit = 10 ** 18
    if 0 in A:
        print(0)
        return
    for i in range(N):
        length = length *  A[i]
        if length > limit:
            print('-1')
            return
    print(length)
    return
if __name__ == '__main__':
    main()

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

def f(a):
    ans = 1
    if 0 in a:
        return 0
    for i in a:
        ans *= i
        if ans > 1e+18:
            return -1
    return ans

print(f(a))

Solution (Python):
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y

n = ini()
a = inl()
ans = 1
lim = 10 ** 18
for i in a:
        ans *= i
        if ans > lim:
                ans = -1
                break
if min(a) == 0:
        ans = 0
print(ans)

Solution (Python):

N=int(input())
A_list=sorted(list(map(int, input().split())), reverse=True)
ans=1

if 0 in A_list:
  print(0)
  exit()
else:
  for a in A_list:
    ans*=a
    if ans>1e+18:
      print(-1)
      exit()
  print(ans)

Solution (Python):
N=int(input())
A_list=sorted(list(map(int, input().split())), reverse=True)
ans=1

for a in A_list:
  ans*=a
  if ans>1e+18:
    ans=-1
    break
if 0 in A_list:
  ans=0
print(ans)

Solution (Python):


def main():
    N = int(input())
    A_array = tuple(map(int, input().split()))
    
    if 0 in A_array:
        print("0")
        return 0
        
    ans = 1
    for A in A_array:
        ans *= A
        if ans > 10 ** 18:
            print("-1")
            return 0
            
    print(ans)

main()

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

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

Solution (Python):
N = int(input())
MM = input().split()
total = 1
for i in MM:
  total = total*int(i)

  if total > 10**18:
    break
for i in MM:
  if int(i) == 0:
    total = 0
if total > 10**18:
  print(-1)
else:
  print(total)

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

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
res = 1
if 0 in a:
    print(0)
    exit()
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()))
res_max = 10 ** 18
res = 1
for i in A:
  if i == 0:
    print("0")
    exit()
for i in A:
  res *= i
  if res > res_max:
    print("-1")
    exit()
print(res)

Solution (Python):
def Qb():
    n = int(input())
    lina = list(map(int, input().split()))

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

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

if __name__ == '__main__':
    Qb()

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

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

    print(n)

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

    r = 1
    if 0 in t:
        print(0)
        return

    for tt in t:
        r *= tt
        if r > 10**18:
            print(-1)
            return

    print(r)

main()