Problem:
 Score : 200 points    Problem Statement Given N integers A_1, ..., A_N , compute A_1 \times ... \times A_N .  However, if the result exceeds 10^{18} , print -1 instead.      Constraints  2 \leq N \leq 10^5  0 \leq A_i \leq 10^{18}  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  A_1  ...  A_N       Output Print the value A_1 \times ... \times A_N as an integer, or -1 if the value exceeds 10^{18} .        Sample Input 1 2
1000000000 1000000000      Sample Output 1 1000000000000000000  We have 1000000000 \times 1000000000 = 1000000000000000000 .       Sample Input 2 3
101 9901 999999000001      Sample Output 2 -1  We have 101 \times 9901 \times 999999000001 = 1000000000000000001 , which exceeds 10^{18} , so we should print -1 instead.       Sample Input 3 31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0      Sample Output 3 0

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



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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
c = 1
flag = True
for _ in a:
    c *= _
    if c > 10**18:
        flag = False
        c = 1
    if c == 0:
        print(0)
        quit()
if flag:
    print(c)
else:
    print(-1)

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

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

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

if A.count(0):
    print(0)
    import sys
    sys.exit()

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

print(ans)

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

Solution (Python):
n = int(input())
a = sorted(list(map(int,input().split())))
m = 1
threshold = 1e18
for i in a:
    m *= i
    if m > threshold:
        m = -1  
        break
print(m)

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

Solution (Python):
N = int(input())
numbers = [int(x) for x in input().split()]
 
if any ([x == 0 for x in numbers]):
    t = 0
else:
    t = 1
    for i in numbers:
        t *= i
        if t > 10 ** 18:
            t = -1
            break
print(t)

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

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

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

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

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

Solution (Python):
import sys

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

ans = 1

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

for i in l:
  ans *= i
  if ans > 1000000000000000000:
    print(-1)
    sys.exit()
print(ans)

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

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

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

print(prod)

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

Solution (Python):


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

Solution (Python):
n = int(input())
lst = [int(x) for x in input().split()]
if lst.count(0) > 0:
  print("0")
else:
  product = 1
  for i in range(n):
    product *= lst[i]
    if product > 1000000000000000000:
      product = -1
      break
  print(str(product))

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

Solution (Python):
n = int(input())
data = list(map(int, input().split()))
data.sort()
data.reverse()

while data[-1] == 0:
  data.insert(0,0)
  data.pop(-1)
 
ans = 1

for d in data:
  ans = ans * int(d)
  if ans > 10**18 or ans == 0:
    break
 
if ans > 10**18:
  print(-1)
else:
  print(ans)

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

Solution (Python):
n = int(input())
nums = sorted(list(map(int,input().split())), reverse=True)

res = 1

if 0 in nums:
  print(0)
  exit()
  
for i in range(n):
  res = res * nums[i]
  if res <= 10**18 :
    continue
  else:
    res = -1
    break
print(res)

Solution (Python):
import sys
N = int(input())
num_list = [int(i) for i in input().split()]
if 0 in num_list:
  print(0)
else:
  mul = 1
  for a in num_list:
    mul *= a
    if mul > 10**18:
      print(-1)
      sys.exit()
  print(mul)

Solution (Python):
def main():
    N=int(input())
    
    Array=list(map(int, input().split(' ')[:N]))
    if 0 in Array:
        print(0)
        return
    mul=1
    for i in Array:
        mul*=i
        if mul > 1000000000000000000:
            print(-1)
            return
    
    print(mul)
main()

Solution (Python):


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

ans = 1
for ai in a:
  if not ans > 10**18:
    ans *= ai
  elif ai == 0:
    print(0)
    exit()

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

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
 
if 0 in a: 
    ans = 0
else:
    ans = 1
    for ai in a:
        ans *= ai
        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)

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

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

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

    if 0 in a:
        print(0)
        return

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

    print(res)

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

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

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

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

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

    if 0 in A:
        print(0)
        return

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


if __name__ == "__main__":
    main()

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

  for a in A:
    if a == 0:
      print(0)
      return

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

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

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

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

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

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:
            break
    
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):
def main():
    n = int(input())
    ary = [int(i) for i in input().split()]
    ary = sorted(ary)

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

    prod = 1
    for i in reversed(range(n)):
        prod *= ary[i]
        if prod > 1000000000000000000:
            print(-1)
            return

    print(prod)
main()

Solution (Python):
def main():
    n = int(input())
    ary = [int(i) for i in input().split()]
    ary = sorted(ary)

    from math import log2
    lt = log2(10**18)

    if ary[0] == 0:
        print(0)
        return
      
    if any(log2(ary[i]) > lt / (n-i) for i in range(n)):
        print('-1')

    else:
        prod = 1
        for i in range(n):
            prod *= ary[i]
        if prod > 10**18:
            print(-1)
        else:
            print(prod)

main()

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

Solution (Python):
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
def dmain():
    sys.setrecursionlimit(1000000)
    threading.stack_size(1024000)
    thread = threading.Thread(target=main)
    thread.start()







abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007

inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]
def getKey(item): return item[1] 
def sort2(l):return sorted(l, key=getKey,reverse=True)
def d2(n,m,num):return [[num for x in range(m)] for y in range(n)]
def isPowerOfTwo (x): return (x and (not(x & (x - 1))) )
def decimalToBinary(n): return bin(n).replace("0b","")
def ntl(n):return [int(i) for i in str(n)]
def ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))
def ceil(x,y):
    if x%y==0:
        return x//y
    else:
        return x//y+1
def powerMod(x,y,p):
    res=1
    x%=p
    while y>0:
        if y&1:
            res=(res*x)%p
        y=y>>1
        x=(x*x)%p
    return res
def gcd(x,y):
    while y:
        x,y=y,x%y
    return x
def isPrime(n):
    if(n<=1): return False
    if(n<=3): return True
    if(n%2==0 or n%3==0): return False
    i=5
    while(i*i<=n) : 
        if(n%i==0 or n%(i+2)==0) : 
            return False
        i=i+6
    return True
def read():
    sys.stdin = open('input.txt', 'r')  
    sys.stdout = open('output.txt', 'w') 

def main():
    n=int(input())
    prod = 1
    arr=list(map(int,input().split()))
    if(0 in arr):
        print(0)
        return
    for i in arr:
        prod = prod*i
        if(prod>1e18):
            print(-1)
            return
    print(prod)

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
    main()

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

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

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

if  __name__ == "__main__":
    main()

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

Solution (Python):
n = int(input())
*a, = map(int, input().split())
set_a = set(a)
if 0 in set_a:
  print(0)
  exit()
  
res = 1
for elem in a:
  if elem == 0:
    print(0)
    exit()
    
  res *= elem
  
  if res > 10 ** 18:
    print(-1)
    exit()
print(res)

Solution (Python):
n = int(input())
*a, = map(int, input().split())
set_a = set(a)
if 0 in set_a:
  print(0)
  exit()
  
res = 1
for elem in a:
  res *= elem
  if res > 10 ** 18:
    print(-1)
    exit()
print(res)

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

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

ans = 1
lim = int(1e18)

if 0 in arr:
    print(0)

else:
    for x in arr:
        ans *= x
        if ans > lim:
            ans = -1
            break 

    print(ans)

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

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

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

product = 1

for num in nums:
    product *= num

    if product > 1e18:
        product = -1
        break

if 0 in nums:
    product = 0

print(product)

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

Solution (Python):
n=int(input())
v=pow(10,18)
inp = list(map(int,input().split()))
prod=1
from collections import Counter
c=Counter(inp)
if c[0]>=1:
  print (0)
else:
  flag=1
  for item in inp:
    prod*=item
    if prod>v:
      flag=0
      print (-1)
      break
  if flag==1:
    print (prod)

Solution (Python):
x = input()
y = input().split()
ord = sorted(y)
t = 1
for z in ord:
    t *= int(z)
    if (int(z) == 0):
        break
    if t > 1000000000000000000:
        print(-1)
        exit(0)
print(t)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
k = 1
flag = True
for i in a:
  k *= i  
  if k > 10 ** 18:
    flag = False
    break

if 0 in a:
  print(0)
elif flag:
  print(k)
else:
  print(-1)

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

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

Solution (Python):
import sys

n = int(input())
an = [int(num) for num in input().split()]

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

answer = 1
check = 10**18
for i in range(len(an)) :
  answer *= an[i]
  if answer > check:
    print(-1)
    sys.exit()

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

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


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

if __name__ == "__main__":
    main()

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

print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
t = 1
a = 10 ** 18

if 0 in A:
    t = 0
else:
    for i in A:
        t *= i
        if t > a:
            break

if t > a:
    print("-1")
else:
    print(t)

Solution (Python):

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

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):
n=int(input())
l=list(map(int,input().split()))
if min(l)== 0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
        if s>10**18:
            s=-1
            break
    print(s)

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

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

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

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

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):
N = int(input())
A = list(map(int, input().split(' ')))

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

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

    print(ans)

main()

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

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

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

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

Solution (Python):
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N = I()

MAX = 10**18
result = 1
A = FLI()
if 0 in A:
    print(0)
    exit()
    
for i in A:
    result *= int(i)
    if result > MAX:
        print(-1)
        exit()

print(result)

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

Solution (Python):


n=int(input())

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


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

Solution (Python):
import numpy as np


def getVar():
    return map(int, input().split())
def getArray():
    return list(map(int, input().split()))
def getNumpy():
    return np.array(list(map(int, input().split())), dtype='int64')

def main():
    N = getVar()
    A = getArray()

    m = 1
    upper = 1000000000000000000

    if 0 in A:
        print(0)
        return
        
    for a in A:
        m *= a
        if m > upper:
            print(-1)
            return

    print(m)

main()

Solution (Python):
import numpy as np


def getVar():
    return map(int, input().split())
def getArray():
    return np.array(list(map(int, input().split())))

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

    m = 1
    upper = 1000000000000000000

    if 0 in A:
        print(0)
        return
        
    for a in A:
        m *= a
        if m > upper:
            print(-1)
            return

    print(m)

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

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

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

