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

Solution (Python):
n = int(input())
l = [int(x) for x in input().split()]
ans=int(1)
aaa=True
if 0 in l:
    aaa = False
    print(0)
else:
    for j in range(n):
        ans = ans*l[j]
        if ans > 10**18:
            print(-1)
            aaa=False
            break
if aaa:print(ans)

Solution (Python):
n = int(input())
ans = 1
m = 1000000000000000000
a = map(int, input().strip().split(" "))
a = list(a)

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

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

print(ans)

Solution (Python):


import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def solve(N, A):
    for i in range(N):
        if A[i] == 0:
            print(0)
            return
    ans =1
    for i in range(N):
        if A[i] > math.pow(10,18):
            print(-1)
            return
        ans *= A[i]
        if ans > math.pow(10,18):
            print(-1)
            return
    print(ans)



def main():
    import sys
    tokens = iter(sys.stdin.read().split())
    N = int(next(tokens))
    A = [None for _ in range(N)]
    for i in range(N):
        A[i] = int(next(tokens))
    assert next(tokens, None) is None
    solve(N, A)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
ans = 1
v = []
v = [int(x) for x in input().split()]
v.sort()
for x in v:
	ans = ans*x
	if ans > 1e18:
		break
if ans > 1e18:
	print(-1)
else :
	print(ans)

Solution (Python):

N = int(input())

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

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

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

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

    print(ans)

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

Solution (Python):
n=int(input())
a = [int(i) for i in input().split() if i!="1"]

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

Solution (Python):
import sys
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    ans = 1

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

    mo = pow(10, 18)
    for i in range(n):
        if a[i] > mo // ans:
            print(-1)
            sys.exit(0)
        else:
            ans *= a[i]
    print(ans)

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

    print(ans)

if __name__ == '__main__':
    main()

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

