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


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    t = 1
    m = 10 ** 18
    for v in sorted(list(map(int, readline().split()))):
        t *= v
        if t > m:
            print(-1)
            exit()
    print(t)


if __name__ == '__main__':
    solve()

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

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

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

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

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

print(ans)

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

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

ans=int(1)

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

Solution (Python):
import sys

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

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

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

print(prod)

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

A = list(map(int, input().split()))
B = 0
C = 1

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

for i in range(N):
    C = C * A[i]
    if C > 1000000000000000000:
        print(-1)
        exit()

print(C)

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






import sys

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

max_ = 10 ** 18
N = ni()
A = na()
A.sort()
ans = 1
for i in range(N):
    ans *= A[i]
    if ans > max_:
        ans = -1
        break
print(ans)

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

const = 10**18

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

result = 1
for i in A:
    result *= i
    if result>const:
        print(-1)
        exit(0)
print(result)

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

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

print(product)

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


def ans():
    if 0 in A:
        return print(0)
    product = 1
    for num in A:
        product = product * num
        if product > 10 ** 18:
            return print(-1)

    print(product)


ans()

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

def foo(n):
    total = 1  
    for number in n:
        total = total * number
        if total > 10**18:
            print('-1')
            return
    print(total)
if '0' in str_list :
    print(0)
else:
    foo(n)

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

if 0 in A:
  print(0)
  exit()
else:
  flag = True
  prd = 1
  A.sort(reverse=True)
  for i in range(N):
    prd *= A[i]
    if prd > 10**18:
      flag = False
      break
if flag:
  print(prd)
else:
  print(-1)

Solution (Python):
import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

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

tmp = 0
res = 1

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

print(res)

Solution (Python):
N = int(input())
CONST = 10 ** 18
result = 1
numbers = list(map(int, input().split()))
if 0 in numbers:
    print(0)
    exit(0)
numbers.sort(reverse=True)
for i in numbers:
    result = result * i
    if result > CONST:
        print(-1)
        exit(0)
print(result)

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

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

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

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

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

ans = 1
if 0 in a:
    print(0)
    exit()
else:
    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()))

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

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

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

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

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

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

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

