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):
input()
ans = 1
n = int(1e18)
a = list(map(int, input().strip().split()))
for i in a:
    ans *= i
    if ans > n:
        ans = -1
        break
if 0 in a: ans = 0
print(ans)

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

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

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

Solution (Python):
def solve():
    e = 10 ** 18
    n = int(input())
    arr = [int(i) for i in input().split()]
    ans, flag = [1,1]
    if 0 in arr:
      	return 0
    for i in arr:
        ans = ans * i
        if ans > e:
            return -1
    return ans
print(solve())

Solution (Python):
import math
n = int(input())
A = list(map(int, input().split(" ")))
A.sort()
ans = 1
ok = True
for i in A:
    ans = ans * i
    if(ans > math.pow(10, 18)):
        ok = False
        break

print(ans if ok else -1)

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

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

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

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

n = int(input())

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

a = sorted(a)
ans = 1
for x in a:
    ans = ans * x
    if (ans > 1e18):
        ans = -1
        break

print(ans)

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

Solution (Python):
def Mul(data,start = 0 ,end = None):
    if end == None:
        end = len(data)-1
    if start == end:
        return data[start]
    else:
        mid = (start+end)//2
        A = Mul(data,start,mid)
        B = Mul(data,mid+1,end)
        return A*B
n = int(input())
data = list(map(int,input().split()))
X = Mul(data)
if X>10**18:
  print(-1)
else:
  print(X)

Solution (Python):
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N = INT()
A = LIST()

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

Solution (Python):
import math
N=int(input())
risuto=list(map(int,input().split()))
ans=1
kari=0
if 0 in risuto:
    print(0)
else:
    for j in range(N):
        kari+=math.log10(risuto[j])

    if kari<18:
        for i in range(N):
            ans*=risuto[i]
        print(ans) 
    elif kari==18:
        for i in range(N):
            ans*=risuto[i]
        if ans>10**18:
            print(-1)
        else:
            print(ans)
    else:
        print(-1)

Solution (Python):
import math
N=int(input())
risuto=list(map(int,input().split()))
ans=1
kari=0
if 0 in risuto:
    print(0)
else:
    for j in range(N):
        kari+=math.log10(risuto[j])

    if kari<18:
        for i in range(N):
            ans*=risuto[i]
        print(ans) 
    elif kari==18:
        for i in range(N):
            ans*=risuto[i]
        if ans>10**18:
            print(-1)
        else:
            print(ans)
    else:
        print(-1)

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

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

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

    
main()

Solution (Python):
import math
N=int(input())
risuto=list(map(int,input().split()))
ans=1
kari=0
if 0 in risuto:
    print(0)
else:
    for j in range(N):
        kari+=math.log10(risuto[j])

    if kari<18:
        for i in range(N):
            ans*=risuto[i]
        print(ans) 
    elif kari==18:
        for i in range(N):
            ans*=risuto[i]
        if ans>10**18:
            print(-1)
        else:
            print(ans)
    else:
        print(-1)

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

Solution (Python):
n = int(input())
L = sorted(list(map(int, input().split())), reverse=True)
ret = 1
if L[-1] == 0:
    print(0)
else:
    for i in L:
        ret *= i
        if ret > 10**18:
            ret = -1
            break
    print(ret)

Solution (Python):


import sys
import math 




input = sys.stdin.readline

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))



def run_test() :
    N = int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)

def main() :
	run_test()

if __name__ == '__main__' :
	main()

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

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

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

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

s = 1
for i in a:
    s = s*i
    s = min(s,10**18+1)
if s == 10**18+1:
    print('-1')
else:
    print(s)

Solution (Python):
n,*l=map(int,open(0).read().split())
from heapq import*;p=heappop;heapify(l)
while len(l)>1:heappush(l,p(l)*p(l))
print([l[0],-1][l[0]>10**18])

Solution (Python):
n,*l=map(int,open(0).read().split())
from heapq import*
p=heappop
heapify(l)
while len(l)>1: heappush(l,p(l)*p(l))
print([l[0],-1][l[0]>10**18])

Solution (Python):
n,*l=map(int,open(0).read().split())
from heapq import*;heapify(l)
while len(l)>1:heappush(l,heappop(l)*heappop(l))
print([l[0],-1][l[0]>10**18])

Solution (Python):
"""
pythonはオーバーフローしないが、桁数がデカい整数の計算をすると、計算が間に合わなくなる。
O（N^2)とかになる。

0のときは0を答えないとダメなので、0があったら0とするでよい。

"""


import sys

N = int(input())

An = [int(_) for _ in input().split()]
An.sort()

