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

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

ans = 1

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

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

print(ans)

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

result = 1

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

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

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

ans = 1
a.sort()
for a_i in a:
    ans *= a_i
    if ans > 1_000_000_000_000_000_000:
        ans = -1
        break

print(ans)

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

Solution (Python):
def Ii():return int(input())
def Mi():return map(int,input().split())
def Li():return list(map(int,input().split()))
n = Ii()
a = sorted(Li())

mx = 10**18
ans = 1
for i in a:
  
  ans *= i
  if ans > mx:
    ans = -1
    break
  elif ans == 0:
    break
    
print(ans)

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

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

print(ans)

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

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

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

Solution (Python):
n = int(input())
arr = [int(x) for x in input().split()]
res=1
arr.sort()
if arr[0] == 0 :
  print('0')
  exit(0)
for i in range(n):
  res = res*arr[i]
  if res>1e18:
    print(-1)
    exit(0)
print(res)

Solution (Python):
N = int(input())
lst = list(map(int, input().split()))
if (0 in lst):
  print(0)
else:
  product = 1
  for i in lst: 
    product *= i

    if(product > 1000000000000000000):
      print(-1)
      break
  else:
    print(product)

Solution (Python):
import sys

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

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

Π = 1
for _ in A:
    Π *= _
    if(Π > 1000000000000000000):
        print(-1)
        sys.exit(0)

print(Π)

Solution (Python):
import sys
n = int(input())
limit = 10 ** 18
ans = 1
a = [int(x) for x in input().split() ]
if 0 in a:
    print(0)
    sys.exit()

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

print(ans)

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

Solution (Python):
n = int(input())
l = map(int, input().split())
ans = 1
for a in l:
    if ans * a > 1e18:
        ans = -1
    elif ans != -1 or a == 0:
        ans *= a

print(ans)

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):
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()
mul = A.pop()
for a in A:
    mul *= a
    if mul > 10**18:
        print(-1)
        exit()
print(mul)

Solution (Python):

N = int(input())
A = list(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)

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

Solution (Python):
N = int(input())
l = list(map(int, input().split()))
if 0 in l:
    print(0)
    exit()
mlt = 1
for x in l:
    mlt *= x
    if mlt > 10 ** 18:
        print('-1')
        exit()
print(mlt)

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

Solution (Python):
def resolve():
    import sys
    sys.setrecursionlimit(10 ** 6)  
    to_index = lambda x: int(x) - 1  
    print_list_in_2D = lambda x: print(*x, sep="\n")  

    
    def input_int(): return int(input())

    def map_int_input(): return map(int, input())

    MII = map_int_input

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

    def MII_to_index(): return map(to_index, input())

    def MII_split_to_index(): return map(to_index, input().split())

    
    def list_int_inputs(): return list(map(int, input()))

    LII = list_int_inputs

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

    
    def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

    def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

    N = input_int()
    A_list = LII_split()

    if 0 in A_list:
        print(0)
        return

    ans = A_list[0]
    for A in A_list[1:]:
        ans *= A
        
        if ans > 1e18:
            ans = -1
            break
    print(ans)
    
resolve()

Solution (Python):
_ = input()
nums = list(map(int, input().split()))
ans = 1
 
for num in nums:
    if num==0 or ans <= 10 ** 18:
        ans *= num
    else:
        pass
 
print(ans if ans <= 10 ** 18 else -1)

Solution (Python):
_ = input()
nums = list(map(int, input().split()))
ans = 1

if 0 in nums:
  ans = 0
 
for num in nums:
    if ans <= 10 ** 18:
        ans *= num
    else:
        break
 
print(ans if ans <= 10**18 else -1)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
sorted(A)
result=1
if 0 in A:
    result=0
for i in A:
    if result==0:
        break
    result*=i
    if result>1000000000000000000:
        result=-1
        break

print(result)

Solution (Python):


import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = na()
    ans = 1
    if min(a) == 0:
        print(0)
        quit()
    for ai in a:
        ans *= ai
        if ans > 10**18:
            print(-1)
            quit()
    print(ans)

if __name__ == "__main__":
    main()

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

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

Solution (Python):
import sys

N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
    print(0)
    sys.exit()

for a in A:
    ans *= a
    if ans > 1e18:
        print(-1)
        sys.exit()
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 = x*a[i]
        if x>10**18:
            print('-1')
            exit(0)
    print(x)

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

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

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