ans = 1
for i in a:
    ans *= i
    if(ans > 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 a:
    ans *= i
    if(ans > 10**18):
        print(-1)
        exit()

print(ans)

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

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

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

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

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

  print(ans)

Solution (Python):
n = int(input())
v = [int(i) for i in input().split()]
if v.count(0) > 0:
    print(0)
    exit(0)
res = 1
for i in v:
    res *= i
    if (res > 10**18):
        print(-1)
        exit(0)
print(res)

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

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

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

result = 1
for a in aa:
    result *= a
    if result > pow(10, 18):
        print('-1')
        exit(0)

print(result)

Solution (Python):
num=int(input())
line=input().split(" ")
checklis=sorted(line)
if checklis[0]=="0":
    res=0
else:
    res=1
    i=0
    while res<=1000000000000000000 and i<num:
        res *= int(line[i])
        i+=1
        
    if res>1000000000000000000:
        res= -1
 
print(res)

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

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

Solution (Python):
a=1
for i in[*open(0)][1].split():a=[-1,a:=a*int(i)][-1<a<=1e18]
print(a)

Solution (Python):
_,b=open(0);a=1
for i in b.split():a*=int(i);a=[-1,a][-1<a<=1e18]
print(a)

Solution (Python):
input();l=input().split();x=not"0"in l
for j in l:x=x*int(j)if 0<=x*int(j)<=1e18else-1
print(x)

Solution (Python):
a=1
for i in[*open(0)][1].split():a*=int(i);a=[-1,a][-1<a<=1e18]
print(a)

Solution (Python):
a,b=open(0);c=1;
for i in b.split():c=[-1,d:=int(i)*c][-1<d<=10**18]
print(c)

Solution (Python):
a=1
for i in[*open(0)][1].split():a*=int(i);a=[-1,a][-2<a-1<1e18]
print(a)

Solution (Python):
a,b=open(0);c=1;
for i in sorted(b.split()):c=[-1,d:=int(i)*c][-1<d<=10**18]
print(c)

Solution (Python):
input();l=input().split();x=1
for j in sorted(l):
  x*=int(j)
  if x>1e18:x=-1;break
print(x)

Solution (Python):
a=1;d=10**18
for i in[*open(0)][1].split():a=min(a*int(i),d+1)
print([a,-1][a>d])

Solution (Python):
input();l=input().split();x=1
for j in sorted(l):
  x*=int(j);
  if x>1e18:x=-1;break
print(x)

Solution (Python):
a,b=open(0);c=1;
for i in sorted(b.split()):c=[d:=int(i)*c,-1][10**18<d or c<0]
print(c)

Solution (Python):
input();l=input().split();x=not'0'in l
for j in l:
  x*=int(j);
  if x>1e18:x=-1;break
print(x)

Solution (Python):
for i in[*open(0)][(a:=1)].split():a*=int(i);a=[-1,a][0<=a<=10**18]
print(a)

Solution (Python):
i=input;i();l=i().split();x=not'0'in l
for j in l:
  x*=int(j);
  if x>1e18:x=-1;break
print(x)

Solution (Python):
for i in[*open(0)][(a:=1)].split():a*=int(i);a=[-1,a][0<=a<=10**18]
print(a)

Solution (Python):
a=1
for i in[*open(0)][1].split():a*=int(i);a=[-1,a][0<=a<=10**18]
print(a)

Solution (Python):
i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=int(j);
  if x>1e18:x=-1;break
print(x)

Solution (Python):
i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=int(j)
  if x>1e18:x=-1;break
print(x)

Solution (Python):
i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=int(j)
  if x>1e18:x=-1;break
print(x)

Solution (Python):
i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=int(j)
  if x>1e18:
    x=-1;break
print(x)

Solution (Python):
a,b=open(0);c=1;
for i in sorted(b.split()):
    c*=int(i)
    if c>10**18:c=-1;break
print(c)

Solution (Python):
input();a=1
for i in input().split():a*=int(i);a=[-1,a][0<=a<=10**18]
print(a)

Solution (Python):
i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=int(j)
  if x>1e18:
    print(-1);quit()
print(x)

Solution (Python):
i=input;i();l=i().split();x=not '0' in l
for j in l:
  x*=int(j)
  if x>1e18:
    print(-1);quit()
print(x)

Solution (Python):
input();a=1
for i in input().split():a*=int(i);a=[-1,a][0<=a<=eval('1'+'0'*18)]
print(a)

Solution (Python):
input();a=1;d=eval('1'+'0'*18)
for i in input().split():a*=int(i);a=[-1,a][-1<a<=d]
print(a)

Solution (Python):
i=input;i();l=i().split();x=not '0' in l
for j in l:
  x*=int(j)
  if x>1e18:
    print(-1);quit()
print(x)

Solution (Python):
a,b=open(0);c=1;
for i in sorted(b.split()):
    c*=int(i)
    if c>10**18:print(-1);exit()
print(c)

Solution (Python):
i=input;i();x=1;l=i().split()
if '0' in l:
  print(0)
  quit()
for j in l:
  x*=int(j)
  if x > 1e18:
    print(-1);quit()
print(x)

Solution (Python):
i = input
i()
x = 1
l = i().split()
if '0' in l:
    print(0)
    quit()
for j in l:
    x *= int(j)
    if x > 1e18:
        print(-1)
        quit()
print(x)

Solution (Python):
a=1;d=eval('1'+'0'*18)
for i in open(0).read().split()[1:]:a=min(a*int(i),d+1)
print([a,-1][a>d])

Solution (Python):
input();a=1;d=eval('1'+'0'*18)
for i in input().split():a=min(a*int(i),d+1)
print([a,-1][a>d])

Solution (Python):
input()
a=1
d=eval('1'+'0'*18)
for i in input().split():
  a=min(a*int(i),d+1)
print([a,-1][a>d])

Solution (Python):
input()
a=1
d=1000000000000000000
for i in input().split():
  a=min(a*int(i),d+1)
print([a,-1][a>d])

Solution (Python):
input()
a=1
d=1000000000000000000
for i in input().split():
  a*=[int(i),1][(a>d)*(i!='0')]
print([a,-1][a>d])

Solution (Python):
input()
a=1
d=1000000000000000000
for i in input().split():
  a=min(a*int(i), d+1)
print([a,-1][a>d])

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

ans = 1

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

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

print(ans)

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

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

print(ans)

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

As_sorted = sorted(As, reverse=True)
if As_sorted[-1] == 0:
    print(0)
else:
    flag = False
    res = 1
    for num in As_sorted:
        res *= num
        if res > 10**18:
            flag = True
            break            
    if flag:
        print(-1)
    else:
        print(res)

Solution (Python):
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())


n=int(input())
ar=lis()
if 0 in ar:
    print(0)
    quit()
p=1
for i in range(n):
    p*=ar[i]
    if p>10**18:
        print(-1)
        quit()
print(p)

Solution (Python):
import numpy as np
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 > 1000000000000000000:
    ans = -1
    break
print(ans)

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

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

VORDER = 10 ** 18
ans = 1

if 0 in n_l:
    ans = 0
else:
    for i in n_l:
        ans = i * ans
        if ans > VORDER:
            ans = -1
            break

print(ans)

Solution (Python):
def check() -> int:
    n = int(input())
    n_l = list(map(int, input().split()))

    VORDER = 10 ** 18
    ans = 1

    if 0 in n_l:
        ans = 0
    else:
        for i in n_l:
            ans = i * ans
            if ans > VORDER:
                ans = -1
                break
    return ans


if __name__ == '__main__':
    print(check())

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

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

A = sorted(list(map(int, input().split())))
assert len(A) == N
mul = 1
for a in A:
  mul *= a

  if a == 0:
    print(0)
    break
  if mul > (10 ** 18):
    print(-1)
    break
else:
  print(mul)

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

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

Solution (Python):
import sys
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, *A = map(int, read().split())
 
U = 10 ** 18
p = 1
for x in A:
    p *= x
    if p > U:
        p = U + 1
 