ans = 1

for val in An:
    
    if(int(val) == 0):
        print(0)
        sys.exit()
    ans *= val
    
    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)
    exit()

limit = 10**18

result = 1
for value in A:
    result *= value
    if result > limit:
        result = -1
        break

print(result)

Solution (Python):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

MX = 10**18
n=ni()
a = sorted(nl())



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

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

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

Solution (Python):
import sys

N = int(input())

An = [int(_) for _ in input().split()]
An.sort()

ans = 1

for val in An:
    
    if(int(val) == 0):
        print(0)
        sys.exit()
    ans *= val
    
    if(ans > 10 **18):
        print(-1)
        sys.exit()

print(ans)

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

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

Solution (Python):
n,*l=map(int,open(0).read().split())
from heapq import *
heapify(l)
while len(l)>1:
  heappush(l,heappop(l)*heappop(l))
print([l[0],-1][l[0]>10**18])

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    ans=1
    
    for i in range(N):
        ans=ans*A[i]
        if ans>pow(10,18):
            ans=-1
            break
        
    if 0 in A:
        ans=0
        
    print(ans)

main()

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

Solution (Python):
INF = 10 ** 18

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

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

ans = 1
for i in range(len(a)):

    ans = ans * a[i]
    if ans > INF:
        print("-1")
        exit()

print(ans)

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

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

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

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

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

    ans = 1
    if 0 in a: return 0
    for i in a:
        ans *= i
        if ans > int(1e18): return -1
    
    
    return ans
    

print(solve())

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

def main():

    if 0 in a:
        print(0)
        return
    
    val = 1
    for each in a:
        val *= each
        if val > 1e+18:
            print(-1)
            return
    print(val)

main()

Solution (Python):
def demon():
  N = int(input())
  A = list(map(int,input().split()))
  A.sort()
  if A[0] == 0:
    print(0)
    return

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

  print(X)

demon()

Solution (Python):
import sys
n = input()
nums = [int(e) for e in input().split()]

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

ans = 1
s = 10**18

for i in nums:
  ans = ans * i
  if(ans > s):
    print('-1')
    break


if(ans <= s):
  print(ans)

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

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()))

judge=10**18
ans = 1

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

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

print(ans)

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

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

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

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

print(ans)

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

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()))

ans = 1

if 0 in A:
	print(0)
else:
	for a in range(N):
		ans = ans * A[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:
    print(0)
    exit()

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


print(ans)

Solution (Python):
def main(): 
  N = int(input())
  str_num = input().split()

  num_list = []
  for i in str_num:
    num_list.append(int(i))

  num_list.sort(reverse=True)

  ans = num_list[0]

  LIMIT_NUM = 10**18

  if 0 in num_list:
    print(0)
    return

  for i in range(1,N):
    ans *= num_list[i]
    if ans > LIMIT_NUM:
      print(-1)
      return

  print(ans)


main()

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

Solution (Python):


count = int(input())
nums = []
nums = input().split(" ")

total = 1

for i in range(count):
    if int(nums[i]) == 0:
        total = 0
        break


for i in range(count):
    total = int(nums[i]) * total
    if total > 10**18:
        total = -1
        break
print(total)

Solution (Python):
p=1
mx=1000000000000000000
n=int(input())
num=input().split()
z=num.count('0')
if(z!=0):
    print('0')
else:    
    for i in num:
        p*=int(i)
        if(p>mx):
            p=-1
            break
    print(p)

Solution (Python):

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

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

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

Solution (Python):
import sys

n = int(input())
a = [int(i) for i in input().split()]
prd = 1
if 0 in a:
  print(0)
  sys.exit()
for i in range(n):
  prd*=a[i]
  if prd > 10**18:
    print(-1)
    sys.exit()
print(prd)

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

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):
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

n = input()
seq = sorted((int(x) for x in input().split()))
if seq[0] == 0:
    ans = 0
else:
    ans = 1
    for val in seq:
        ans *= val
        if ans > 10**18:
            ans = -1
            break
print(ans)

Solution (Python):
def intMap(): return map(int,input().split())
def intList(): return list(map(int, input().split())) 
n = int(input())
a = intList()


MAX_NUM = 10**18

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

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

print(ans)

Solution (Python):
import math

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

if 0 in A:
    print(0)
elif sum(map(math.log, A)) > math.log(10**18*1.1):
    print(-1)
else:
    temp = 1
    for a in A:
        temp *= a
    if temp > 10 ** 18:
        print(-1)
    else:
        print(temp)

Solution (Python):
from sys import stdin

