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
import math
import statistics
import datetime
import collections

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 1
    e = False
    for x in a:
        if ans > 1000000000000000000:
            print("-1")
            e = True
            break
        ans *= x
    if ans > 1000000000000000000 and e == False:
        print("-1")
    elif e == False:
        print(ans)

if __name__ == '__main__':
    main()

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

    if 0 in A:
        print(0)
        return

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

    print(ans)

main()

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

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

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

if 0 in a:
    print(0)
else:
    a.sort(reverse=True)
    ans = 1
    for i in a:
        ans *= i
        if ans > 1000000000000000000:
            print("-1")
            break
    else:
        print(ans)

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

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

Solution (Python):
def main():
	N = int(input())
	A = [int(i) for i in input().split()]
	
	if 0 in A:
		print(0)
		return
	
	res = 1
	top = 10 ** 18
	for a in A:
		res *= a
		if res > top:
			print(-1)
			return
	print(res)

if __name__ == "__main__":
	main()

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





def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))


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

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

	print(ans)


if __name__ == "__main__":
	main()

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

print(ans)

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

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

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

if ans == 10**18 + 1: ans = -1

print(ans)

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

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

s = 1

A = input().split()

if '0' in A:
  print(0)
else:
  for i in A:
    a = int(i)
    s *= a
    if s > 10**18:
      s = -1
      break
  print(s)

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


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

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

    if 0 in A:
        print(0)
        return

    S = 1
    for i in range(N):
        S *= A[i]
        if S > 10 ** 18:
            print(-1)
            return

    print(S)

main()

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)

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

Solution (Python):
n = int(input())
ans = 1;
tem = 0
ok = 1
s = input().split()
for i in s:
    if(int(i) == 0):
        tem = 1
        break
    if(ok == 1):
        ans *= int(i) 
        if(ans > 10**18):
            ok = 0
if(tem):
    print(0)
elif(ok):
    print(ans)
else:
    print("-1")

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

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

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


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

print(ans)

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


ans = 1

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

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

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


print(ans)

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

def main():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    lim = int(1e18)
    ans = 1
    for a in A:
        ans *= a
        if ans > lim:
            ans = -1
            break
        elif ans == 0:
            break
    print(ans)



if __name__ == "__main__":
    main()

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

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

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

main()

Solution (Python):

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


def f(list):
    a = 1
    for i in list:
        a = a*i
    return a


def main():

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


main()

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


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

ans = 1
upper = 10 ** 18

if 0 in set(a):
	print(0)
else:
	for i in range(n):
		ans *= a[i]
	
		if ans > upper:
			print(-1)
			exit()

	print(ans)

Solution (Python):
n = int(input())
ary = list(map(int,input().split()))
import cmath
if 0 in ary:
    print(0)
else:
    multiple = 1
    while ary:
        multiple *= ary.pop()
        if multiple > 10**18:
            multiple = -1
            break
    print(multiple)

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

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

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

print(ans)

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

main ()

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

Solution (Python):


import copy
import random
import bisect 
import fractions 
import math
import sys
import collections

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

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = LI()
A.sort()
ans = 1
for a in A:
    ans *= a
    if ans > 10**18:
        ans = -1
        break

print(ans)

Solution (Python):

N = int(input()) 

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












def main():
    if 0 in A:
        print(0)
        return

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

        if output > (10 ** 18):
            print(-1)
            return

    print(output)

main()

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

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

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

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

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

mx = 1e18
pr = 1
done = True
zero = False

for i in a:
	if i == 0:
		zero = True

if zero == False:
	for i in a:
		pr = pr*i
		if pr > mx:
			break
else:
	pr = 0
if zero or pr <= mx:
	print(pr)
else:
	print(-1)

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

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

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

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

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

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

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

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

Solution (Python):

times= int(input())
nums= list(map(int, input().split()))
a= 1
if 0 in nums:
  print(0)
  exit()
for i in nums:
  a*= i
  if a > 10**18:
    print('-1')
    exit()
else:
  print(a)

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

Solution (Python):
def main():
    n = int(input())
    ps = [int(x) for x in input().split()]
    ps.sort()
    a = 1
    for p in ps:
        a *= p
        if a == 0:
            print(0)
            return
        if a > 10 ** 18:
            print(-1)
            return
        
    print(a)

    
main()

Solution (Python):


import numpy as np

def main():
    n = int(input())
    l = list(map(int,input().split()))
    if 0 in l:
        print(0)
        exit()
    pro=1
    for num in l:
        pro = pro*num
        if pro > 10**18:
            print(-1)
            exit()
    else:
        print(pro)