def main(A):
  if 0 in A:
    print(0)
    return
  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  print(prod)
    
main(A)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
product = 1
if A[0]==0:
  print(0)
else:
  for i in range(len(A)):
    product *= A[i]
    if product > 10**18:
      print(-1)
      break
if product <= 10**18 and A[0]!=0:
  print(product)

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

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

Solution (Python):
import sys
def main():
  u = 1  
  n = int(input())
  a = list(map(int,(input().split())))
  
  if 0 in a:
    print(0)
    sys.exit()
	
  for i in a:
    u *=i
    if u > 1000000000000000000:
      print(-1)
      sys.exit()

  print(u)


main()

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

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

print(ans)

Solution (Python):
import sys
n = int(sys.stdin.readline())
li = list(map(int, sys.stdin.readline().split()))
if 0 in li:
    print(0)
    exit()
res = 1
for i in range(n):
    res *= li[i]
    if res > 1000000000000000000:
        print(-1)
        exit(0)
print(res)

Solution (Python):
N = int(input())
A = list(map(int, input().split(' ')))
ans = 1
if 0 in A:
    ans = 0
else:
    for l in A:
        ans *= l
        if 10**18 < ans:
            ans = -1
            break
print(ans)

Solution (Python):

class Calc():
  def multi(self,x,y):
    x, y, sign, rslt = str(x)+".", str(y)+".",1 ,""
    if x[0]=="-":
      sign*=-1
      x=x[1:]
    if y[0]=="-":
      sign*=-1
      y=y[1:]
    x,y=x.split("."),y.split(".")
    x2 = [int(x[1][-i-1]) for i in range(len(x[1]))] + [int(x[0][-i-1]) for i in range(len(x[0]))]
    y2 = [int(y[1][-i-1]) for i in range(len(y[1]))] + [int(y[0][-i-1]) for i in range(len(y[0]))]
    sum=[0]*(len(x2)+len(y2))
    for i, p in enumerate(y2):
      for j, q in enumerate(x2):
        K=i+j
        sum[K]+=p*q
        while sum[K]>9:
          sum[K+1], sum[K] = sum[K+1] + int(sum[K]/10) , sum[K]%10
          K+=1
    for i in range(len(sum)): rslt+=str(sum[-i-1])
    dclen=len(x[1])+len(y[1])
    if dclen>0: rslt=rslt[:len(rslt)-dclen]+"."+rslt[len(rslt)-dclen:len(rslt)]
    for i in range(len(rslt)):
      if rslt[i]=="0" and (rslt[i+1] if i<len(rslt)-1 else ".")!="." : continue
      else:
        rslt=rslt[max(i,0):]
        break
    return ("-" if sign==-1 else "")+rslt
  
  def max_2(self,x,y):
    X,Y=x,y
    x, y, rslt = str(x)+".", str(y)+".", ""
    if x[0]=="-" and y[0]!="-": return Y
    if x[0]!="-" and y[0]=="-": return X
    if x[0]=="-" and y[0]=="-": return 
    x,y=x.split("."),y.split(".")
    size0,size1 = max(len(x[0]),len(y[0])), max(len(x[1]),len(y[1]))
    x[0],y[0] = "0"*( size0 - len(x[0]) ) + x[0] , "0"*( size0 - len(y[0]) ) + y[0]
    x[1],y[1] = x[1] + "0"*( size1 - len(x[1]) ) , y[1] + "0"*( size1 - len(y[1]) )
    for s in [0,1]:
      for i in range( size0 if s==0 else size1 ):
        p,q=int(x[s][i]),int(y[s][i])
        if p==q: continue
        elif p>q: return X
        elif p<q: return Y
    return X

N=int(input())
A=input().split()
R,lim="1","1"+"0"*17+"1"
if "0" in A: print(0)
else:
  for i in range(N): 
    R=Calc().multi(R,A[i])
    if Calc().max_2(lim,R)==R:
      print(-1)
      break
  else:
    print(R)

Solution (Python):






N = int(input())
ans = 1
limit = 10 ** 18
length = 0

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

A0 = set(A)
if 0 in A0:
    ans = 0
else:
    pass

for n in range(N):
    ans = ans * A[n]
    if ans == 0:
        break
    elif ans > limit:
        length = 1
        break
    else:
        pass

if length == 1:
    print(-1)
else:
    print(ans)

Solution (Python):




N = int(input())
ans = 1
limit = 10 ** 18
length = 0

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

A0 = set(A)
if 0 in A0:
    ans = 0
else:
    pass

for n in range(N):
    ans = ans * A[n]
    if ans == 0:
        break
    elif ans > limit:
        length = 1
        break
    else:
        pass

if length == 1:
    print(-1)
else:
    print(ans)

Solution (Python):
N = int(input())
ans = 1
lim = 10 ** 18
l = 0

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

A0 = set(A)
if 0 in A0:
  ans = 0
else:
  pass

for n in range(N):
  ans = ans * A[n]
  if ans == 0:
    break
  elif ans > lim:
    l = 1
    break
  else:
    pass

if l == 1:
  print(-1)
else:
  print(ans)