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

def f(A):
    for a in A:
        if a == 0:
            print(0)
            return
    v = 1
    for a in A:
        v *= a
        if v > int(1e+18):
            print(-1)
            return
    print(v)
    return

f(A)

Solution (Python):
import sys

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

if 0 in A:
    print(0)
    sys.exit()
else:
    for x in range(n):
        product = product*A[x]
        if product > 10**18:
            print(-1)
            sys.exit()

print(product)

Solution (Python):
def prod(a):
    if 0 in a:
        return 0
    p = 1
    for ai in a:
        if p * ai <= 10**18:
            p *= ai
        else:
            return -1
    return p

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

Solution (Python):
def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))
n = inN()
a = inL()
if 0 in a:
    print(0)
    exit()

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

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

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

solve()

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

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

ans = 1

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

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

print (ans)

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

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

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

if not ( 2 <= N <= 10**5 ): sys.exit()
if not ( 0 <= min(array) and max(array) <= 10**18): sys.exit()
if 0 in array: print(0); sys.exit()

sum = array[0]
for I in range(1,len(array)):
    sum *= array[I]
    if sum > 10**18: print(-1);sys.exit()
print(sum)

Solution (Python):
n = int(input())
arr = list(map(int, input().split()))
if 0 in arr:
    print('0' + '\n')
else:
    mul = 1
    for n in arr:
        mul *= n
        if mul > 10**18:
            print('-1' + '\n')
            break
    else:
        print(str(mul) + '\n')

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

A = list(map(int, input().split()))
A = sorted(A)
total = 1
for i in A:
    total *= i
    if total > 10**18:
        total = -1
        break
print(total)

Solution (Python):


from typing import *
import itertools
import math
import sys

INF = float('inf')


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


def main():

    sys.setrecursionlimit(10 ** 6)

    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)]  
    print(solve(N, A))


if __name__ == '__main__':
    main()

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

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

    print(product)

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

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




flag = True

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

if flag:
  for i in a:
    ans *= i
    if ans > limit:
      print(-1)
      flag = False
      break

if flag:
  print(ans)

Solution (Python):
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

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

N=one_int()

A=many_int()
A=sorted(A)

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

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

p=1

for k in range(N):
    if A[k] == 0:
        p = 0
        break

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

    print(p)

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

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

print(s)

Solution (Python):
n = int(input())
a = sorted(map(int, input().split()))
lim = 10**18
multi = 1
for x in a:
    multi *= x
    
    if multi > lim:
        print(-1)
        exit()

print(multi)

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

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

if nums.count(0):
    print(0)
    exit(0)

result=1
for i in nums:
    result *= i
    if result > (10**18):
        print(-1)
        exit(0)
print(result)

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

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

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())
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())
A = sorted([int(i) for i in input().split()])

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

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

print(ans)

Solution (Python):

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

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

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

    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()

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 = int(input())
A = [int(x) for x in input().split()]

result = 1

if A.count(0) == 0:
    for x in range(N):
        result = result * A[x]
        if result >= 10**18 + 1:
            print(-1)
            exit()
    print(result)
else:
    print(0)

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

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

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

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

ans = 1
for i in range(N):
  ans = 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()))
if 0 in A:
    print(0)
    exit()

max = 10**18

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

print(mul)

Solution (Python):
n = int(input())
ans,f=1,0
ls = sorted(map(int,input().split()))
for i in ls:
    ans*=i
    
    if ans > 1e18:
        f=1
        break
if f:
    print(-1)
else :
    print(ans)

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

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

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

main()

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

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

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

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):
N = int(input())
A = list(map(int,input().split()))
A.sort()
result = 1
for i in range(N):
    result = result * A[i]
    if result > 1e18:
        result = -1
        break
print(result)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A.sort()
result = 1
for i in range(N):
    result = result * A[i]
    if result > 1e18:
        result = -1
        break
print(result)

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

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

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

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

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
A = list(map(int,input().split()))
A.sort()
result = 1
for i in range(N):
    result = result * A[i]
    if result > 1e18:
        result = -1
        break
print(result)

Solution (Python):
n=int(input())
arr=list(map(int,input().split()))
arr.sort();
x=int(1)
for i in arr:
  x=x*i
  if x>1e18:
    x=-1;
    break;
print(x)

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

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

print(ans)

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


def log(*args):
    print(*args, file=sys.stderr)


