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):
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]
n = I()
li = LI()
ans = 1
if 0 in li:
  print(0)
else:
  for k in li:
    ans *= k
    if ans > 10**18:
      print(-1)
      break
  else:
    print(ans)

Solution (Python):

def main():
    MAX = 1_000_000_000_000_000_000
    n = int(input())
    nums = [int(_x) for _x in input().split()]
    if 0 in nums:
        print(0)
        return

    result = 1
    for num in nums:
        result = result * num
        if result > MAX:
            print(-1)
            return
    print(result)


main()

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

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

def solve():
    if 0 in A:
        return 0
    m = 1
    for a in A:
        m *= a
        if m > 10**18:
            return -1
    return m

print(solve())

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

if 0 in An:
  print(0)

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

  else:
    print(mult)

Solution (Python):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import deque
def main():
    n, *a = map(int, read().split())

    if 0 in a:
        print(0)
        sys.exit()
    a = deque(a)
    s = 10 ** 18
    r = 1
    while a:
        r = r * a.popleft()
        if r > s:
            print(-1)
            sys.exit()
    print(r)

if __name__ == '__main__':
    main()

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

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

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

print(A)

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

Solution (Python):
def main():
    n = int(input())
    a = [int(s) for s in input().split()]
    ans = 1
    if 0 in a:
        print(0)
        return
    for i in a:
        ans *= i
        if ans > (10 ** 18):
            ans = -1
            break
    print(ans)
main()

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

print(ans)

Solution (Python):
import sys  

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

if 0 in a:

    print(0)
else:

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

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

ans = 1

if 0 in a:
    print(0)

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

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

Solution (Python):
input()

result = 1
a = [int(x) for x in input().split()]
if 0 in a:
  print(0)
  exit()

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

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

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

Solution (Python):
n = 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 = input()
l = list(map(int,input().split()))
li = sorted(l)
n = 1

for i in li:
    n *= i
    if n > 1000000000000000000:
        break

if n > 1000000000000000000:
    print("-1")
else:
	print(n)

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

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

m = 1

A.sort()
if A[0] == 0:
    print(0)
    exit(0)


for a in A:
    m = m * a

    if m > 1000000000000000000:
        print(-1)
        exit(0)



print(m)

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

Solution (Python):

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

def swap(a,b):
	tmp=a
	a=b
	b=tmp
	return a,b

n=int(input())
A=input_array()
MAX=10**18
A=sorted(A)
ans=A[0]
for i in range(1,len(A)):
	ans*=A[i]
	if ans==0:
		break
	elif ans>MAX:
		ans=-1
		break
	else:
		pass

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

print(ans)

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

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

    

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

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

Solution (Python):
def main():
  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*=a[i]
      if ans >1000000000000000000:
        ans=-1
        break
  print(ans)
main()

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

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

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

Solution (Python):
n = int(input())
ms = list(map(int, input().split()))
iter_ms = iter(ms) 
r = 1
if 0 in ms:
  r = 0
else:
    for i in range(n):
        x = next(iter_ms)
        r *= x
        if r > 10 ** 18:
            r = -1
            break
        
print(r)

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

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
c=1
if not 0 in l:
    for li in l:
        c*=li
        if c > 10**18:
            
            break
    if c > 10**18:
        print('-1')
    else:
        print(c)
else:
    print(0)

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

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

ans = 1
for i in range(N):

    if ans * A[i] > 10**18:
        print(-1)
        exit()

    ans *= A[i]

print(ans)

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

if 0 in A:
  flag=False
  print(0)
else:
  for i in range(n):
    ans*=A[i]
    if ans>10**18:
      print(-1)
      flag=False
      break
    else:
      pass

if flag:
  print(ans)

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

a_sum = 1

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

    print(a_sum)

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

Solution (Python):
n=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(lambda a : int(a), input().split(" ")))
ans = 1
if A.count(0) > 0:
  ans = 0

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

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

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


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

    print(res)

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

