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

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
ans=1
limit=10**18
flag=True
for x in A:
  if x==0:
    flag=False
    ans=0
if flag:
  for x in A:
    ans=ans*x
    if ans > limit:
      ans=-1
      break
print(ans)

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

ans = 1

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

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


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

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

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

A = [int(i) for i in A]
A.sort()
re = A[0]

for i in range(1,n):
	if re > 1000000000000000000:
		re = -1
		break
	if re == 0:
		break
	re = re*A[i]

if re > 1000000000000000000:
	re = -1
print(re)

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

    res = 1

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

if __name__ == '__main__':
    main()

Solution (Python):
import sys
def calc():                                             
    _ = int(sys.stdin.readline())                       
    xs = [int(x) for x in sys.stdin.readline().split(" ")]
    for x in xs:                                          
        if x == 0:                                        
            return 0                                      
    r = 1                                                 
    m = 10 ** 18                                          
    for x in xs:                                          
        r *= x                                            
        if r > m:                                         
            return -1                                     
    return r                                              
                                                          
print(calc())

Solution (Python):
N=int(input())
array=input().split(" ")
sum=1
for j in range(N):
  if array[j]=="0":
    sum=0
if sum!=0:
  for i in range(N):
    sum=sum*int(array[i])
    if sum>1000000000000000000:
        sum=-1
        break
    else:
      continue
    break
print(sum)

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

count =data[0]
data.remove(data[0])

if 0 in data:
    print(0)

else:

    for _ in data:

        if count ==0:
            break
        elif count <= 10**18:
            count *= _

    if count ==0:
        print(0)
    elif count <= 10**18:
        print(count)
    else:
        print(-1)

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

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

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

Solution (Python):

import sys


def solve(N: int, A: "List[int]"):
    big = pow(10, 18)
    ret = 1
    if 0 in A:
        print(0)
        return
    for a in A:
        ret *= a
        if ret > big:
            print(-1)
            return
    print(ret)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):

N = int(input())
A = [int(i) for i in input().split()]
if 0 in A:
    print(0)
else:
    result = 1
    for i in range(len(A)):
        result = result * A[i]
        if result > 1000000000000000000:
            result = -1
            break
    print(result)

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

ans = 1
for a in A:
    ans *= a
    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()))

A.sort()
ans = 1

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

print(ans)

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

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

ans = 1

for e in num_list:
    if e == 0:
        ans = 0

for e in num_list:
    ans *= e
    if ans > 1000000000000000000:
        ans = -1
        break
    if ans == 0:
        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):
import sys
sys.setrecursionlimit(10**6)

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








ans = 1
ma = 1e18


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

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

for i in A:
    if not flag:
        if sum*i > 10**18:
            flag = True
        else:
            sum *= i
    else:
        if i == 0:
            print(0)
            exit()
if flag:
    print(-1)
else:
    print(sum)

Solution (Python):

import sys
_ = input()
l = list(map(int, input().split(" ")))

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

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

print(ans)

Solution (Python):
import sys



import math

def main():
    N = int(input())

    As = [int(s) for s in input().split()]
    logsum = 0
    prod = 1
    for a in As:
        if a == 0:
            print('0')
            return

        logsum += math.log10(a)
        


    if logsum > 18.2:
        print('-1')
        return

    for a in As:
        prod *= a

    if prod > 10 ** 18:
        print('-1')
        return
    print(prod)

    
    
    
    

    return 0

if __name__ == '__main__':
    sys.exit(main())

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

Solution (Python):
if __name__=="__main__":
    
    N = int(input())
    A = [None]*N
    A = list(map(int, input().split(' ')))
    result = 1
    flag = False
    is_zero = False
    if 0 in A:
        print("0")
    else:
        for x in A:
            result = result * x
            if result > 1e18:
                flag = True
                break
        if flag:
            print("-1")
        else:
            print(result)

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

print(res)

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

Solution (Python):
n=int(input())
s=1
f=0
x=[int(x) for x in input().split()]
if x.count(0)>0:
    print(0)
else:
    for i in range(len(x)):
        s=s*x[i]
        if s>10**18:
            f=1
            break
    if f:
        print(-1)
    else:print(s)

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

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

Solution (Python):
n=int(input())
num=list(map(int,input().split()))
ma=1000000000000000000
p=1
num.sort()
if num[0]==0:
    print(0)
elif num[-1]==1 and num[0]==1:
    print(1)
else:
    f=0
    for i in range(n-1,-1,-1):
        p*=num[i]
        if p>ma:
            f=1
            print(-1)
            break
    if f==0:
        print(p)

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

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

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

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

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

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

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

print(ans)

Solution (Python):
N = int(input())
A = [int(j) for j in input().split()]
from collections import Counter

A_C =Counter(A)
A_C = sorted(A_C.items(),key=lambda x:-x[0])

if 0 == A_C[-1][0]:
    print(0)
    exit()
    
result = 1
for a in A_C:
    result*=(a[0]**a[1])

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

