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

Solution (Python):
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp



class UnionFindEx:
    def __init__(self, size):
        
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    N=ii()
    A=lmis()
    A.sort()
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            return
    print(ans)





main()

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

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

res = 1

if 0 in a:
    print(0)
else:
    for i in range(n):
        res *= a[i]

        if a[i] == 0:
            break
        if res > 10**18:
            print(-1)
            break


    if res > 10**18:
        pass
    else:
        print(res)

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

MAX = 1000000000000000000
ans = 1

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

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

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

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

if 0 in a:
    print(0)
else:
    for i in range(len(a)):
        if ans <= 10 ** 18:
            ans *= a[i]
    if ans <= 10 ** 18:
        print(ans)
    else:
        print(-1)

Solution (Python):
from sys import stdin
import sys
n = stdin.readline().rstrip()
a = [int(x) for x in stdin.readline().rstrip().split()]
tmp = 1
ok = 1
for i in a:
    if i == 0:
        print(0)
        sys.exit(0)
    if ok == 1:
        tmp *= i
        if tmp > 1000000000000000000:
            ok = 0
if ok == 0:
    print(-1)
else :
    print(tmp)

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

ch1 = 0
for i in a:
	if(i == 0):
		print(0)
		ch1 = 1
		break

if(not ch1):
	ans = 1
	ch2 = 0
	for i in a:
		ans*=i
		if(ans > int(1e18)):
			print(-1)
			ch2 = 1
			break
	if(not ch2):
		print(ans)

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








def calculate(n, arr):
    res = 1
    for i in range(n):
        if arr[i] == 0:
            res = 0
            break

        if res == -1:
            continue

        res = res * arr[i]
        if res > 1000000000000000000:
            res = -1

    return res


print(calculate(N, ARR))

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

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

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

prod = 1
overflow = False

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

for aa in a:
  if prod * aa > 1000000 * 1000000 * 1000000:
    overflow = True
  else:
    prod = prod * aa

for aa in a:
  if aa == 0:
    overflow = False

if overflow:
  print(-1)
else:
  print(prod)

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

maxval = 10 ** 18
ans = 1


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

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

nums = list(map(lambda x : int(x),input().split()))

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

print(ans)

Solution (Python):

def main():
    n = int(input())
    a = list(map(int,input().split()))
    temp = 1
    if 0 in a:
        temp = 0

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

if __name__ == '__main__':
    main()

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

ass.sort(reverse=True)

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

ans = 1
for i in range(n):
	ans *= ass[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)
else:
    for num, val in enumerate(a):
        ans *= val
        if ans > 10**18:
            print(-1)
            break 
    else:
        print(ans)

Solution (Python):
def Multiplication_2():
    N = int(input())
    An = list(map(int,input().split()))

    if 0 in An:
        return 0
    
    over = 10 ** 18

    ans = 1
    
    for i in An:
        ans *= i
        if ans > over:
            return -1
        
    
    return ans

print(Multiplication_2())

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

Solution (Python):
n = int(input())
ls = [int(x) for x in input().split()]
if 0 in ls:
    print(0)
    exit()
res = 1
for x in ls:
    if res <= 1000000000000000000:
        res *= x
    else:
        break

print(res if res <= 1000000000000000000 else -1)

Solution (Python):
import sys

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

num = 1

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

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

print(num)

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

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

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

ans = 1

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

  print(ans)

else:
  print(0)

Solution (Python):
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from sys import stdin
input = stdin.readline



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

ans = 1
ng = False
for i in range(n):
    if l[i] == 0:
        print(0)
        quit()
    if not ng:
        ans *= l[i]
        if ans > 10**18:
            ng = True

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

Solution (Python):
n = int(input())
a = [0]*n
a = input().split()
n0 = a.count('0')
sum = int(a[0])
if n0 == 0:
  for k in range(len(a)-1):
    sum =sum*int(a[k+1])
    if sum >1000000000000000000:
      print(-1)
      break
  if sum <=1000000000000000000:
    print(sum)
else:
  print(0)

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

ans = 1

over=False
zero=False

if 0 in data:
    zero=True

for num in data:
    ans*=num
    if(ans>1000000000000000000):
        over=True
        break

if ans>1000000000000000000:
    over=True

if zero:
    print("0")
elif over:
    print("-1")
else:
    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 a:
    ans*= 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 :
  prod = 1
  for x in a:
    prod *= x
    if prod:
      if prod > 10**18:
        print(-1)
        break
    else :
      print(0)
      break
  else :
    print(prod)

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

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

pi = 1
for A in As:
  pi*=A
  if pi>1000000000000000000:
    print("-1")
    exit()

print(str(pi))

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

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

if 0 in c:
  print('0')
  sys.exit()

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

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

    try:
        if a.index(0):
            print(0)
            sys.exit()
    except ValueError:
        pass

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

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import math,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 > pow(10,18):
        print(-1)
        sys.exit()