Solution (Python):


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

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

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

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


        

print(ans)

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

ans = 1

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

print(ans)

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

Solution (Python):
def main():
    x = int(input())
    list1 = list(map(int, input().split(" ")))
    result = 1

    if 0 in list1:
        print(0)
        return

    for i in list1:
        result *= i
        if result > 1000000000000000000:
            print("-1")
            exit()
    print(result)

main()

Solution (Python):
def main():
    x = int(input())
    list1 = list(map(int, input().split(" ")))
    result = 1

    if 0 in list1:
        print(0)
        return 
    
    for i in list1:
        result *= i
        if result > 1000000000000000000:
            print("-1")
            exit()
    print(result)

main()

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

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

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

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

Solution (Python):

N = int(input())
A = list(map(int,input().split()))
flg = True
ans = 1
A.sort()
for a in A:
    ans *= a
    if ans > 10**18:
        flg = False
        break
    if ans == 0:
        break
if flg:
    print(ans)
else:
    print(-1)

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

Solution (Python):
import math
def facts(n):
    ans = []
    for  i in range(1, int(math.sqrt(n)+1)):
        if(n%i==0):
            ans.append(i)
            ans.append(n//i)
    ans = sorted(ans)
    return ans


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

Solution (Python):

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

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

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

Solution (Python):
n, *A = list(map(int, open(0).read().split()))

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

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

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

ans = 1

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

print(ans)

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

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

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

if 0 in c:
    print(0)
else:
    for i in c:
        ans = ans*i
        if ans <= mod:
            pass
        else:
            print('-1')
            break
    if ans <= mod:
        print(ans)

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

    if 0 in A:
        print(0)
        return

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


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 > pow(10,18):
    print(-1)
    exit()
print(ans)

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

Solution (Python):
def func(n, a):
	if(0 in a):
		return 0
	tmp = [0 for i in range(n)]
	tmp[0] = a[0]
	for i in range(1, n):
		tmp[i] = tmp[i-1] * a[i]
		if(tmp[i] > 10**18):
			return '-1'
	
	return str(tmp[-1])

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

Solution (Python):



def main():
    import sys

    input = sys.stdin.readline

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

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


if __name__ == '__main__':
    main()

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

if ls.count(0) > 0:
    result = 0
else:
    result = 1
    for i in ls:
        result *= i
        if result > 10 ** 18:
            result = -1
            break
print(result)

Solution (Python):
input()
ls = list(map(int, input().split(' ')))
ls.sort(reverse=True)

def main(ls):
    if ls.count(0) > 0:
        print(0)
        return
    result = 1
    for i in ls:
        result *= i
        if result > 10 ** 18:
            print(-1)
            return

    print(result)

main(ls)

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

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

for a in A:
    ans *= a
    if 1000000000000000000 < ans:
        print(-1)
        exit()

print(ans)

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

ans = 1

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

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

a = sorted(a, reverse=False)
ans = a[0]
for i in range(1, n):
    ans *= a[i]

    if ans > limit:
        print("-1")
        exit()
print(ans)

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

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

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

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

Solution (Python):
kazu = int(input())
word = input()
score = word.split()

maxn = 10**18
zero = 0
answer = 1
scin = [0]*kazu

for i in range(kazu):
    scin[i] = int(score[i])
    if scin[i] == 0:
        zero = 1
if zero == 1:
    answer = 0
else:
    for j in range(kazu):
        answer *= scin[j]
        if answer > maxn:
            answer = -1
            break
print(answer)

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

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

count = 1

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

else:
    print(count)

Solution (Python):
import sys

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

if A[0] == 0:
    print(0)
    sys.exit()

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

Solution (Python):
import sys

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

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

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

print(ans)

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

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

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

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


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

print(p)

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 > 10**18:
            print(-1)
            return
    print(prod)

main()

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

func()

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

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

res = 1

for n in L:
    res *= n
    if res > 10**18:
        print(-1)
        exit()
    
print(res)

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

l = 1
for i in range(18):
    l *= 10

ans = 1

for A_ in A:
    ans *= A_
    if ans > l:
        ans = -1
        break

if 0 in A: ans = 0

print(ans)

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

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

if rec:
    print(ans)
else:
    print('-1')

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

Solution (Python):
N = int(input())
Alst = list(map(int, input().split()))
ans = 1
rec = True
if 0 in Alst:
    print(0)

else:
    for i in range(N):
        ans = ans * Alst[i]
        if ans > 10**18:
            rec = False
            break

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

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

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

Solution (Python):
import sys

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

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

result = 1
for a in list(A):
    result *= a
    if (result > 10 ** 18):
        print(-1)
        sys.exit()

print(result)

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

ans = 1

for i in As:
    ans *= i
    ans = min(ans, 10**18 + 1)

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

else:
    print(ans)

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

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

flag = True
ans = 1
if 0 in lst:
  print(0)
else:
  for i in range(n):
    ans *= lst[i]
    if ans > 10 ** 18:
      flag = False
      break
  if flag:
    print(ans)
  else:
    print(-1)

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

    ans = 1
    if 0 in A:
        print("0")
        return
    for i in range(N):
        ans *= A[i]
        if ans > 1000000000000000000:
            ans = -1
            break
    print(ans)

if __name__ == "__main__":
    resolve()

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):
from typing import Collection