def main():
    np.set_printoptions(threshold=20)
    N = int(input())
    A = list(map(int, input().rstrip().split()))
    A.sort()
    ans = 1
    for v in A:
        ans *= v
        if ans > pow(10, 18):
            ans = -1
            break
    print(ans)


if __name__ == '__main__':
    main()

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

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

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

mult = 1

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

Solution (Python):


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

    if 0 in A:
        print(0)
    else:
        out = 1
        for n in A:
            out = n * out
            if out > 1000000000000000000:
                break
            else:
                continue
    
        if out > 1000000000000000000:
            print(-1)
        else:
            print(out)


main()

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

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

else:
    print(ans)

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

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

if a.count(0) != 0:
    print(0)
else:
    result = 1
    for i in range(n):
        result *= a[i]
        if result > (10**18):
            print(-1)
            break
        else:
            continue
    else:
        print(result)

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

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

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

if a.count(0) != 0:
  print(0)
else:
  result = 1
  for i in range(n):
    result *= a[i]
    if result > (10**18):
      print(-1)
      break
    else:
      continue
  else:
    print(result)

Solution (Python):
import sys  

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

cur = 1  
for x in a:
    cur *= x
    if cur > 10 ** 18:
    
        print(-1)
        sys.exit()
print(cur)

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

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

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

print(multi)

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

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

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

print(c)

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


print(ans)

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

Solution (Python):
import sys  

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')
        sys.exit()
print(ans)

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

result = multiplication()
print(result)

Solution (Python):
import sys

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

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

s = 1
for x in a:
  s *= x
  if s > 1000000000000000000:
    break
if s > 1000000000000000000:
  print(-1)
else:
  print(s)

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

for S in B:
    result *= S
    if result > 10**18:
        print(-1)
        exit()
print("%d"%result)

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

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

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

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

final = 1

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

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

        else:
            ans=D
        

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

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

prod = 1

A.sort()
if A[0] == 0:
    prod = 0

A.sort(reverse=True)


for i in range(N):
    prod *= A[i]
    if prod > 1e18:
        prod = -1
        break
    if prod == 0:
        break

print(prod)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def line_to_int(): return int(sys.stdin.readline())
def line_to_each_int(): return map(int, sys.stdin.readline().split())
def line_to_list(): return list(map(int, sys.stdin.readline().split()))
def line_to_list_in_iteration(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]






n = line_to_int()
a = line_to_list()













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

Solution (Python):
def b169(n, alist):

    ans = 1
    for i in alist:
        if i == 0:
            return 0

    for i in alist:
        ans *= i
        if ans > 10**18:
            return -1

    return ans

def main():
    n = int(input())
    alist = list(map(int, input().split()))
    print(b169(n, alist))

if __name__ == '__main__':
    main()

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

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

Solution (Python):
a=int(input())
List = list(map(int, input().split()))
res =1
List.sort()
for i in range(a):
  res = res *List[i]
  if res > 1000000000000000000:
    res = -1
    break
  elif res == 0:
    break
  else:
    pass
print(res)

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

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

print(ans)

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

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

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

Solution (Python):

n = int(input())
a = list(map(int, input().split()))
if 0 in a:
    output = 0
    
else:

    output = 1

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

Solution (Python):
import sys
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:
            print(-1)
            sys.exit()
    print(temp)

Solution (Python):
n = input()
n = int(n)
a = input().split()
b = 1
if '0' in a:
    print ("0")
else:
    for i in a:
        b *= int(i)
        if (b > 1000000000000000000):
            print ("-1")
            break
    if (b <= 1000000000000000000):
        print (b)

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

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

Solution (Python):
def main(numbers: list):
    result = 1
    numbers.sort()
    for num in numbers:
        result *= num
        if result > 10 ** 18:
            print(-1)
            return

    print(result)


N = int(input())
line = list(map(int, input().split()))
main(line)

Solution (Python):
MX = 10**18
def fun(a,n):
	if max(a) > MX:
		return -1
	if 0 in a:
		return 0
	res = a[0]
	for i in range(1,n):
		res = res * a[i]
		if res > MX:
			return -1
	return res

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

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

Solution (Python):
n, *a = map(int, open(0).read().split())
res = 1
if 0 in a:
  print(0)
  exit()
for a in a:
  res *= a
  if res > 1e18:
    res = -1
    break
print(res)

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

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

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

Solution (Python):

def main():
    n = int(input())
    al = list(map(int,input().split()))
    al_p = 1

    if 0 in al:
        print(0)
        return

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

