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()))
s = 1

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

if 0 in a:
    s = 0

print(s)

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

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

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

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



flag = 0
b = 1

for a in A:
  if a == 0:
    flag = 2

if flag == 0:
  for a in A:
    b = b * a
    if(b > 10**18):
      flag = 1
      break



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

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

b = sorted(a, reverse=True)


ans=1

if min(b) == 0:
    print(0)
    exit(0)

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



print(ans)

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

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

if __name__ == '__main__':
    main()

Solution (Python):
big = 10**18
n = int(input())
things = list(map(int, input().split()))
result = 1
good = True
if 0 in things:
	print(0)
else:
	for x in things:
		result *= x
		if result > big:
			print(-1)
			good = False
			break
	if good:
		print(result)

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

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
i = 0
ans = 1
if 0 in a:
    print(0)
else:
    while ans<10**18 and i < len(a):
        ans*=a[i]
        i+=1
    if ans<=10**18:
        print(ans)
    else:
        print(-1)

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

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

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

Solution (Python):
n=int(input())
cnt=1
a=sorted(list(map(int,input().split())))
for it in a:
  cnt*=it
  if cnt>1000000000000000000:
    print(-1)
    exit()
if cnt>1000000000000000000:
  print(-1)
else:
  print(cnt)

Solution (Python):
import sys

n = sys.stdin.readline()
l = list(map(int, sys.stdin.readline().split()))
tmp = 1000000000000000000

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

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

count = 1

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

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

print(count)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
max = 10**18
sum = 1
a.sort(reverse=True)
for i in a:
  sum *= i 
  if sum > max:
    sum = -1
    break
if 0 in a:
  sum = 0
print(sum)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
if 0 in a:
    print(0)
    exit()
a.sort(reverse = True)
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()]
if 0 in a:
    print(0)
else:

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

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

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

flag = True
ans = 1
if 0 in A:
    print(0)
    flag = False

if flag:
    for i in A:
        ans *= i
        if ans > pow(10,18):
            print(-1)
            flag = False
            break

if flag:
    print(ans)

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

print(calc())

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

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

if flag == 1 and (0 not in a):
    ans = -1
if 0 in a:
    ans = 0

print(ans)

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

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

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

Solution (Python):
import sys
import numpy as np
import math
import random
from decimal import Decimal
import itertools
import re
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(2147483647)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

def main():
	n = I()
	A = sorted(np.array(LI()))
	product = Decimal('1')
	for a in A:
		ad = Decimal(str(a))
		product *= ad
		if product > Decimal(str(10**18)):
			product = -1
			break
	print(int(product))




if __name__ == '__main__':
    main()

Solution (Python):
input()
l = list(map(int, input().split()))
if 0 in l:
    print(0)
else:
    r = 1
    for i in l:
        r *= i
        if r > 1e18:
            break
    print(-1 if r > 1e18 else r)

Solution (Python):

import math

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

chk_0 = 0
for i in range(N):
  if ( A[i]==0 ):
    chk_0 = 1

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

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

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

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

pi = 1
for num in a:
    pi*=num
    if pi > 10**18:
        pi = -1
        break;

print(pi)

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

    if 0 in A:
        print(0)
        return

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

    print(result)

if __name__ == "__main__":
    main()

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

Solution (Python):
import sys

n = int(input())
alist = [ int(x) for x in input().split() ]
product = 1

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

for index in range(len(alist)):
    product = product * alist[index]
    if product > 10**18:
        print(-1)
        sys.exit()

print(product)

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

p = 1

flag = False
zero = False
n = input().split()
for i in n:
    x = int(i)
    p = p * x
    if p == 0:
        zero = True

    if p > 1000000000000000000:
        flag = True
        p = 1

if zero:
    print(0)
else:
    if flag:
        print(-1)
    else:
        print(p)

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

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

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

if a.count(0) > 0:
    ans = 0

print(ans)

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

Solution (Python):
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
if A[-1] == 0:
    print(0)
    exit()
ans = 1
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()))
tot = a[0]

if a.count(0) > 0:
  print(0)
  exit()

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

print(tot)

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

sum = 1

if 0 in A:
    sum = 0

else:
    for i in range(len(A)):
        sum *= A[i]
        if sum > 1000000000000000000:
            break
    
if sum > 1000000000000000000:
    sum = -1

print(sum)

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

Solution (Python):

def main():
    n = int(input())
    *A, = map(int, input().split())
    a = 1
    if 0 in A:
        print(0)
    else :
        for i in A:
            a*=i
            if a > 10**18:
                print(-1)
                break
        else :
            print(a)