Solution (Python):
N = int(input())
A = [int(e) for e in 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
    else:
        print(ans)

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

Solution (Python):
import sys


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


if __name__ == '__main__':
    main()

Solution (Python):

n = int(input())

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

k = 1

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

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

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

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

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

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

t = 1

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

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

print(t)

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

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

result = 1
for i in A:
    result = result * i
    if result > 1000000000000000000:
        break

for j in A:
    if j == 0:
        result = 0
    



if result <= 1000000000000000000:
    print(result)
else:
    print(-1)

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

Solution (Python):
n = int(input())
a=[int(i) for i in input().split()]
ans=1
flag=0
for i in range(n):
    ans = ans*a[i]
    if a[i]==0:
        flag=1
    if ans>pow(10,18):
        ans=0
if ans==0 and flag==0:
    print("-1")
elif ans==0 and flag==1:
    print("0")
else:
    print(ans)

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

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

Solution (Python):
import math
import string
import collections
from collections import Counter
from collections import deque


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



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

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

ans = 1

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

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

print(ans)

Solution (Python):
num = input()
data = input().rstrip().split(" ")
ans = 1
if "0" in data:
    ans = 0
else:
    for i in data:
        ans = ans*int(i)
        if ans > 1000000000000000000:
            ans = -1
            break
print(ans)

Solution (Python):
n = int(input())
s = input().split()
s = [int(i) for i in s]
mul = 1
flag = 0

if 0 in s:
    print(0)
else:


    for item in s:
        mul *= item
        if flag == 1:
            break

        if mul >  1e18:
            print(-1)
            flag = 1

    if mul <=  1e18:
        print(mul)

Solution (Python):
import sys

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

N, *A = map(int, read().split())

ans=1
zero=False
for a in A:
    if a==0:
        zero=True
        break

if zero:
    print(0)
else:
    over=False
    for a in A:
        ans*=a
        if ans>1e18:
            print(-1)
            over=True
            break
    if not over:
        print(ans)

Solution (Python):
m = 1000000000000000000

n = input()
a = [int(i) for i in input().split()]


if 0 in a:
    print(0)
else:


    o = 1

    for i in a:
        if o <= m:
            o = o * i
        else:
            o = -1
            break
        
    if o > m:
        o = -1

    print(o)

Solution (Python):
n = int(input())
a = list(map(int, input().strip().split()))
LIMIT = 10**18

z = False
for x in a:
    if x == 0:
        z = True

if z:
    print(0)
else:
    ans = 1
    for x in a:
        ans = ans * x
        if ans > LIMIT:
            break
    print(ans if ans <= LIMIT else -1)

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

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

for i in range(n):
    ans *= a_list[i]
    if len(str(ans)) > 19 or ans > 10 ** 18:
        print(-1)
        exit()

print(ans)

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

mul = 1
if 0 in A:
    print("0")
else:
    for i in A:
        mul *= i
        if mul >= limit:
            print("-1")
            break
    if mul < limit:
        print(mul)

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

if 0 in ls:
  print('0')
  exit()

goukei = 1
for i in ls:
  goukei *= i

  if goukei > 1000000000000000000:
    print('-1')
    exit()

print(int(goukei))

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

Solution (Python):
N = int(input());
A = [int(x) for x in input().split()];
A = sorted(A);
pro = 1;
for x in A:
	pro *= x;
	if pro > 1000000000000000000:
		pro = -1;
		break;
print(pro);

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

product = 1
flag = 0

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

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

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

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

print(s)

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

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

print(s)

Solution (Python):




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

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

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

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

Solution (Python):
n = int(input())
upper = 1e18
res = 1
generator = map(int, input().split())
for x in generator:
   res *= x
   if res > upper:
      break

for x in generator:
   if x == 0:
      res = 0
   
print(-1 if res > upper else res)

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

solve()

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

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

Solution (Python):
N = int(input())
ans = 1
for A in input().split():
    A = int(A)
    if ans == -1 and A == 0:
        ans = 0
        break
    elif ans == -1:
        continue
    else:
        ans *= A
        if ans > 10**18:
            ans = -1
print(ans)

Solution (Python):
if __name__ == '__main__':
    a = int(input())
    b = [int(i) for i in input().split()]
    ans = 1
    b.sort(reverse=True)
    if 0 in b:
        ans = 0
    else:
        for i in range(len(b)):
            ans *= b[i]
            if ans > 10 ** 18:
                ans = -1
                break
    print(ans)

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

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

ans = nums[0]

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

for x in range(N - 1):
    ans = ans * nums[x + 1]
    if ans > 1000000000000000000:
        print("-1")
        exit()
        
print(ans)

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

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

NList.sort()
result = 1
for i in range(N):
    result *= NList[i]

    if result > 10 ** 18:
        break

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

Solution (Python):
N = 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 = [int(i) for i in input().split()]

result = a[0]
p = pow(10,18)

if 0 in a:
    result = 0

else:
    for i in range(n-1):
        result *= a[i+1]
        if result > p:
            result = -1
            break

print(result)

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

if flag == 0 :
    print(Asum)
else:
    print(-1)

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

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

ans = 1
for ll in l:
  ans *= ll
  if ans > 10**18 or ans==0:
    break
  
if ans > 10**18:
  print(-1)
else:
  print(ans)

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

Solution (Python):



def solve(N, As):
    ans = 1
    for a in sorted(As):
        ans *= a
        if ans == 0:
            return 0
        if ans > 10 ** 18:
            return -1
    return ans


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

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

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

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

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

print(ans)

Solution (Python):
import sys
import math
def get_array(): return list(map(int,sys.stdin.readline().strip().split()))
def get_ints(): return map(int,sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n=int(input())
a=get_array()
mul=1
flag=0
if 0 in a:
    print(0)
else:
    for i in range(n):
        mul=mul*a[i] 
        if mul>1000000000000000000:
            flag=1 
            break
    if flag==0:
        print(mul)
    else:
        print(-1)

Solution (Python):
def keisan(numlist):
  ans=1
  if "0" in numlist:
    return "0"
  for i in numlist:
    ans *= int(i)
    if ans > max:
      return "-1"
  return ans

  
  

num = input()
numlist = input().split()

max=10**18
print(keisan(numlist))

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *





































def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007




def main():
	N = inputInt()
	A = inputList()

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

	print(ans)






def bisect_left_reverse(a, x):
    if a[0] <= x:
        return 0
    if x < a[-1]:
        return len(a)
    
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] <= x:
            ok = mid
        else:
            ng = mid
    return ok

def bisect_right_reverse(a, x):
    if a[0] < x:
        return 0
    if x <= a[-1]:
        return len(a)
    
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] < x:
            ok = mid
        else:
            ng = mid
    return ok





def binary_search(list, item):
    low = 0
    high = len(list) - 1

    while low <= high:
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
            return mid
        if guess > item:
            high = mid -1
        else:
            low = mid + 1
    return None




def sunuke(N, K, mod=10**9+7):
	if N < K or K-1 < 0:
		return 0
	else:
		return combination(N-1, K-1, mod)




def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y




def H(n, r, mod=10**9+7):
	
	
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        
        
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv



def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)



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

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

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

l.sort(reverse=True)

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

N = ni()
A = nl()
L = 10 ** 18


def solve():
    ans = 1
    for a in A:
        if a == 0:
            ans = 0
            break
        if ans > 0:
            ans *= a
        if ans > L:
            ans = -1
    return ans


print(solve())

Solution (Python):

def main():
  _n = int(input())
  ans = 1
  for num in map(int, input().split()):
    if num == 0:
      print(0)
      return

    if ans <= 10**18:
      ans *= num

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

main()

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

list.sort(a)
ret = a[0]
for i in range(1, n):
    ret = ret * a[i]
    if ret > pow(10, 18):
        ret = -1
        break

print("{}".format(ret))

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

INF = 10 ** 18
ans = 1
if any([n == 0 for n in a]):
    print(0)
    exit()

for n in a:
    ans *= n
    if ans > INF:
        ans = -1
        break
print(ans)

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

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

if min(a)==0:
    print(0)
else:
    print(ans)

Solution (Python):
N = int(input())
arr = sorted(map(int, input().split()))
INF = 10 ** 18
ans = 1
for num in arr:
    ans *= num
    if num > 0 and ans > INF:
        ans = -1
        break
    elif ans == 0:
        break