main()

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

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

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

Solution (Python):
ans = 1
ok1 = True
_n = int(input())
a = list(map(int,input().split()))
ok2 = False
if 0 in a:
    ok2 = True

for i in a:
    ans *= i
    if ans > 1e18:
        ok1 = False
        break

if ok2:
    print(0)
elif ok1:
    print(ans)
else :
    print(-1)

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

Solution (Python):
input()
a = [int(i) for i in input().split(" ")]
p = 1
for i in a:
 p *= i
 if(p > 10**18): p = 10**18 + 1
if(p > 10**18):
 print(-1)
else:
 print(p)

Solution (Python):
import math

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

ans = 1
for num in range(N):
    ans *= A[num]
    if ans > math.pow(10, 18):
        ans = -1
        break

if 0 in A:
    ans = 0

print(ans)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

a = k()
b = l()
b.sort()
ans = 1
for i in b:
    if i == 0:
        print(0)
        sys.exit()
    else:
        ans *= i
    if ans > 10**18:
        print(-1)
        sys.exit()

print(ans)

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

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



for ai in A:
  if ai == 0 :
    print('0')
    exit()
	    
ans = A[0]      
for i in range(1,N):
  
  ans *= A[i]
  
  ansCp = ans
  ansCnt = 1
  while ansCp >= 10:
    ansCp /= 10
    ansCnt += 1
    
  if (ansCnt > 19) or ( ansCnt == 19 and ans%10 > 0 ) :
    print("-1")
    exit()
  
  
      
print(str(ans))

Solution (Python):
import sys

if __name__ == "__main__":
    a = int(input())
    n = list(map(int, input().strip().split(' ')))
    ans = 1
    n.sort()
    for i in n:
      ans *= i
      if ans > 10**18:
          break
    if ans > 10**18:
        print(-1)
    else:
        print(ans)

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

flag = 1
if 0 in num:
  print(0)
  flag=0

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

if flag==1:
  print(ans)

Solution (Python):

import sys


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


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


def main():
    N = II()
    A = LI()

    ans = 1
    index = 0
    A_set = set(A)
    if 0 in A_set:
        print(0)
        return
    while index < N:
        ans *= A[index]
        index += 1
        if ans > 10**18:
            break

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




main()

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

a.sort()
sum_num = 1
std_num = 1000000000000000000
if(a[-1] == 0):
    sum_num = 0
else:
    for i in range(n):
        sum_num = a[i]*sum_num
        if(sum_num > std_num):
            sum_num = -1
            break;
print(sum_num)

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

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

print(ans)

Solution (Python):
def main():
    N=int(input())
    X=input().split()
    if "0" in X:
        print(0)
        return
    ans=1
    for i in X:
        ans = int(i) * ans
        if 1000000000000000000<ans:
            print(-1)
            return
    print(ans)
main()

Solution (Python):
def main():
    N=int(input())
    X=input().split()
    if "0" in X:
        print(0)
        return
    ans=1
    for i in X:
        ans = int(i) * ans
        if 1000000000000000000<ans:
            print(-1)
            return
    print(ans)
main()

Solution (Python):
def main():
    N=int(input())
    X=input().split()
    if "0" in X:
        print(0)
        return
    ans=1
    for i in X:
        ans = int(i) * ans
        if 1e18<ans:
            print(-1)
            return
    print(ans)
main()

Solution (Python):
N=int(input())
X=input().split()

ans=1
if "0" in X:
    print(0)
else:
    for i in X:
        ans = int(i) * ans
        if 1e18<ans:
            print(-1)
            break
    else:
        print(ans)

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

ans=1
if 0 in X:
    print(0)
else:
    for i in X:
        ans *= i
        if 1e18<ans:
            print(-1)
            break
    else:
        print(ans)

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

ans=1
if 0 in X:
    print(0)
else:
    X.sort()
    for i in X:
        ans *= i
        if 1e18<ans:
            print(-1)
            break
    else:
        print(ans)

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

ans=1
if 0 in X:
    print(0)
else:
    X.sort()
    for i in range(N):
        ans *= X[i]
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)

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

ans=1
if 0 in X:
    print(0)
else:
    X.sort(reverse = True)
    for i in range(N):
        ans *= X[i]
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)

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

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

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

print(ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
ans = 1
A.sort(reverse=True)
t = A.pop()
if t == 0:
    print(0)
    exit(0)

A.append(t)

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