if __name__ == "__main__":
    main()

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

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

print(cnt)

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

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

answer = 1
for Ai in A:
    answer *= Ai
    if answer > 10 ** 18:
        answer = -1
        break

print(answer)

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

ans = 1
if a.count(0):
    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()))
ans=1
flag=True
if 0 in A:
    print(0)
else:
    for j in A:
        ans*=j
        if ans>10**18:
            print(-1)
            flag=False
            break
    if flag:
        print(ans)

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

if A.count(0) != 0:
    print(0)
else:
    result = 1
    for e in A:
        result *= e
        if result > 10**18:
            break

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

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

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

if min(an) == 0:
    print(0)
else:
    calc = 1
    is_ok = True
    for i in sorted(an, reverse=True):
        calc *= i
        if calc >10 ** 18:
            is_ok = False
            break
    if is_ok:
        print(calc)        
    else:
        print(-1)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
A.sort()
if A[0]==0:
    print(0)
else:
    ok=bool(True)
    ans=int(1)
    for i in A:
        ans*=i
        if ans>1000000000000000000:
            ans=0
            ok=False
    if ok:
        print(ans)
    else:
        print(-1)

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

A.sort()
B = list(set(A))

total = 1
flag = 9
for i in range(len(B)):
  total *= B[i]**A.count(B[i])
  if total > 10**18:
    flag = 0
    break
  elif min(A) == 0:
    flag = 1
    break
  
if flag == 0:
  print(-1)
elif flag == 1:
  print(0)
else:
  print(total)

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

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

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

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

Solution (Python):
n=int(input())
arr=[int(i) for i in input().split()]
ans=1
if 0 in arr:
    print(0)
else:
    for i in arr:
        ans=ans*i
        boo=True
        if ans>1000000000000000000:
            print(-1)
            boo=False
            break
    if boo:
        print(ans)

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

ans = A[0]

if 0 in A:
    ans = 0
else:
    for i in range(1, N):
        ans = ans * A[i]

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

print(ans)

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

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

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

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

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

if 0 in A:
    print(0)
    exit(0)
else:
    for i in range(1, N):
        res *= A[i]
        if res > limit:
            print(-1)
            exit(0)

print(res)

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

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

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

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

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

print(dp[n])

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = 1
flag =0
for i  in a:
    if i == 0:
        flag=2
        break
if flag!= 2:
    for i  in a:
        ans = ans*i
        if ans > 10 ** 18:
            flag=1
            break


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

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

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

if 0 in A:
    print(0)
elif ans > 10**18:
    print(-1)
else:
    print(ans)

Solution (Python):
import sys

N = int(input())
X = list(map(int, input().split()))
if min(X) == 0:
  print(0)
  sys.exit()
Y = X[0]
for i in range(1, N):
  Y = X[i] * Y
  if Y > 10 ** 18:
    print(-1)
    sys.exit()
print(Y)

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

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

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 1
    for ai in a:
        ans *= ai
        if ans == 0:
            print(0)
            exit()
        elif ans > 10 ** 18:
            print(-1)
            exit()
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

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

Solution (Python):


from collections import deque

n = int(input())

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

if min(a_list) == 0:
    print("0")
else:
    a_dq = deque(a_list)
    ans = 1
    for i in range(n):
        ans *= a_dq.popleft()
        if ans > 10**18:
            break

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

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

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

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

print(ans)

Solution (Python):
import sys

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

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

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

else : print(a)

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

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

EL = 1
for i in range(N):
    EL = EL * As[i]
    if EL > 1e+18:
        print(-1)
        exit(0)
print(EL)

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

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

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

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

if min(a) == 0:
  print(0)
else:


  ans = 1
  f = False

  for e in a:
    ans *= e
    if ans > 1e18:
      f = True
      print(-1)
      break

  if not f:
    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 e in l:
    ans *= e
    if ans > 10 ** 18:
        print('-1')
        sys.exit()

print(str(ans))

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


def f():

    for i in range(n):
        a = int(A[i])
        if(a == 0):
            return 0

    ans = 1

    for i in range(n):
        a = int(A[i])
        if(a == 0):
            return 0
        elif(ans*a > 1000000000000000000):

            return -1
        ans *= a

    return ans


print(f())

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

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

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

print(r)

Solution (Python):
x = input()
y = [int(a) for a in input().split(" ")]
if 0 in y:
  print(0)
  exit(0)
res = 1
for i in y:
  res *= i
  if res > int(1e+18):
    print(-1)
    exit(0)
