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 = map(int,input().split())
 
x = sorted(a)
ans = 1
for i in x:
    ans *= i
    if(ans == 0):
        break
    if(ans > 1e18):
        break
if(ans > 1e18):
    print(-1)
else:
    print(ans)

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

ans = 1

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

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

a.sort()
if a[0]==0:
    print(0)
else:
    a.sort(reverse=True)
    

    ans=1
    for i in range(n):
        ans=a[i]*ans
        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()))

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

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

Solution (Python):
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

n = I()
a = LI()

if (0 in a):
    ret = 0
else:
    ret = a[0]
    for i in range(1,n):
        ret = ret * a[i]
        if(ret > 1000000000000000000):
            ret = -1
            break

print(ret)

Solution (Python):
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue

Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

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

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

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

ans = 1

a = [int(x) for x in input().split()]
for i in range(n):
    ans = min(10 ** 30, ans * a[i])

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

Solution (Python):
if __name__ == "__main__":
    N = int(input())
    num_list = list(map(int, input().split()))
    ans = 1
    MAX = 1e18
    for i in num_list:
        ans = ans*i
        if ans > MAX:
            ans = -1
            break
    if 0 in num_list:
        print(0)
    else:
        print(ans)

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

Solution (Python):
import sys

N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))

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

Solution (Python):
import math
import bisect



n=int(input())
l=[int(x) for x in input().split()]
p=1
M=10**18
f=0
if 0 in l:
	print(0)
else:	
	for i in range(n):
		p*=l[i]
		if p>M:
			print(-1)
			f=1
			break
	if f==0:
		print(p)

Solution (Python):
from math import log10 as log

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

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

if any(a == 0 for a in As):
    print(0)
    sys.exit()

mul = 1
for a in As:
    mul *= a
    if mul > 1e+18:
        print(-1)
        sys.exit(0)
print(mul)

Solution (Python):

n=int(input())
a=sorted(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())
lst=list(map(int, input().split()))
ans = 1
if 0 in lst:
    print(0)
    exit()

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


print(ans)

Solution (Python):
n = int(input())
s = str(input())
d = s.split()
mod = 10 ** 18
ans = int(d[0])
d.pop(0)
z = 0
if '0' in d:
	print(0)
else:
	for i in d:
		i = int(i)
		ans *= i
		if ans > mod:
			print(-1)
			z = 1
			break
	if z == 1:
		pass
	else:
		print(ans)

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

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

ans = 1

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


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

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

flag = 1

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

if 0 in lis:
    flag = 2

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

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

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

Solution (Python):


import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        
        
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]
    a = [int(e) for e in lines[1].split(' ')]

    return (n, a)


def solve(n, a):
    
    m = int(10 ** 18)
    a.sort()
    result = 1
    for i in range(n):
        result = result * a[i]
        if result > m:
            result = -1
            break

    return result    


def main():
    
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

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

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

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

border_num = 10 ** 18


if 0 in nums:
    output = 0
else :
    output = 1
    for _ in nums :
        output *= _
        if output > border_num:
            output = -1
            break
            
print(output)

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

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

Solution (Python):
import sys
n = int(input())
A = [int(n) for n in input().split()]
total = 1
if 0 in A:
  print(0)
  sys.exit()
for a in A:
  total *=a
  if total > 10**18:
    print(-1)
    sys.exit()
print(total)

Solution (Python):

import sys
N = int(input())
inf = 10**18
a = list(map(int, input().split()))
ans = a[0]
if 0 in a:
    print("0")
    sys.exit()
for i in range(1,len(a)):
    ans = ans * a[i]

    if ans > inf:
        print("-1")
        sys.exit()
print(ans)

Solution (Python):
import numpy as np






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

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

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

if __name__ == '__main__':
    main()

Solution (Python):
import itertools
import math

N=int(input())
array = list(map(int, input().strip().split()))

ans=1

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

if 0 in array:
    ans=0

print(ans)

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

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

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

Solution (Python):
import sys
n = int(input())
s = input().split()

result = 1

if "0" in s:
    print(0)
    sys.exit()