print(ans)

Solution (Python):
import sys

N = int(input())
h = list(map(int, input().split()))
c = 1
if 0 in h:
    print(0)
    sys.exit()
for i in range(0, len(h)):
    c *= h[i]
    if c > 10**18:
        print(-1)
        sys.exit()
print(c)

Solution (Python):
import math
import sys

N = int(input())
A = list(map(int, input().split()))
if min(A) == 0:
    print(0)
else:
    k = 1
    flag = True
    for a in sorted(A, reverse=True):
        k *= a
        if k > math.pow(10, 18):
            print(-1)
            flag = False
            break

    if flag:
        print(k)

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

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

res = 1
exceeded = False
thresh = 10 ** 18
for a in [int(v) for v in input().split()]:
    if not exceeded:
        res *= a
        if res > thresh:
            exceeded = True
    elif a == 0:
        res = 0
        exceeded = False

if exceeded:
    print(-1)
else:
    print(res)

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

ans=1

flag=1
zero=0

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


for i in range(0,N):
    ans*=A[i]
    if ans>1000000000000000000:
        flag=0
        break;

if zero==1:
    print(0)
elif flag==0:
    print(-1)
else:
    print(ans)

Solution (Python):

 
import sys
import math
from collections import Counter
import itertools
import fractions


 

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())

def LI(): return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()
 
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'
 

p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")
 

n=II()
A=LI()
 
ans = 1

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

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

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

Solution (Python):
p = 10 ** 18

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

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

for i in range(n):
    ans *= a[i]
    if ans > p:
        print(-1)
        quit()


print(ans)

Solution (Python):
n = int(input())
arr = list(input().split(' '))
arr = map(int, sorted(arr))
ans = 1
for i in arr:
    ans *= i
    if ans > 1e18:
        print('-1')
        exit()
print(ans)

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

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

Solution (Python):
n=int(input())
A = list(map(int, input().split()))
result=1
limit=10**18
flg0=0
flg=0
for i in range(n):
  if A[i] == 0:
    flg0=1
    print('0')
for i in range(n):
  if flg0 == 1:
    break
  result *= A[i]
  if result > limit:
    print('-1')
    flg=1
    break
if flg != 1 and flg0 != 1:
  print(result)

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

for one in a:
    now *= one
    if now > 1e18:
        print("-1")
        exit()

print(now)

Solution (Python):


import random
import sys

if __name__ == '__main__':
    def _(f):
        for l in f:
            for i in l.split():
                yield(int(i))

    g = _(sys.stdin)

    N = next(g)

    a = []

    for i in range(N):
        a.append(next(g))

    a.sort()

    S = 1

    for i in a:
        S *= i

        if S == 0:
            print(0)
            sys.exit(0)
        elif S > 10 ** 18:
            print(-1)
            sys.exit(0)

    print(S)

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

for x in a:
    b *= x
    if b > 10**18:
        ans = -1
        break
    else:
        ans = b

print(ans)

Solution (Python):
import sys
import math
from functools import reduce
from operator import mul
sys.setrecursionlimit(10**6)

def InMap(): return list(map(int, sys.stdin.readline().split(' ')))
def In(): return int(sys.stdin.readline())
def InS(): return sys.stdin.readline()

N = In()
A = InMap()

A.sort()
if A[0] == 0:
    print(0)
    sys.exit()
res = 1
for i in A:
    res *= i
    if res > 1000000000000000000:
        print(-1)
        sys.exit()
print(res)

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

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

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

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

Solution (Python):
MAX_NUM = 10 ** 18

def main():
    import math
    N = int(input())
    A = list(map(int, input().split()))
    A_set = set(A)
    log_sum = 0
    if(0 in A_set):
        print("0")
        return
    
    A_log = [0] * N
    ans = 1
    for i in range(N):
        log_sum += math.log10(A[i])
        if(log_sum > 18):
            ans = -1
            break
        else:
            ans = ans * A[i]
            if(ans > MAX_NUM):
                ans = -1
                break
    print(ans)



main()

Solution (Python):
n=int(input())
ans=1;
i = []
for a in input().split():
    i.append( int(a) )
    if (int(a)==0):
        print(0)
        exit(0)
for l in i:
    ans*=l
    if (ans>1000*1000*1000*1000*1000*1000):
        print(-1)
        exit(0)
print(ans)

Solution (Python):
import sys

n = int(input())
a = list(map(int, input().split()))
cur = 1
for x in a:
    if ( x == 0 ):
        print(0)
        exit()

for x in a:
    cur = cur * x
    if ( cur > 1000000000000000000 ):
        print(-1)
        exit()
print(cur)

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

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

ans = 1

if min(A) == 0:
  print(0)

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

Solution (Python):

n = int(input())

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

if n != 0 :
    ans = a_list[0]
else :
    ans = 0

if 0 in a_list :
    ans = 0

for i in range(1, n):
    ans = ans * a_list[i]

    if 10**18 < ans :
        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
    flag = False
    for i in range(n):
        ans = ans * a[i]
        if ans > 10**18:
            flag = True
            break

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