print(ans)

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

if __name__=='__main__':
    main()

Solution (Python):
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

n = int(input())
a = list(map(int,input().split()))
if 0 in a:
    print("0")
else:
    num = 1
    for x in range(n):
        num *= a[x]
        if 10**18 < num:
            num = -1
            break

    print(num)

Solution (Python):
n=int(input())
multi3 = [int(x.strip()) for x in input().split()]
ans=1
flag=True
for i in multi3:
    if ans*i>10**18:
        flag=False
    elif i==0:
        flag=True
        ans=0
        break
    else:
        ans*=i
if(flag):
    print(ans)
else:
    print(-1)

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

ans = 1
for a in A:
	ans *= a
	if ans > 10 ** 18:
		ans = 10 ** 18 + 1

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

Solution (Python):
import numpy as np
import math

n = int(input())
max = 1e+18
is_zero = False
ans = 1
a = input().split()

for i in range(n):
    if (int(a[i]) == 0):
        ans = 0
        is_zero = True
        break

if not is_zero:
    for i in range(n):
        ans *= int(a[i])
        if ans > max:
            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=input().split()
ans=1

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

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

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

flag = 0

for i in range (N):
    if pre[i] == 0:
        flag = 1

if flag == 0:

    ans = 1

    for i in range (N):
        ans *= pre[i]

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

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

else:
    print("0")

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

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

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



A.sort()


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

Solution (Python):
from sys import stdin
input=stdin.readline
a=1
ok=0
n=int(input())
ar=list(map(int,input().strip().split()))
ar.sort()
for i in ar:
    a*=i
    if(i==0):
        ok=1
        print(0)
        break
    if(a>1000000000000000000):
        ok=1
        print(-1)
        break
    
if(ok==0):
    print(a)

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

if __name__ == '__main__':
    for i in l:
        total *= i
        if total > 1000000000000000000:
            total = -1
            break

    if 0 in l :
        total = 0
    print(total)

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

Solution (Python):
import sys
n=int(input())
As = list(map(int, input().split()))
ans=1
for val in As:
    if val==0:
        ans=0
        break
for val in As:
    if ans==0:
        break
    if val==0:
        ans=0
        break
    ans=val*ans
    if 10**18<ans:
        ans=-1
        break

print(ans)

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

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

result = As[0]
if 0 in As:
    print(0)
else:
    for i in range(n-1):
        result = result*As[i+1]
        if result > 10**18 :
            print(-1)
            break
        else:
            continue
    if result <= 10**18 :
        print(result)

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

Solution (Python):




import sys
input = sys.stdin.readline




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

    Aset = set(A)

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

    A.sort(reverse=True)

    res = 1
    INF = 10 ** 18

    for i in range(N):
        res *= A[i]
        if res > INF:
            res = -1
            break

    print(res)



main()

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

X = 1

for i in range(N):
    if a[i] == 0:
        X = 0

if X == 1:
    for i in range(N):
        X = X * a[i]
        if X > 1000000000000000000:
            X = -1
            break

print(X)

Solution (Python):

N = int(input()) 
A = list(map(int, input().split()))
S = set(A)
if 0 in S:
  print(0)
  exit()
 
upp = 10**18
flag = 1
ans = 1

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

Solution (Python):
import sys

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

a = sorted(a)

num = a[0]

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

print(num)

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

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

Solution (Python):

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

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

Solution (Python):
import sys


def input1():
	return int(input())


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


def input_array():
	return list(map(int,input().split()))
  
n=input1()
A=input_array()
if 0 in A:
	print(0)
	sys.exit()
ans=1

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

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

Solution (Python):
MAX = 10 ** 18

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

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

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


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

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

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

over = False
if 0 in dat:
    print ("0")
else:
    for d in dat:
        tmp *= d
        if tmp > 1000000000000000000:
            print ("-1")
            over = True
            break
    if not over:
        print (tmp)

Solution (Python):
import sys

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

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

Solution (Python):
n = int(input())
ls = list(map(int,input().split(' ')))
pro=1
f=0
zero=0
for i in ls:
    if(i==0):
        zero=1
if(zero==1):
    print(0)
else:
    for i in ls:
        pro = pro*i
        if(pro > 1000000000000000000):
            print(-1)
            f=1
            break
    if(f==0 and pro<=1000000000000000000):
        print(pro)

Solution (Python):
N = int(input())
lst = list(map(int, input().split()))
if 0 in lst:
  print(0)
else:
  ans = 1
  for i in lst:
    ans *= i
    if ans > 1000000000000000000:
      print(-1)
      ans = -1
      break
  if ans != -1:
    print(ans)

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

Solution (Python):
import numpy as np
N = int(input())
A = [int(a) for a in input().split()]
ans = A[0]

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