for i in range(n):
    result = result * int(s[i])
    if result > (10 ** 18):
        print(-1)
        sys.exit()

print(result)

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

output = A[1]
for i in range(1, N):
    output = output * A[i]
    if output > pow(10, 18):
        output = -1
        break

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

print(output)

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

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

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

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

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

now = 1
ok = False

a.sort()

for i in range(len(a)):
	now *= a[i]
	if now > 1000000000000000000 :
			print(-1)
			ok = True
			break

if ok == False:
	print(now)

Solution (Python):
import math
import sys
import collections
from collections import defaultdict
from sys import stdin, stdout

sys.setrecursionlimit(10**9)
n=int(input())
arr=list(map(int,input().split()))
mult=1
flag=0
if 0 in arr:
    print(0)
else:
    for i in range(n):
        mult*=arr[i]
        if mult>10**18:
            flag=1
            break

    if flag==0:
        print(mult)
    else:
        print(-1)

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

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

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


n = int(input())
up = 10**18
l = list(map(int, input().split()))

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

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

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

ans = 1;
for num in num_list:
    ans *= num
    if ans > 1000000000000000000:
        ans = -1
        break

if 0 in num_list:
    ans = 0

print(ans)

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

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

Solution (Python):
def main():
    _ = input()
    lst_a = [int(v) for v in input().split(' ')]
    ans = int(1)
    for a in lst_a:
        if a == 0:
            print('0')
            return
    for a in lst_a:
        ans *= a
        if ans > 1e18:
            ans = -1
            break
    print(int(ans))


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
if min(A) == 0:
    curr = 0
else:
    curr = 1
    for val in A:
        curr *= val
        if curr > 10**18:
            curr = -1
            break

print(curr)

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

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

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

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

Solution (Python):
n = int(input())
lst = [int(i) for i in input().split()]
if(lst.count(0) > 0):
    print(0)
    exit()

ans = 1
for i in lst:
    ans *=  i
    if(ans > 1.0e+18):
        print(-1)
        exit()

print(ans)

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

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

print(ans)

Solution (Python):
import sys


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

ans = 1

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

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

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

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

ans = 1
if 0 in A:
    ans = 0
else:
    for a in A:
        ans *= a
        if ans > 10**18:
            ans = -1
            break

print(ans)

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

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

    if NO==0:
        print(ans)

Solution (Python):


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

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

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

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

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

  
Flag = True
t = A[0]
i = 1
while Flag == True and i < N:
  t = t*A[i]
  if t > 10**18:
    Flag = False
  i += 1
if 0 in A:
  print(0)
elif Flag == True:
  print(t)
  
else:
  print(-1)

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

Solution (Python):

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

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

ans = 1
ans_over = 0

for x in A:
        ans *= x
        if ans > 10 ** 18:
                ans = 1
                ans_over = 1

if ans_over == 1:
        if ans != 0:
                ans = -1


print(ans)

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

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

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 > 1000000000000000000:
            print(-1)
            exit()
    print(ans)

Solution (Python):
n = int(input())
a = [int(arg) for arg in input().split()]
res = 1
if 0 in a:
    print(0)
    exit()

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

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

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

Solution (Python):
def main():
    N=int(input())
    A=[int(n) for n in input().split()]
    p = 1
    ov = False
    for i in range(N):
        if not ov:
            np = p * A[i]
        if np > 10**18:
            ov = True
        if A[i] == 0:
            print(0)
            return
        p = np
    if ov:
        print(-1)
    else:
        print(np)
main()

Solution (Python):
def main():
    N = int(input())
    A = list(map(int,input().split()))
    C = 1
    if 0 in A:
        print(0)
    else:
        for i in range(N):
            C *= A[i]
            if C > 10**18:
                C = '-1'
                break
            
        print(C)
    
if __name__ == '__main__':
    main()

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





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

a_L = list(sorted(a_L))
if a_L[0] == 0:
    print(0)
    exit()

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

print(ans)

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

Solution (Python):
import sys

import copy



input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**20
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n = ri()
a = rl()
ans=1
flag=False
for i in a:
    ans*=i
    if ans>10**18:
        flag=True
        break
   