print(res)

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

Solution (Python):
import math


def main():
    N = int(input())
    A = list(map(int, input().split()))
    if 0 in A:
        ans = 0
    else:
        ans = 1
        for x in A:
            ans *= x
            if ans > 10**18:
                ans = -1
                break
    print(ans)

 
 
if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10000)
    main()

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

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

for i in range(n):
    if re > 1000000000000000000:
        break
    re = re * li[i]
if 0 in li:
    print(0)
elif re > 1000000000000000000:
    print(-1)
else:
    print(re)

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

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

Solution (Python):


import sys
























from itertools import accumulate             


import operator as op



def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n = ii()
    L = lmi()
    ans = 1
    if any(map(lambda x: x==0, L)):
        print(0)
    else:
        for i in range(n):
            ans = ans * L[i]
            if ans > 10**18:
                print(-1)
                exit()
        print(ans)


if __name__ == "__main__":
    main()

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

Solution (Python):
N = int(input())
n = list(map(int, input().split()))
i = 1
f = 0
n.sort()
for j in n:
  i = i * j
  if i > 10**18:
    print(-1)
    f = 1
    break
  elif i == 0:
    break
if f == 0:
  print(i)

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

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

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


class Solution:
    def main(self):
        n = int(input())
        a = list(map(int, input().split()))

        a.sort()

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


if __name__ == '__main__':
    Solution().main()

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

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

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

    else:
        print(ans)

Solution (Python):
n = int(input())
goukei = 1
ok = 0
arr = [int(x) for x in input().split()]
if 0 in arr:
    print(0)
else:
    for i in arr:
        goukei *= int(i)
        if goukei > 1000000000000000000:
            print(-1)
            ok = 1
            break
    if ok == 0:
        print(goukei)

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

A = sorted(A, reverse= True)

if A[-1] == 0:
    print(0)
    exit()
    
ans = 1

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

print(ans)

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

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

ans = 1 
for i in range(N):
  ans *= A[i]
  if ans > 1e+18:
    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 num in A:
        ans *= num
        if ans > 1e18:
            ans = -1
            break

print(ans)

Solution (Python):
n=int(input())
A=list(map(int,input("").split()))
ans=1
A.sort()
for i in A:
    ans*=i
    if ans==0:
        break
    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 a in A:
        ans *= a
        if ans > 10 ** 18:
            ans = -1
            break

print(ans)

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

Solution (Python):
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
A.sort()
res = 1
if 0 in A:
  res = 0
else:
  for i in range(N):
    res *= A[i]
    if res > 10**18:
      res = -1
      break

print(res)

Solution (Python):

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

if __name__ == '__main__':
    main()

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

Solution (Python):
import sys

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

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

Solution (Python):
from math import *
from heapq import *

def mi():
    return map(int, input().split())
def ii():
    return int(input())
def li():
    return list(mi())
def gcd(a,b):return a if(not b) else gcd(b,a%b)
def qw(a,b,p):
    '''quick pow'''
    ans = 1
    while b:
        if b & 1:
            ans = ans * a % p
        a = a * a % p
        b >>= 1
    return ans
def is_prime(x):
    if(x < 2): return 0
    for i in range(2,int(sqrt(x)+1)):
        if(x % i == 0) : return 0
    return 1

n = ii()
a = li()
ans = 1
ok = 1
a.sort()
for i in range(0,n):
    ans = ans * a[i]
    if(ans > 1000000000000000000):
        ok = 0
        break

if(ok == 0):print(-1)
else: print(ans)

Solution (Python):
import math
n = int(input())
A = list(map(int, input().split()))
lg = 0
for a in A:
    if a == 0:
        print(0)
        exit()
    lg += math.log10(a)
if lg > 18:
    print(-1)
else:
    ans = 1
    for a in A:
        ans *= a
    if ans > 10**18:
        print(-1)
    else:
        print(ans)

Solution (Python):
N=int(input())
Alist=list(map(int,input().split()))
multi=Alist[0]
ibreak=0
if(Alist.count(0)>0):
    print(0)
else:
    for i in range (N-1):
        multi*=Alist[i+1]
        if(multi>1e18):
            print(-1)
            ibreak=1
            break;
    if(ibreak==0):
        print(multi)

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
A = LI()
ans = A[0]
if 0 in A:
    ans = 0
else:
    for i in range(1, N):
        if ans > 10**18:
            ans = -1
            break
        else:
            ans = ans*A[i]
if ans > 10**18:
    ans = -1
print(ans)