def main():
  read = stdin.readline
  N = int(read())
  data = list(map(int,read().split(" ")))
  ans = 1
  flg = False
  if 0 in data:
    print("0")
    flg = True
    exit()
  for i in data:
    
    if ans*i > 10**18:
      print("-1")
      flg = True
      break
    else:
      ans *= i
      
  if not flg:  
    print(ans)
  
  
if __name__ == "__main__":
  main()

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

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

ans = 1

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

Solution (Python):
n = int(raw_input())
a = map(int, raw_input().split())
ans = 1
a.sort()
for val in a:
	ans = ans * val
	if ans > 10 ** 18:
		ans = -1
		break
print ans

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

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

main()

Solution (Python):
n = int(input())
a = [int(i) for i in 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):
def main():
    n = int(input())

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

    if 0 in a:
        print(0)
        return

    ans = 1
    for tmp in a:
        ans *= tmp
        if (ans > 1e18) :
            print(-1)
            return

    print(ans)

main()

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

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

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

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

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

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

print(multiple)

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

Solution (Python):
def fun(a,n):
    if 0 in a:
        return 0
    z = 1
    for i in a:
        z=z*i 
        if(z>1000000000000000000):
            return -1
    return z

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

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans = 1

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

if __name__ == '__main__':
    main()

Solution (Python):
input()
a = list(map(int, input().split()))
ans = 1
a.sort()
for i in a:
    if ans != -1:
        ans *= i
    if ans > int(1e18):
        ans = -1

print(ans)

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

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

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

print(ans)

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

Solution (Python):
n = int(input())
lista = [int(e) for e in input().split()]

if 0 in lista:
    ans = 0
else:
    ans = 1
    for i in lista:
        ans *= i
        if ans>10**18:
            ans = -1
            break

print(ans)

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

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

a = [int(x) for x in input().split() ]
sum = a[0]

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


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

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

def main():
    N = int(readline())
    res = 1
    A = list(map(int, readline().rstrip().split()))
    if 0 in A:
        print(0)
        return
    for a in A:
        res *= a
        if res > 10 ** 18:
            print(-1)
            return

    print(res)
    

if __name__ == '__main__':
    main()

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

if 0 in A:
  ans = 0
  N = 0

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

print(ans)

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

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

ans = 1

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

print(ans)

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

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


print(ans)

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

    if 0 in A:
        print(0)
        return

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

    print(ans)

main()

Solution (Python):

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

    if 0 in A:
        print(0)
        return

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

    print(prod)
    return

main ()

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

print(ans)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    a = LI()
    if min(a) == 0:
        return 0
    r = 1
    for c in a:
        r *= c
        if r > 10**18:
            return -1

    return r

print(main())

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

Solution (Python):
import sys






n=input()
s=list(map(int,input().split())) 
count=0

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

print(a)

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

if 0 in a:
  print(0)
  sys.exit()
  
b = 10 ** 18
ret = 1
for i in a:
  ret = ret * i
  if ret > b:
    print('-1')
    sys.exit()
else:
  print(ret)

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

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

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

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

print(ans)

Solution (Python):
def multiply2(A):
    res = 1
    if 0 in A:
        return 0
    for item in A:
        res *= item
        if res > 10**18:
            return -1
    return res

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

Solution (Python):
import sys
n=int(input())
List=list(map(int,input().split()))
List.sort(reverse=True)
if List[-1]==0:
    print(0)
    sys.exit()
ans=1
for i in List:
    if ans<=10**18:
        ans*=i
    else:
        print(-1)
        sys.exit()
if ans<=10**18:
    print(ans)
else:
    print(-1)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

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

limit = 10 ** 18
A = sorted(A)

total = A[0]
if total == 0:
    print(total)
    exit()

for a in A[1:]:
    total *= a
    if total > limit:
        print(-1)
        exit()
print(total)

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

main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

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

A = sorted(A)

total = A[0]
limit = 10 ** 18

for a in A[1:]:
    total *= a
    if total > limit:
        print(-1)
        exit()
print(total)

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

if sorted(a)[0]==0:
    print(0)
else:
    import math
    b = [math.log10(i) for i in a if i!=0]    
    if sum(b)>18:
        print(-1)
    else:
        z = 1
        for i in a:
            z*=i
        if z>10**18:
            print(-1)
        else:
            print(z)

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

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

ans = 1
for i in a:
    if ans * i <= 1e18:
        ans *= i
    else:
        print(-1)
        exit()
print(ans)

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

if a[0] == 0:
    print(0)
else:
    ans = 1
    for i in a:
        ans *= i
        if(ans > 1e18):
            print(-1)
            exit()
    print(ans)

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