print(result)

Solution (Python):
n = int(input())
str_list = input().split()

list = [int(k) for k in str_list]

list.sort(reverse=True)

result = 1

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

for i in range(n):
  result = result * list[i]
  if(result > 1000000000000000000):
    print('-1')
    exit()

print(result)

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

Solution (Python):
import sys

input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
    exit()
c = 1
l = 10 ** 18
for i in a:
    c *= i
    if c > l:
        print(-1)
        exit()

print(c)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
ret = 1
if 0 in A:
    print(0)
    exit()

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

Solution (Python):

import sys
n=int(input())
a=list(map(int,input().split()))
ans=1
 
for i in range(n):
    if a[i]==0:
        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()))
zero=a.count(0)

Inf=10**18

if zero>=1:
    print(0)
else:
    ans=1
    a.sort(reverse=True)
    for num in a:
        ans*=num
        if ans>Inf:
            print(-1)
            exit()
    
    print(ans)

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

Solution (Python):
def func(l):
	if 0 in l:
		return 0
	re = 1
	for i in l:
		re *= i
		if re > 10 ** 18:
			return -1
	return re
	
n = int(input())
l = list(map(int, input().split()))
print(func(l))

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

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

ls = sorted(ls)
f = 1
ans = 1
inf = 1000000000000000000
for x in ls:
    ans *= x
    if ans > inf:
        f = 0
        break

if f == 1:
    print(ans)
else:
    print("-1")

Solution (Python):


def main():
    N = int(input())
    A = [int(c) for c in input().split(' ')]
    A.sort(reverse=True)

    if A[-1] == 0:
        print('0')
        exit()
    elif A[0] > 1e18:
        print('-1')
        exit()

    ret = 1
    for x in A:
        ret = ret * x
        if ret > 1e18:
            print('-1')
            exit()
        elif ret == 0:
            print('0')
            exit()

    if ret == 0:
        print('0')
        exit()
    elif ret > 1e18:
        print('-1')
        exit()
    print(f'{ret}')


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
num = 1
flag = True
if A.count(0)>=1:
    print(0)
else:
    for i in A:
        num *= i
        if num > pow(10,18):
            print(-1)
            flag =False
            break

    if flag:
        print(num)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def solve():
  n = int(readline())
  num_list = list(map(int, input().split()))

  for a in num_list:
    if a == 0:
      print(0)
      return


  base = 10**18
  ans = 1

  for a in num_list:
    ans *= a
    if ans > base:
      print(-1)
      return

  print(ans)

solve()

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

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

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

import sys

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

ans = 1
for i in range(len(A)):
    ans *= A[i]
    if (ans > int(1e18)):
        print(-1)
        sys.exit(0)
if ans > int(1e18):
    print(-1)
else:
    print(ans)

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

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

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

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
limit = 1000000000000000000
ans = 1
for i in range(N):
    if A[i] == 0:
        ans = 0

flag = False
for i in range(N):
    ans *= A[i]  
    if ans > limit:
        flag = True
        break
print(-1) if flag else print(ans)

Solution (Python):
a=int(input())
l=[int(i) for i in input().split()]
mul=1
f=0
if 0 in l:
    print(0)
else:
    for i in l:
        mul*=i
        if mul>10**18:
            f=1
            print(-1)
            break
    if f==0:
        print(mul)

Solution (Python):
import sys

stdin = sys.stdin

def main():
    n = int(stdin.readline().rstrip())
    A = list(map(int, stdin.readline().rstrip().split()))
    A.sort()
    ans = 1
    for i in range(n):
        if ans > 10**18:
            if A[0] == 0:
                print(0)
                exit()
            print(-1)
            exit()
        ans *= A[-i]
    print(ans if ans <= 10**18 else -1)


main()

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

if A[0] == 0:
  print(0)
  quit()

result = 1

for a in A:
  result *= a
  if result > 1e18:
    print(-1)
    quit()

print(result)

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 = [int(i) for i in 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()))

import sys
ans = 1
for i in range(n):
    ans *= A[i]
    if ans > 10 ** 18:
        for j in range(i,n):
            if A[j]==0:
                print(0)
                sys.exit()
        ans=-1
        break

print(ans)

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

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

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

M_NUM = 10**18

ans = 1
for item in a:
    if ans > M_NUM:
        break
    ans *= item

if 0 in a:
    print('0')
elif ans > M_NUM:
    print('-1')
else:
    print(ans)

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

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

if 0 in alist:
  print("0")
else:
  result = 1
  m = 0
  while result <= 10**18 and m < n:
    result *= alist[m]
    m += 1
  if m < n or result > 10**18:
    print("-1")
  else:
    print(result)

Solution (Python):


import numpy as np

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



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

if any(( x > 10**18 for x in a)):
  print(-1)
  exit()

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

print(mult)

Solution (Python):
import sys
import copy
from collections import deque
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  
maxr = 10**18
_ = ni()
a = na()
res = 1

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