for i in range(1, len(A)):
    if A[i] != 1:
        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(0)


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

    if ans > 1000000000000000000:
        print(-1)
        exit(0)

print(ans)
exit(0)



'''


a = int(input())

b, c = map(int, input().split())

s = input()

print('{} {}'.format(a+b+c, s))
'''

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

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


prod = 1
overflow_flag = False

if 0 in As:
    print(0)
else:
    for a in As:
        prod *= a

        if prod > 10**18:
            overflow_flag = True
            break

    if overflow_flag:
        print("-1")
    else:
        print(prod)

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

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

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

print(str(ans))

Solution (Python):
n = input()
ar = map(int,input().split())
ar = list(ar)
mul=1
ar=sorted(ar)

for i in ar:
	mul*=i
	if mul>10**18:
		break
if mul>10**18:
	print(-1)
else:
	print(mul)

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

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

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

ans = 1

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

Solution (Python):
import sys

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

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

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

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


flag = True

for a in A:
    if a == 0:
        flag = False
        print(0)

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = 1
lis = [0] * (n+1)


for i in range(n):
    if a[i] == 0:
        lis[i+1] += 1
    lis[i+1] += lis[i]

if lis[-1] > 0:
    print(0)
    exit()
for i in range(n):
    ans *= a[i]
    if lis[-1]-lis[i+1] == 0:
        if ans > int(1e18):
            print(-1)
            exit()
print(ans)

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

      break
  if flag:
    print(ans)

Solution (Python):

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

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

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

Solution (Python):
n = int(input());
ans = 1;
lis = list(map(int,input().split()))
flag = False
flag2 = False
for i in range(n):
    if lis[i]==0:
        flag = True
    if ans*lis[i]>=1000000000000000001:
        flag2 = True
    else:
        ans *= lis[i]

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

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

res = 1

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

for i in a:
    res *= i
    
    if (res > 1000000000000000000):
        res = -1
        break
        

if res == -1:
    for i in a:
        if i == 0:
            res = 0
            break

print(res)

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

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

over = False
mul = 1
if 0 in a:
    mul = 0
for a_ in a:
    mul *= a_
    if mul > 10**18:
        mul = -1
        break
print(mul)

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

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 = list(map(int, input().split()))

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

if zero > 0:
    print(0)
    exit(0)

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

print(ans)

Solution (Python):
N = int(input())
nums = input().split()
end = False
result = 1
for num in nums:
  if num == "0":
    print(0)
    end = True
    break
if not end:
  nums = [int(s) for s in nums]
  for num in nums:
    result = result * num
    if 10**18< result:
      result = -1
      break
  print(result)

Solution (Python):
N = int(input())
List = list(map(int, input().split()))
a=1
if  0 in List:
    print(0)

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

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

fflag = False
for i in range(n):
    if a[i] == 0:
        fflag = True
        break

ans = 1
flag = True
for i in range(n):
    if fflag == True:
        ans = 0
        break
    ans = ans * a[i]
    if ans == 0:
        break
    if ans > 1000000000000000000:
        print(-1)
        flag = False
        break

if flag == True:
    print(ans)

Solution (Python):
N=input()
s=input().split()
a = [int(j) for j in s]
lim=10**18

for i in range(int(N)):
    if(i==0):
      mul=int(a[0])
      if(0 in a):
          print(0)
          break
    else:
      mul=mul*int(a[i])
    if(mul>lim):
      print(-1)
      break
    if(i==int(N)-1):
      print(mul)
      break

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

Solution (Python):
import sys

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

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

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

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

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

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

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

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

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

num = 1
for ele in a:
  num *= ele
  if num > 1000000000000000000:
    print(-1)
    sys.exit()

print(num)

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

print(total)

Solution (Python):

"""
Created on Sun May 31 20:04:25 2020

@author: k
"""

n = int(input())
a = input().split()
inf = 1000000000000000000
ans = 1
f = 1
for x in a:
    x = int(x)
    if x == 0:
        f = 0
    if ans == -1:
        continue
    ans = ans*x
    if ans > inf:
        ans = -1
print(ans*f)

Solution (Python):


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

if ans <= 10 ** 18 and flg == 0:
    print(ans)

Solution (Python):
from decimal import *
n = int(input())
a=list(map(Decimal,input().split()))
a.sort()
ans = 1
for i in a:
    ans *= i
    if ans > 1000000000000000000:
        print(-1)
        exit()

print(ans)

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

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

print(ans)

Solution (Python):
n=int(input())
import  functools
import operator
prod=functools.partial(functools.reduce, operator.mul)
a=list(map(int,input().split()))
a.sort(reverse=True)
if a[0]*a[1]>10**18 and a[-1]!=0:
    print(-1)
    exit()
if a[-1]==0:
    print(0)
    exit()
    
ans=prod(a)

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