def multply(nums: Collection[int]) -> int:
    if 0 in nums:
        return 0

    result = 1

    for i in nums:
        result *= i
        if result > 10**18:
            return -1

    return result

count_num = int(input())
nums = map(int, input().split())
print(multply(list(nums)))

Solution (Python):
from typing import Iterable


def multply(nums: Iterable[int]) -> int:
    if 0 in nums:
        return 0

    result = 1

    for i in nums:
        result *= i
        if result > 10**18:
            return -1

    return result

count_num = int(input())
nums = map(int, input().split())
print(multply(list(nums)))

Solution (Python):
n = int(input())
a = sorted(list(map(int,input().split())), reverse = True)
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)
    quit()
s = 1
for x in a:
    s *= x
    
    if s > 1000000000000000000:
        print(-1)
        quit()
print(s)

Solution (Python):
import sys

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

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

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

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

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

Solution (Python):
a=int(input())
A=list(map(int,input().split()))
ans=1
if A.count(0)==0:
    for x in A:
      ans*=x
      if ans>10**18:
        break


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

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

Solution (Python):


def main():

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

    ans = 1

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

    else:
        ans = 0

    print(ans)


if __name__ == "__main__":
    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)
        exit()
print(ans)

Solution (Python):


















































global FLAG_LOG
FLAG_LOG = False


def log(value):
    
    FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    
    N = int(lines[0])
    
    values = list(map(int, lines[1].split()))
    
    
    
    
    
    
    

    result = 1
    if min(values) == 0:
        result = 0
    else:
        for value in values:
            result *= value
            if result > 10**18:
                result = -1
                break

    return [result]



def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2', '1000000000 1000000000']
        lines_export = [1000000000000000000]
    if pattern == 2:
        lines_input = ['3', '101 9901 999999000001']
        lines_export = [-1]
    if pattern == 3:
        lines_input = ['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']
        lines_export = [0]
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

Solution (Python):

from decimal import Decimal

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

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

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

print(ans)

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

flag = 0
for i in range(len(A)):
	if A[i]==0:
		flag =1

if flag == 1 :
	print("0")
else:
	x = 1
	for i in range(len(A)):
		x = x * A[i]
		if x > 10 ** 18:
			break
          
    
	if x > 10 ** 18:
		print("-1")
	else:
		print(x)

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

    if 0 in a:
        print(0)
        return

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

    print(ans)


main()