for item in a:
    res *= item
    if res > maxr:
        print(-1)
        exit(0)

print(res)

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
p = 1
mod = 1e18
f0 = 0
f1 = 0
for i in range(0,n):
    if a[i] == 0:
        f0 = 1
        break
    else:
        if f1 == 0:
            p = p*a[i]
            if p > mod:
                f1 = 1

if f0 == 1:
    print(0)
elif f1 == 1:
    print(-1)
else:
    print(p)

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

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

print(ans)

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

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

res = A[0]

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

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



print(res)

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

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

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

print(sum)

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

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

Solution (Python):


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

if __name__ == '__main__':
    main()

Solution (Python):
import sys
N = int(input())
input_list = input().split()
result = 1
max = 10 ** 18
if '0' in input_list:
    print(0)
else:
    for i in input_list:
        result *= int(i)
        if result > max:
            print(-1)
            sys.exit(0)
    print(result)

Solution (Python):
import math
n=int(input())
b=1
a=list(map(int,input().split()))
x=1000000000000000000
for i in range(n):
    if(a[i]==0):
        print(0)
        exit(0);

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

print(b);

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 > 1000000000000000000:
            ans = -1
            break

print(ans)

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

Solution (Python):
n = int(input())
li = [int(i) for i in input().split()]
times = 1

if 0 in li:
    times = 0
    print(0)
else:
    for k in range (0, n):
        times = times * li[k]
        if times > 10**18:
            print(-1)
            break
  
if times <= 10**18 and times != 0:
  print(times)

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

if(A.count(0)!=0):
    print('0')
    exit()

for i in range(1,len(A)):
    b=b*A[i]
    if(10**18<b):

        print('-1')
        exit()
        
print(b)

Solution (Python):
n = int(input())
numbers = [int(n) for n in input().split()]
res = 1
numbers.sort()
printou = False
for i in numbers:
	if(i == 0):
		print(0)
		printou = True
		break
	res *= i
	if(res > 1000000000000000000):
		print(-1)
		printou = True
		break

if not printou:
	print(res)

Solution (Python):
def main():
  n = int(input())
  a = list(map(int,input().split()))
  result = 1
  for i in range(n):
    result *= a[i]
    if result > 1000000000000000000:
      for j in range(i + 1, n):
        if a[j] == 0:
          return 0
      return -1
  return result

print(main())

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

Solution (Python):
n = int(input())
alist = list(map(int, input().split()))
ans = 1
max_val = 10**18

for i, a in enumerate(alist):
  ans *= a
  if ans > max_val:
    ans = -1
    for a in alist[i:]:
      if a == 0:
        ans =0
    break
print(ans)

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

ret = 1
for i in range(n):
	if(ret <= MAX):
		ret = ret*a[i]
	if(a[i] == 0):
		ret = 0
		break


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

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

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

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

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

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

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

print(ans)

Solution (Python):
import sys

def main():
    n = int(input())
    A = list(map(int, sys.stdin.readline().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)


if __name__ == '__main__':
    main()

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

if not 0 in s:
    if len(s) > 1:
        for i in range(1,N):
            a = a * s[i]
            
            if a > 10**18:
                a = -1
                break
else:
    a=0
print(a)

Solution (Python):



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

A = sorted(A)

t = 1
inf = int(1e18)
f = False
for i in range(N):
    t *= A[i]
    if t > inf:
        f = True
        break
        
if f:
    print(-1)
else:
    print(t)

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 *= i

    if ans >= 1000000000000000001:
        print(-1)
        exit()
print(ans)

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

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

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

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

judge = True
ans = 1

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

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

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

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

A.sort()

for i in A:
    if 0 <= (ans * i) and (ans * i) <= 1000000000000000000:
        ans *= i
        
    else:
        print("-1")
        exit(0)

print(ans)

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

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

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

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):
n = int(input())
a = list(map(int,input().split()))
if min(a) != 0:
  ans = 1
  for i in range(n):
    ans = ans*a[i]
    if 10**18 < ans:
      print(-1)
      break
  if ans <= 10**18 and ans != 0:
      print(ans)
else:
  print(0)

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

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

Solution (Python):


n=int(input())
l=list(map(int,input().split()))
res=1
f=1
if(0 in l):
    print(0)
    f=0
if(f==1):
    
    for x in l:
        res=res*x
        if(res>1000000000000000000):
            print(-1)    
            f=0
            break
    
    if(f==1):
        print(res)

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

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

for i in A:
    if i == 0: 
        ans = 0
        break
    elif ans > 10**18:
        break
    else:
        ans *=i

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

Solution (Python):
n = int(input())
s = list(map(int, input().split()))
if 0 in s:print(0);exit()
ans=1
for i in s:
  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)
    exit()

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

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

m = a[0]
over = False
limit = pow(10, 18)
for i in a[1:]:
    m *= i
    if m > limit:
        over = True
        break

if over:
    print("-1")
else:
    print(m)