zero=False
for i in a:
    if i==0:
        zero=True
        break
if zero:
    print(0)    
elif flag:
    print(-1)
else:
    print(ans)

Solution (Python):
n = int(input())
an = list(map(int, input().split()))
s = 1
flg = False
for a in an:
  s = s * a
  if s > 10**18 or s< 0:
    flg = True
    break
if 0 in an:
  print(0)
elif flg:
  print(-1)
else:
  print(s)

Solution (Python):
import sys

N = input()
list1 = list(map(int, input().split()))
answer = 1
for i in list1:
    if i == 0:
        print(0)
        sys.exit()
for i in list1:
    answer *= i
    if answer > 10**18:
        print(-1)
        sys.exit()
print(answer)

Solution (Python):
n = int(input())
now = 1
fl = False
li = list(map(int,input().split()))
zero = False;
for i in li:
    if i == 0:
        zero = True
if zero == True:
    print(0)
else:
    for i in li:
        if fl == True:
            continue;
        now *= i
        if now > 1e18:
            print(-1)
            fl = True
    if fl == False:
        print(now)

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

Solution (Python):
n,*a=map(int,open(0).read().split())
a.sort()
ans=1
for ai in a:
  ans*=ai
  if ans>10**18:
    print(-1)
    exit()
print(ans)

Solution (Python):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

n = ni()
a = na()
a.sort()

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

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

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

M = 10**18

def solve():
    for x in A:
        if x == 0:
            return 0
    result = 1
    for x in A:
        result *= x
        if result > M:
            return -1
    return result

print(solve())

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

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

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

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

print(r)

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

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
c=10**18
ans=1
miss=False
zero=False
for i in range(n):
  if not miss:
    ans*=l[i]
  if l[i]==0:
    zero=True
    break
  elif ans>c:
    miss=True
    
if zero:
  print(0)
elif miss:
  print(-1)
else:
  print(ans)

Solution (Python):
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
   
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n=int(input())

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

a=1
if l[0]==0:
	print("0")

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

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

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

Solution (Python):

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

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

ans = 1

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

print(ans)

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

Solution (Python):
from sys import stdin

def main():

    input = stdin.readline

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

    over_num = 10 ** 18

    ans = 1

    if A.count(0) > 0:
        print("0")
        return

    for i in A:
        ans = ans * i
        if ans > over_num:
            print("-1")
            return

    print(ans)


if __name__ == "__main__":
    main()

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

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

print(ans)

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

ans = 1
for i in range(n):
    ans *= val[i]
    if(ans > 1e18):
        ans = -1
        break

if(ans == -1):
    for i in range(n):
        if(val[i] == 0):
            ans = 0
            break
print(ans)

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

Solution (Python):

N = int(input())

Alist = sorted([int(x) for x in input().split(" ")])
if len(Alist) != N:
  print("-1")
  exit()

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

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

ans = 1

min_A = min(A)
A = sorted(A, reverse=True)

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

for a in A:
    ans *= a
    if ans > 10 ** 18:
        break

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

Solution (Python):
import math


n = int(input())
a = list(map(int, input().split()))
p = 1
r=0
m=math.pow(10,18)
if 0 in a:
    print(0)
else:
    for i in range(n):

        p = p * a[i]
        if p>m:
            r+=1
            break

    if r>0:
        print(-1)
    else:
        print(p)

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

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

Solution (Python):
import sys
import numpy as np

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

if len(np.where(np.array(A) == 0)[0]) != 0:
    print(0)
    sys.exit(0)

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

print(ans)

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

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

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

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

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

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):
def solve(alist):
    if 0 in alist:
        return 0
    result = 1
    for a in alist:
        result *= a
        if result > 10**18:
            return -1
    return result

n = input()
alist = list(map(int, input().split()))
print(solve(alist))

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

Solution (Python):
n=input()

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

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

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

print(ans)

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

mult=1
array=map(int,input().split())

array=sorted(array)

for i in array:
    mult*=i
    if mult==0:
        break
    elif mult>10**18:
        mult=-1
        break

print(mult)