if __name__ == '__main__':
    main()

Solution (Python):
a1 = int(input())
b2 = input().split(" ")

def check(a , b):
  score = 1
  if '0' in b:
    return 0
  else:
    for i in range(a):
      score *= int(b[i])
      if score > 10 ** 18:
        return -1
    
    return score

print(check(a1 , b2))

Solution (Python):
def ans(a):
    limit = 10**18
    acm=1
    if 0 in a:
        return 0

    for i in a:
        acm *= i
        if acm > limit:
            return -1
    return acm
    
n = int(input())
a = input()
a = list(map(int,a.split()))

print(ans(a))

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

product = 1

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

print(product)

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

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

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

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

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

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

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

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

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

Solution (Python):
N = int(input())
lst = sorted([int(x) for x in input().split() if x != "1"], reverse=True)

if len(lst) == 0:
    print(1)
    exit()
if lst[-1] == 0:
    print(0)
    exit()

ret = 1
for x in lst:
    ret *= x
    if ret > 10 ** 18:
        print(-1)
        exit()

print(ret)

Solution (Python):
n,*a=map(int,open(0).read().split())
if min(a)==0:
    print(0)
else:
    s=1
    for i in range(len(a)):
       s=s*a[i]
       if s>10**18:
           print(-1)
           break
    else:
        print(s)

Solution (Python):
n,*a=map(int,open(0).read().split())
if min(a)==0:
    print(0)
else:
    s=1
    for i in range(len(a)):
       s=s*a[i]
       if s>10**18:
           print(-1)
           break
    else:
        print(s)

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

for i in a:
    if i=='0':
        print("0")
        quit()
ans=1
p = 1000000000000000000 / ans
for i in a:
    
    if(int(ans)<=p):
        ans=ans*int(i)
        if(int(ans)>p):
            print("-1")
            quit()
    else:
        print("-1")
        quit()
print(ans)

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

res = 1

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

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

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

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

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

print(prod)

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

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

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

while len(arr) > 1:
    m = len(arr)
    if m & 1:
        arr.append(1)
        m += 1

    left, right = arr[:m // 2], arr[m // 2:]
    arr = [x * y for x, y in zip(left, right)]

x = arr[0]
if x > 10 ** 18:
    print(-1)
else:
    print(x)

Solution (Python):
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    n = int(readline())
    a = list(map(int, readline().split()))
    a.sort()
    ans = 1
    for aa in a:
        ans *= aa
        if ans > 10 ** 18:
            print(-1)
            break
    else:
        print(ans)


if __name__ == '__main__':
    main()

Solution (Python):



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


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

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

if min(a) ==0:
    ans =0
else:
    order =0
    for i in a:
        order = order+len(str(i))-1

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

Solution (Python):
import sys
N = int(input())
a = list(map(str, input().split()))
total = 1

if '0' in a:
    print('0')
    sys.exit()
for i in a:
    total *= int(i)
    if total > 10**18:
        print('-1')
        sys.exit()
print(total)

Solution (Python):

N = int(input())
A = [int(a) for a in input().split()]
if 0 in A:
  print(0)
  exit() 
ans = 1
for i in range(N):
  ans *= A[i]
  if ans > 10 ** 18:
    print('-1')
    exit()
print(ans)

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

x =1

if min(a) ==0:
    ans =0
else:
    order =0
    for i in a:
        order = order+len(str(i))-1

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

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

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

Solution (Python):

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

def ans():
    global N,A
    for i in range(N):
        if A[i]==0:
            return 0
    tmp = 1
    for i in range(N):
        tmp *= A[i]
        if tmp>10**18:
            return -1
    return tmp

print(ans())

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



a.sort()
r = 1
t = 10 ** 18
for x in a:
  r *= x
  if r > t:
    break
if r <= t:
  print(r)
else:
  print(-1)

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

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

Solution (Python):
max_value = 10 ** 18


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

if 0 in A:
    result = 0
else:
    result = A.pop(0)
    for i in A:
        result = result * i
        if result > max_value:
            result = -1
            break

print(result)

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

if Nlist.count(0)>=1:
    total = 0
    print(total)
    sys.exit()


for i in range(N):
    total = total*Nlist[i]
    if total > 1000000000000000000:
        total = -1
        break

print(total)

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

Solution (Python):
n = int(input())
ar = list(map(int,input().split()))
ans = 1
z = 0
p = 0
for i in ar:
    if ans != -1:
        ans *= i
    if i == 0:
        z+=1
    if ans > 1e18:
        ans = -1
if z:
    ans = 0
print(ans)

Solution (Python):
n = int(input())
A = sorted(list(map(int, input().split())))
if A[0] == 0:
    print(0)
    exit()

now = 1
for a in A:
    now *= a
    if now > int(1e18):
        print(-1)
        exit()

print(now)

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

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

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

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

Solution (Python):

n = int(input())

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

if 0 in arg:
    ans = 0
else:
    for m in arg:
        ans *= m

        if ans > 1000000000000000000:
            ans = -1
            break

print(ans)

Solution (Python):
import math
n = int(input())
la = [int(i) for i in input().split()]
la.sort(reverse=True)
ans = 1

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

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

Solution (Python):
def main():

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

	d=1
    
	

	for b in a:
		d=d*b
		if d>10**18:
			print("-1")
			return
	print(d)

main()

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

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):
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


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


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


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    A = LIST()
    ans = 1
    A.sort()
    for x in A:
        ans *= x
        if ans > 10**18:
            print(-1)
            exit()
    print(ans)