Solution (Python):
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict

n=IN()
a=LI()
p=1
if 0 in a:
    print(0)
    exit()
for i in a:
    p*=i
    if p>pow(10,18):
        print(-1)
        exit()
print(p)

Solution (Python):
Max = 10**18
N = int(input())
array = list(map(int, input().split()))
for i in range(N):
	if array[i]==0:
		print(0)
		exit()

ans = 1
for i in range(N):
	ans *= array[i]
	if ans > Max:
		print(-1)
		exit()

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

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

res = 1
check = 10**18
flag = 0 in l

for e in l:
    res *= e
    if res > check:
        if flag:
            res = 0
        else:
            res = -1
        break

print(res)

Solution (Python):
import sys
input = sys.stdin.readline
 
M = int(1e18)
n = int(input())
s = list(map(int, input().split()))
res = 1
flag = False
if 0 in s: print('0')
else:
    for i in range(len(s)):
        res *= s[i]
        if res > M: flag = True; break
    print(-1 if flag else res)

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

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

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

print(b)

Solution (Python):
n = int(input())
arr = list(map(int,input().split()))
arr.sort(reverse=True)
ans = 1
limit = 10**18

if arr[-1] == 0:
  ans = 0
else:
  for i in arr:
    ans *= i
    if ans > limit:
      ans = -1
      break
print(ans)

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

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

Solution (Python):

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

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

LIM= 10**18
ans=1
for e in a:
    ans*=e
    if ans > LIM or ans<-1:
        ans = -1

if ans <0:
    ans = -1

print(ans)

Solution (Python):

n=int(input())
a=[int(x) for x in input().split()]
ans=1  
mod=int(1e18)
for i in range(n):
    if a[i]==0:
        ans=0 
        break 
for i in range(n):
    ans*=a[i]
    if ans>mod:
        ans=-1 
        break 
    if ans==0:
        break
print(ans)

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

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

Solution (Python):
from functools import reduce
def f(acc, a):
  if acc == 0 or a == 0:
    return 0
  elif acc == -1:
    return -1
  elif acc * a > 10 ** 18:
    return -1
  else:
    return acc * a

n = int(input())
a_list = list(map(int, input().split()))
print(reduce(f, a_list, 1))

Solution (Python):
import math  
from typing import Dict, List, Optional, Tuple, Union  


def main(N: int, A: List[int]):
    A = sorted(A, reverse=True)
    if A[-1] == 0:
        print(0)
        return
    ans = 1
    for a in A:
        ans *= a
        if ans > 10 ** 18:
            ans = -1
            break
    print(ans)


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

Solution (Python):



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

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

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

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

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

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

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

Solution (Python):
N = int(input())
A_list = list(map(int,input().split()))
output = 1
flug = 0

if 0 in A_list:
    print(0)
    flug = 1
if flug != 1:
    for i in range(N):
        output *= A_list[i]
        
        if (output > 10 ** 18):
            print(-1)
            flug = 1
            break
if(flug != 1):
    print(output)

Solution (Python):
from sys import stdin
data = stdin.readlines()

a = int(data[0])
b = [int(s) for s in data[1].split()]

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

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

Solution (Python):
n = int(input())
a = list(map(int, input().split(' ')))
if a.count(0) > 0:
	print("0")
else:
	lim = int(1e18)
	mult = 1
	for v in a:
		if mult > lim:
			break
		else:
			mult *= v
	if mult > lim:
		print("-1")
	else:
		print(mult)

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

def main():
    n = int(input())
    a = list(map(int, input().strip().split()))
    
    if 0 in a:
        print(0)
        return
    ans = 1
    for ai in a:
        ans *= ai
        if(ans > 10**18):
            print(-1)
            return
    print(ans)
    
if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    if 0 in a: 
        print(0)
        return
    ans = 1
    for ai in a:
        ans *= ai
        if ans > 10**18:
            print(-1)
            return
    print(ans)
    
if __name__ =="__main__":
    main()

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

if __name__ == "__main__":
    main()

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

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

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

    for i in A:
        if i == '0':
            print(0)
            return

    X = 1
    for i in A:
        X *= int(i)
        if X > 1000000000000000000:
            print(-1)
            return
    print(X)
main()

Solution (Python):

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

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

    return ans


if __name__ == '__main__':
    ans = main()
    print(ans)

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

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

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

res = 1
overflow = False

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

