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_l = list(map(int,input().split()))
ans = 1
for i in range(n):
    ans *= a_l[i]
    if ans > 10**18:
        if 0 not in a_l[i:n]:
            print(-1)
        else:
            print(0)
        quit()
    if ans == 0:
        print(0)
        quit()


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

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

def main():
    n = int(input())
    a = sorted(map(int, input().split()))
    ans = 1
    for x in a:
        ans *= x
        if ans > 10 ** 18:
            print(-1)
            exit()
    print(ans)

main()

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

result = 1
for el in a:
    result = result * el
    if result > 10 ** 18:
        result = -1
        break

if 0 in set(a):
    result = 0
    
print(result)

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

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

Solution (Python):
def main():
    input()
    a=input().split()
    if "0" in a:
        print(0)
        return
    s=1
    for i in a:
        s*=int(i)
        if s>1e+18:
            print("-1")
            return
    else:
        print(s)
    return
if __name__ == "__main__":
    main()

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

    


if __name__ == '__main__':
    main()

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

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

Solution (Python):
n = int(input())
A=list(map(int, input().split())) 
ans = 1
if A.count(0) >= 1:
    print(0)
    exit()

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

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

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

else:
    print(ans)

Solution (Python):




def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    

    
    

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

if __name__ == '__main__':
    main()

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

Solution (Python):

def solve():
	n = int(input())
	a = input().split()
	a = [int(aa) for aa in a]
	
	for aa in a:
		if aa == 0:
			print(0)
			return 0
	
	ans = 1;
	for aa in a:
		ans *= aa;
		if ans > 1e18:
			print(-1)
			return 0
	print(ans)
	
solve()

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

import sys
if 0 in A:
  print(0)
  sys.exit()
prod = 1
lim = 10 ** 18
for elem in A:
  prod *= elem
  if prod > lim:
    print(-1)
    sys.exit()
print(prod)

Solution (Python):

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

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

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

print(result)

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

Solution (Python):
N = int(input());
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit(0)
res = 1
for i in A:
    res *= i
    if res > 1e18:
        print(-1)
        exit(0)
print(res)

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

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

Solution (Python):
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
getcontext().prec = 400
N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print(0)
    exit()
i=1
a=10**18

for n in A:
    
    i*=n
    
    if i>a:
        print(-1)
        exit()
print(i)

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

if min(a) == 0:
    print(0)
    exit()
else:
    ans = a[0]
    for i in range(1, n, 1):
        ans = ans * a[i]
        if ans > 1e+18:
            print(-1)
            exit()
    print(ans)

Solution (Python):
n = int(input())
as_ = sorted(list(map(int, input().strip().split())))

ans = 1
if as_[0] == 0:
    print(0)
    exit(0)

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

print(ans)

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

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


t=sorted(s)

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

print(count)

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

Solution (Python):
S = int(input())
A=list(map(int, input().split()))
LIMIT = 10**18
if 0 in A:
  print(0)
  exit(0)

ans=1
for i in range(len(A)):
  ans = A[i]*ans
  if ans > LIMIT:
    print(-1)
    exit(0)
print(ans)

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

Solution (Python):
n=int(input())
arr=[int(i) for i in input().split()]
total=1
arr.sort()
if(arr[0]==0):
    print(0)
else:

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

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

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

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

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

flag=0
for x in A:
    if x==0:
        print('0')
        exit()

    if flag==0:
        ans=x
        flag=1
        continue

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

print(ans)

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

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

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

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

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

print(ans)

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

Solution (Python):
n=int(input())
arr=[int(i) for i in input().split()]
if 0 in arr:
    print(0)
    exit()
f=1 
prod=1 
for i in arr:
    prod*=i 
    if prod>10**18:
      f=0 
      break
        
print(prod if f else -1)

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

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

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

for i in l:
  ans *= i
  if ans > 1e18 or ans == 0:
    break
if ans > 1e18:    
  print(-1)
else:
  print(ans)

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

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

m = 10 ** 18

s = 1
for aa in a:
    s = s * aa
    if s > m:
        print(-1)
        exit(0)

print(s)

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

Solution (Python):

import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def main():
    n =ni()
    s = na()
    s.sort()
    l = pow(10,18)
    ans = 1
    for i in s:
        ans *= i
        if ans > l:
            print(-1)
            return
    print(ans)
    return


if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys
import math

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


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

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

print(result)

Solution (Python):
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N=II()
LIS=LI()

MX=1000000000000000000
res = 1
if 0 in LIS:
    print(0)
else:
    for i in LIS:
        res *= i
        if res > MX:
            print(-1)
            exit(0)
    print(res)

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

T = 10**18

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

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

print(ans)

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

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

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

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

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

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

Solution (Python):
n=int(input())
a=list(map(int, input().split()))
if 0 in a:
    print(0)
else:
    ans=1
    for x in a:
        ans=ans*x
        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:
    print("0")
    exit()

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

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

Solution (Python):
N = int(input())
L = list(map(int, input().split()))
Ans = 1
if min(L) == 0:
    print(0)