if p > U:
    print(-1)
else:
    print(p)

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

m = 10 ** 18
acc = 1
if 0 in AS:
  print(0)
  import sys
  sys.exit()

for i in AS:
  acc *= i
  if acc > m:
    print('-1')
    import sys
    sys.exit()

print(acc)

Solution (Python):

import sys

if __name__ == '__main__':
    N = int(input())
    li_A = list(map(int, input().split()))

    ans = li_A[0]

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

    for i in range(1, N):
        if ans * li_A[i] > 1000000000000000000:
            print('-1')
            sys.exit()
        else:
            ans *= li_A[i]

    print(ans)

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

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

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

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

Solution (Python):
import sys

N = int(input())
A = list(map(int, input().split()))
LA = len(A)
ans = A[0]
for j in range(LA):
    if A[j] == 0:
        print('0')
        sys.exit()

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

Solution (Python):

def main():
    n = int(input())
    As = list(map(int, input().split()))
    ans = 1
    if 0 in As:
        print(0)
        return

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

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

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

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

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

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

Solution (Python):


n = int(input())

nums = sorted(list(map(int, input().split())))

ans = 1
for i in range(n):
    ans *= nums[i]

    if ans == 0:
        print(0)
        exit()

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

print(ans)

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

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

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

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

    if 0 in n1:
        print(0)
        return

    sum = 1
    for i in n1:
        sum *= i
        if sum > 1000000000000000000:
            print(-1) 
            return 
    print(sum)

main()

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

ans=1

if A.count(0)>0:
    ans=0
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 = [int(v) for v in input().split()]
limit = 1000000000000000000
if 0 in a:
    print (0)
else:
    ans = 1
    num = 1
    for i in a:
        num *= i
        if num > limit:
            num = -1
            break
    ans = num
    print(ans)

Solution (Python):
def main() -> None:
    n = int(input())
    a_tuple = tuple(map(int, input().split()))

    if 0 in a_tuple:
        print(0)
        return
    boader = 10 ** 18
    answer = 1
    for a in a_tuple:
        answer *= a
        if answer > boader:
            print(-1)
            return
    print(answer)


if __name__ == '__main__':
    main()

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

sum=1

if 0 in A:
    print(0)
else:
    for i in range(N):
        sum *= A[i]  
        if sum >= int(1e18):
            break
    print(sum if sum<= int(1e18) else -1)

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

if 0 in As:
    print(0)
else:
    for i in range(N):
        ans*=As[i]
        if ans>int(1e18):
            break
    print(ans if ans<=int(1e18) else -1)

Solution (Python):
N = int(input())
line = [int(i) for i in input().split()]
sum = 1
line.sort(reverse=True)
if line[len(line) -1]== 0:
  print(0)
  exit()
for num in line:
  sum = sum * num
  if sum > 10 ** 18:
    print(-1)
    exit()
print(sum)

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

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

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

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

ans = 1

for i in a:
    if i == 0:
        ans = 0

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

print(ans)

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

print(ans)

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

lst = input().split()

ans = 1

if '0' in lst:
   ans = 0
else:
   for i in range(N):
      ans = ans * int(lst[i])
      if 10**18 < ans:
         ans = -1
         break

print(ans)

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

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

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

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

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

for i in a:
  if i == 0:
    ans = 0
    t = True

if t != True:
  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()))

mul=1
if 0 in A:print("0")
else:
    for i in range(N):
        mul*=A[i]
        if mul>pow(10,18):
            print("-1")
            break
        elif i==N-1:print(mul)

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

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

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

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

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

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

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

B = 1
C = 10 ** 18

for i in range(N):
    B = B * A[i]
    if B == 0:
        break
    elif B > C:
        B = -1
        break

print(B)

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

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

Solution (Python):
def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    if 0 in A:
        print(0)
        return

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

        if mul > 1e18:
            print(-1)
            return

    print(mul)


main()

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

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

    print(mul)

main()

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

Solution (Python):
def main():
    _ = int(input())
    A = [int(i) for i in input().split()]
    ans = 1
    if 0 in A:
        ans = 0
    else:
        for a in A:
            ans *= a
            if (10**18 < ans):
                ans = -1
                break
        if (10**18 < ans):
            ans = -1

    print(ans)


if __name__ == '__main__':
    main()

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

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

x = 1

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

print(x)

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

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

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

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

print(ans)

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

Solution (Python):
n = int(input())
lst = sorted(list(map(int, input().split())))
mult = 1

for i in lst:
    mult *= i
    if 10**18 < mult:
        print(-1)
        exit()
else:
    print(mult)

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

Solution (Python):
def main():
    _ = int(input())
    A = [int(i) for i in input().split()]
    if 0 in A:
        print(0)
    else:
        s = 1
        for a in A:
            s *= a
            if 10**18 < s:
                s = -1
                break
        if 10 ** 18 < s:
            s = 1
        print(s)


if __name__ == '__main__':
    main()

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

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

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

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

ans = 1
zero_count = A.count("0")

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

    print(ans)

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

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

print(str(ans))

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

if ans > max_limit:
  print(str(-1))
else:
  print(str(ans))

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