if __name__ == '__main__':
    main()

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

minA = min(A)
minA = int(minA)
M = 10 ** 18

Y = 0
if minA != 0:
    Y = 1
    for i in range(N):
        X = A[i]
        X = int(X)
        Y = Y * X
        if Y > M:
            break


if Y > M:
    print(-1)
else:
    print(Y)

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

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

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

  if 0 in a:
    print(0)
    return
  
  ans = a[0]
  a2 = a[1:]
  for i in a2:
    ans = ans * i
    if ans > 1000000000000000000:
      print(-1)
      return

  print(ans)

main()

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

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

a=1
for i in range(N):
  if(P[i]==0):
    a=0
    break
if a!=0:
  for i in range(N):
    a*=P[i]
    if(a>1000000000000000000):
      a=-1
      break
print(a)

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

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

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

print(c)

Solution (Python):

"""AtCoder Beginner Contest 169: B - Multiplication 2
https://atcoder.jp/contests/abc169/tasks/abc169_b
"""


def calc(As):
    MAX = 10 ** 18
    ans = 1
    for n in As:
        ans *= n
        if MAX < ans:
            return -1
    return ans


def main():
    N = int(input())
    As = list(map(int, input().split()))

    if As.count(0) != 0:
        print(0)
    else:
        print(calc(As))


if __name__ == '__main__':
    main()

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

Solution (Python):
from math import log10
from functools import reduce
from operator import mul

N = int(input())

nums = [int(s) for s in input().rstrip().split()]

def product(nums):
  limit = 10**18
  result = 1
  if 0 in nums:
    return 0
  for n in nums:
    result *= n
    if result > limit:
      return -1
  return result
    
print(product(nums))

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

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

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

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

if __name__ == '__main__':
    main()

Solution (Python):
inp = input()
inp = input()
 
def mp(nums):
  if 0 in nums:
    print(0)
    return
  n = 1
  limit = 10**18
  for num in nums:
    n *=num
    if n > limit:
      print(-1)
      return
  print(n)
 
mp([int(x) for x in inp.split(" ")])

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

Solution (Python):
N = int(input())
Ali = list(map(int,input().split()))
r = Ali[0]

for i in range(1,N):
  r *= Ali[i]
  if r > 10**18:
    r = -1
  if r < 0:
    r = -1
  
print(r)

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

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

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

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

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

a.sort()

if a[0] == 0:
    print(0)
else:
    m = 1
    i = 0
    while m < 10**18:
        m *= a[i]
        if m > 10**18:
            print(-1)
            sys.exit()
        i += 1
        if i == n:
            print(m)
            sys.exit()

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

import sys


def solve(N: int, A: "List[int]"):
    ans = 1
    threshold = 1000000000000000000
    if 0 in A:
        print(0)
        exit()

    for x in A:
        ans *= x
        if (ans > threshold):
            print(-1)
            exit()
    print(ans)



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)

if __name__ == '__main__':
    main()

Solution (Python):
def process():
  count = int(input())
  nums_str = input().split()
  nums_int = []
  for strn in nums_str:
    nums_int.append(int(strn))

  if 0 in nums_int:
    result = 0
    return result
  else:
    result = 1
    for intn in nums_int:
      result *= intn
      if result > 10**18:
        result = -1
        return result
    return result
    
print(process())

Solution (Python):
def process():
  count = int(input())
  nums_str = input().split()
  nums_int = []
  for strn in nums_str:
    nums_int.append(int(strn))

  if 0 in nums_int:
    result = 0
    return result
  else:
    result = 1
    for intn in nums_int:
      result *= intn
      if result > 1000000000000000000:
        result = -1
        return result
    return result
    
print(process())