i = 0
while i < len(A) and res <= 10**18:
  res *= A[i]
  i += 1


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

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

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

print(ans)

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

Solution (Python):
def main():
    n = int(input())
    in_list = list(map(int,input().split()))
    result = 1
    if in_list.count(0)>0:
        print(0)
        return

    for i in range(n):
        result = result*in_list[i]
        if result > 10**18:
            print(-1)
            return
    print(result)

main()

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
ans = 1
a = sorted(a,reverse=True)
if(0 in a):
	print(0)
	exit()
for i in a:
	if(len(str(i)) + len(str(ans)) > 20):
		print(-1)
		exit()
	ans *=i

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

Solution (Python):
def main():
    num = int(input())
    num_list = list(map(int, input().split()))

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


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):

import sys
from decimal import Decimal

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


product = 1
max_product = 10**18

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


for a in A_list:
    check = Decimal(str(max_product)) / Decimal(str(product))

    if a <= check:
        product *= a
    else:
        print(-1)
        sys.exit()

print(product)

Solution (Python):
import sys

input = sys.stdin.readline

def main():

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

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




if __name__ == "__main__":
    main()

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

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

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

t = 1
limit = pow(10, 18)

if 0 in set(a):
    print(0)
else:
    for i in a:
        t *= i
        if t > limit:
            print(-1)
            break
    else:
        print(t)

Solution (Python):

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

P = 0
if not(0 in A):
    P = 1
    for i in A:
        P *= i
        if P > 10**18:
            P = -1
            break

print(P)

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

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

MultipliedNum=1
index=0

if min(Alist)==0:
    print(0)
    index=1

else:
    for i in Alist:
        MultipliedNum*=i

        if MultipliedNum>10**18:
            print(-1)
            index=1
            break
            
if index==0:
    print(MultipliedNum)

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

sum_A = 1

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

for i in range(0,len(A)):
  if(sum_A > 1000000000000000000):
        break
  sum_A *= A[i]
if(sum_A > 1000000000000000000):
        print("-1")
        exit()
print(sum_A)

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

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

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

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

res = 1
for a in A:
    res *= a
    if 1e18 < res:
        print(-1)
        sys.exit()

print(res)

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

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

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

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

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

ans = 1
if 0 in l:
  print(0)
  sys.exit()

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)

def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')







def solve():
    N = II()
    A = LI()
    A.sort()
    ans = 1
    th = pow(10, 18)
    for a in A:
        ans = ans * a
        if ans > th:
            print(-1)
            return
    print(ans)

if __name__ == '__main__':
    solve()

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

Solution (Python):
import sys

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

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

Solution (Python):
def resolve():
    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)
resolve()

Solution (Python):

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

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

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

    total = 1
    for a in A:
        total *= a

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

if __name__ == '__main__':
    main()

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

main()

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

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

print(s)

Solution (Python):
import numpy as np
N = int(input())
A = list(map(int, input().split()))
prod = 1
if 0 in A:
    print(0)
else:
    for i in A:
        prod *=i
        if prod > int(1e18):
            print(-1)
            break
    if prod <= int(1e18):
        print(prod)

Solution (Python):
import sys

stdin = sys.stdin


def ni(): return int(ns())


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


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  


N = ni()
ans = 1
a_array = na()
overflow = 0
for a in a_array:
    if a == 0:
        ans = 0
        break
    if not overflow:
        ans = ans * a
        if ans > 10 ** 18:
            overflow = 1
            ans = -1

print(ans)

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

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

ans=main()

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

ans = 1
flg_over_max = False
if(0 in a_int):
    print(0)
else:
    for a in a_int:
        ans *= a
        
        if(ans > 1000000000000000000):
            flg_over_max = True
            break
        
    if(flg_over_max):
        print(-1)
    else:
        print(ans)

Solution (Python):
N = int(input())
Al = list(map(int,input().split()))
result = 1
if 0 in Al:
    result = 0
else:
    for i in Al:
        result *= i
        if result > 10**18:
            result = -1
            break

print(result)

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

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

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

A.sort()

res = 1

for a in A:
  res *= a
  if res > 1000000000000000000:
    print(-1)
    quit()

print(res)

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

a=1

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

for i in A:

    a=a*i

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


print(a)

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

a = 1
b = 10**18

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

for i in range(0,N):
  
  a = n_list[i] * a
  
 
  if a > b:
     print(-1)
     sys.exit()

print(a)

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