else:
    for i in range(N):
        Ans *= L[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:
    print(0)
    exit()

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

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

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

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

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

if a.count(0) >= 1:
    hantei = True
    ans = 0
print(ans) if hantei else print(-1)

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

Solution (Python):




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


a.sort()
ans = a[0]
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 = [int(a) for a in input().split()]
over = 10 ** 18
isOver = False
is0 = False
ans = 1
for a in A:
    ans *= a
    if ans > over:
        isOver = True
        ans = 1
    elif ans == 0:
        is0 = True
if is0:
    print(0)
elif isOver:
    print(-1)
else:
    print(ans)

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



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):
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().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):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
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()
a.sort()
x = 1
for i in range(n):
    x *= a[i]
    
    if x > 10**18:
        print(-1)
        quit()
print(x)

Solution (Python):

MOD = 10 ** 9 + 7
INFI = 10**10

import math
from collections import deque
import itertools
import heapq

from fractions import Fraction
import copy
from functools import lru_cache



def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default




def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)



def main():
    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:
        ans=0
    print(ans)










if __name__ == "__main__":

    main()

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

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

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

ans = 1
for x in arr:
    ans *= x
    if ans > 10**18:
        ans = 10**19

if ans == 10**19:
  print(-1)
else:
  print(ans)

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

if As[0] == 0:
    print(0)
    exit()
b = 1
for a in reversed(As):
    b *= a
    if b > 10**18:
        print(-1)
        exit()
print(b)

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

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

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

print(ans)

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

list.sort(A, reverse=True)

if A[-1] == 0:
  print(0)
  exit()

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

print(mul)

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

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

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

print(ans)

Solution (Python):
import sys
import heapq
import random
import collections




import math


def solve(lst):  
    
    if 0 in lst:
        return 0
        
    res = 1
    for r in lst:
        res *= r
        if res > 10**18:
            return -1

    return res

def console(*args):  
    print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return



    
    

    
_ = int(input())
    
    
    

    

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

    
    
    
    
    
    

res = solve(lst)

    
    

    
print(res)

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

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

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())))

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


if __name__ == '__main__':
    resolve()

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

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

print(ans)

Solution (Python):
def abc169_b():
    _ = int(input())
    A = list(map(int, input().split()))
    lim = 10**18

    if 0 in A: return 0

    ans = 1
    for a in A:
        ans *= a
        if lim < ans: return -1
    return ans

print(abc169_b())

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

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

print(ans)

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

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

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

print(ans)

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

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


'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''
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:
        print(-1)
        sys.exit()

print(ans)

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

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

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

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

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

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

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

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

m = 10 ** 18

ans = 1
ex = False
for i in range(n):
    if a[i] == 0:
        print(0)
        ex = True

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

    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):
n = int(input())
a = list(map(int,input().split()))
s = 1
if 0 in a:
  print(0)
  exit()
for k in a:
  s *= k
  if s > 10**18:
    print(-1)
    exit()
print(s)

Solution (Python):
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
A=nl()

ans=1

for i in A:
    if(i==0):
        print(0)
        sys.exit(0) 
for i in A:
    ans*=i
    if(10**18<ans):
        print(-1)
        sys.exit(0)

print(ans)

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

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

print(ans)

Solution (Python):
import sys
from collections import deque

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

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

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

M = 10**18

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

Solution (Python):

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

    if a.count(0) >= 1:
        print("0")
        return

    MAX = 1000000000000000000
    ans = 1
    for x in a:
        if (ans <= MAX):
            ans *= x

    if ans > MAX:
        print("-1")
    else:
        print(ans)

if __name__ == "__main__":
    main()

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

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

ans = 1

for x in a:
    ans = ans * x

    if (ans > 10**18):
        ans = -1;
        break

for x in a:
    if x == 0:
        ans = 0

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 > pow(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')
else:
    for a in A:
        ans *= a
        if ans > 10**18:
            ans = -1
            break

    print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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 = sorted([int(i) for i in input().split()])
ans = 1
for a in A:
    if a == 0:
        ans = 0
        break
    ans *= a
    if ans > 10**18:
        ans = -1
        break
print(ans)

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

prod = 1
flag = 0
lim = 1e18
A.sort()
for num in A:
  prod = num*prod
  if prod > lim:
    flag = 1
    break
if flag == 1:
  print(-1)
else:
  print(prod)

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

    ans = A[0]
    if 0 in A:
        print(0)
        return

    for i in range(1, N):
        ans = ans * A[i]

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

    print(ans)


resolve()

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

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

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
total = 1
count = 0
for i in range(n):
    total *= A[i]
    if total > 10**18:
        count += 1
        break

if 0 in A:
    print('0')
elif count == 1:
    print('-1')
else:
    print(total)

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

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

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

tmp = A[0]
index = 1
while tmp < 10**18 and index < N:
    tmp *= A[index]
    index += 1

A.sort()

if A[0] == 0:
    print(0)
elif tmp > 10**18:
    print(-1)
else:
    print(tmp)