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

Solution (Python):
def 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):
if __name__ == '__main__':

	INF = 10**18
	
	n = int(input())
	A = list(map(int,input().split()))

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

	ans = 1
	flg = False

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

	print(ans)

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

A=list(map(int,input().split()))
ans=A[0]

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

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

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

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

    print(ans)

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

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

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

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

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

Solution (Python):
import sys

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

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

else:
    for i in range(N):
        A_sum = A_sum * A[i]
        
        if A_sum > 1e18:
            print(-1)
            sys.exit()


print(A_sum)

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

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

ans = 1

for item in A:
    ans *= item

    ans = min(ans, 10**18 + 1)

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

print(ans)

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

ans=1

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

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

Solution (Python):
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()))
prod = 1

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

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

print(prod)

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

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

AA=sorted(A)
B=1
for i in range(N):
    B=B*AA[i]
    if B>10**18:
      B=-1
      break

print(B)

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

res = 1
for a in A:
    res = min(res*a, 10**18 + 1)
if res == 10**18 + 1: print(-1)
else: print(res)

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

Solution (Python):
import sys

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

U = 10**18
ret = 1

for x in A:
  ret *= x
  if ret > U:
    ret = U+1
    
if ret > U:
  ret = -1

print(ret)

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

Solution (Python):
n,*a=map(int,open(0).read().split());z=1
for i in a:
 if i>1e18//z:z=-1;break
 z*=i
print(0 if 0in a else z)

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

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

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

for i in range(1,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:
    ANS = 0
else:
    A.sort(reverse=True)
    ANS = 1
    for a in A:
        ANS = ANS * a
        if ANS > 10 ** 18:
            ANS = -1
            break

print(ANS)

Solution (Python):
from sys import stdin

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

ans = 1

if 0 in A:
    ans = 0

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

print(ans)

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

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

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

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

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

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

if 0 in S:
  print(0)
  exit(0)
  
for n in S:
  ans *= n
  if ans > t:
    print(-1)
    exit(0)
  
print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    A = list(map(int,input().split()))
    ans = 1
    if 0 in A:
        print(0)
        sys.exit()
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)

if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    A = list(map(int,input().split()))
    ans = 1
    if 0 in A:
        print(0)
        sys.exit()
    for a in A:
        ans *= a
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)

if __name__=='__main__':
    main()

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

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

def f():
    if 0 in S:
        return 0
    elif 10 ** 18 in S:
        return -1
    else:
        ans = 1
        for s in S:
            ans *= s
            if ans > 10 ** 18:
                return -1
        return ans

print(f())

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

for i in range(N):
    ans *= A[i]
    if ans > P:
        ans = -1
        break

ans = 0 if any([a==0 for a in A]) else ans
print(ans)

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

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

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

print(acc)

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

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

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

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 main():
    n = int(input())
    a = list(map(int, input().split(" ")))
    lim = 1e18
    ans = 1
    if 0 in a:
        print(0)
        return
    for i in a:
        ans *= i
        if ans >lim:
            print(-1)
            return
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
import sys
N = input()
num = [int(x) for x in input().split()]
multiply = 1

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

for i in num:
    multiply *= i
    if (multiply > 10**18):
        print(-1)
        sys.exit()
if (0 < multiply and multiply <= 10**18):
    print(multiply)

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

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

print(x)

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

main()

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

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

k = input().split()

for i in range(len(k)):
    k[i] = int(k[i])

k.sort()

mul = 1

for i in range(num):
    mul *= int(k[i])
    if mul > 10**18:
        break

if mul > 10**18:
    print(-1)

else:
    print(mul)

Solution (Python):
n = int(input())
x = [int(w) for w in input().split()]
x = sorted(x)
ans = 1
f = False
for i in range(n):
    ans *= x[i]
    if ans > 10**18:
        f = True
        break
    
if ans > 10**18:
    f = True
    
if(f):
    print(-1)
    
else:
    print(ans)

Solution (Python):
def main(X, A):
    ans = 1
    if 0 in A:
        return 0
    for a in A:
        ans *= a
        if ans > 1e18:
            return -1
    return ans

if __name__ == '__main__':
    X = int(input())
    A = list(map(int, input().split()))
    ans = main(X, A)
    print(ans)

Solution (Python):

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

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

print(ans)

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

m = 10**18
if a[0] == 0:
    print(0)
else:
    ans = 1
    for i in a:
        ans *= i
        if ans > m:
            print(-1)
            exit()
    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())))
l=1
a=sorted(a)
for i in range(n):
    l*=a[i]
    if l>10**18:
        print('-1')
        exit()
print(l)

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

if 0 in a:
    print(0)
else:

    ans = 1
    i = 0
    while (i <= n - 1):
        if ans <= 10 ** 18:
            ans *= a[i]
            i += 1
        else:
            break

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

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

ans = 1
dotira = False
s = 10**18

if 0 in p :
  print(0)

else:
  
  for x in p:
    ans = ans * x
    if ans > s:
      dotira = True
      break
  if dotira:
    print(-1)
  else:
    print(ans)

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

if '__main__' == __name__:
    resolve()

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

if A[0] == 0:
  print(0)
else:
  for An in A:
    p = p * An
    if p > 10 ** 18:
      print(-1)
      done = 1
      break
  if done == 0:
    print(p)

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

Solution (Python):

_ = input()
N = sorted([int(v) for v in input().split()])
s = 1
for n in N:
    s *= n
    if s == 0 or s > 10**18:
        break

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

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

for i in range(n):
  if a[i] == 0:
    sum = 0

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

print(sum)

Solution (Python):
N=int(input())
ans =1
A = list(map(int,input().split()))
for i in A:
        if i == 0:

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

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

kMax = 10**18

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

for i in I:
    ans *= i
    if ans > kMax:
        print(-1)
        exit()
print(ans)

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

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

Solution (Python):
import sys

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

a = sorted(a, reverse=True)

multi = 1

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

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

print(multi)

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

Solution (Python):




from math import prod

if __name__ == '__main__':
    n = input()
    a = list(map(int, input().split(' ')))
    s = 1
    a.sort()
    x = True
    for i in range(len(a)):
        s = s * a[i]
        if s > 10**18:
            print(-1)
            x = False
            break
    if x:
        print(s)

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

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

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

Solution (Python):
N=int(input())
s=list(map(int,input().split()))
ans=1
if s.count(0)>0:
  print('0')
  exit()
for i in s:
  ans*=i
  if ans>1000000000000000000:
    print('-1')
    exit()

print(ans)

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

print(ans)

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

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

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
sum = 1
big = False
if 0 in A:
    print(0)
else:
    for a in A:
        sum *= a
        if sum > 10**18:
            big = True
            break
    if big:
        print(-1)
    else:
        print(sum)

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

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

prod = 1

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

print(prod)

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



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

print(ans)

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

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

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

c=1

for i in range(n):
    c*=a[i]
    if c>10**18:
        print('-1')
        sys.exit()
    else:
        continue

print(c)

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

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

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

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

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

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

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

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

print(ans)

Solution (Python):
from sys import exit

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

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
def nhan(A):
    multi = 1
    for i in A:
        multi *= i
        if multi > 10**18: return -1
    return multi
print(nhan(A))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
 
ans = 1
for x in a:
  if ans <= 10**18:
    ans = ans * x

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

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

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

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

ans = 1
if any(j == 0 for j in A) == True:
    ans = 0
else:
  for i in A:
    ans *= i
    if ans > 10**18:
      ans = -1
      break

print(ans)

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

Solution (Python):

n=int(input())
ans=1
a=list(int(y) for y in input().split())

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

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

m=1
l=10**18

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

for i in range(n):
    m=m*a[i]
    if m > l:
        print(-1)
        sys.exit()

print(m)

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

Solution (Python):
import numpy as np

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


Alist.sort()
ans = 1
for i in range(N):
  
  ans*= Alist[i]
  if Alist[i]==0:
    break
  if ans >10**18:
    break

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

Solution (Python):
import numpy as np

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


Alist.sort()
ans = 1
for i in range(N):
  
  ans*= Alist[i]
  if Alist[i]==0:
    break
  if ans >10**18:
    break

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

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

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

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

print(ans)

Solution (Python):
n = int(input())
list_a = [int(x) for x in input().split()]
list_a_str = [str(s) for s in list_a]
ans = 1

for i in range(0, n):
    if list_a_str[i] in '0':
        print('0')
        exit()

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

else: print(ans)

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

ans = 0
if 0 not in A:
  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 = [int(x) for x in input().split()]

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

ans = A[0]
for i in range(1, 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 = sorted(A)
result=1
max=10**18
for a in A:
    result *= a
    if result>max:
        print(-1)
        break
else:
    print(result)

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):
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr) 
ans=1
for val in arr:
 ans*=val 
 if ans>10**18:
   print(-1)
   break
else:
 print(ans)

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


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

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

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

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

    print(ans)


if __name__ == "__main__":
    main()

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

result = 1

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

print(result)

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

judge = True
ans = 0

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

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

Solution (Python):

import sys
from itertools import chain

MAX = 10 ** 18


def solve(N: int, A: "List[int]"):
    A = sorted(A)
    answer = 1
    for a in A:
        answer *= a
        if answer > MAX:
            return -1
    return answer


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    answer = solve(N, A)
    print(answer)


if __name__ == "__main__":
    main()

Solution (Python):

import sys
from itertools import chain

MAX = 10 ** 18


def solve(N: int, A: "List[int]"):
    A = sorted(A)
    answer = 1
    for a in A:
        answer *= a
        if a > 0:
            if answer > MAX:
                return -1
    return answer


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    answer = solve(N, A)
    print(answer)


if __name__ == "__main__":
    main()

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

if 0 in A :
    print("0")
    exit()
result = 1
for i in range(N) :
    result *= A[i]
    if result > 10**18 :
        print("-1")
        exit()

print(result)

Solution (Python):
N = input()
A = list(map(int, input().split()))
C = sorted(A)
l = len(A)
i = 0
S = 1

while i < l:
   S = S * C[i]
   i = i + 1
   if S > 1000000000000000000:
        print(-1)
        break
   elif i == l:
        print(S)
        break

Solution (Python):
N = input()
A = list(map(int, input().split()))
C = sorted(A)
l = len(A)
i = 0
S = 1

while i < l:
   S = S * C[i]
   i = i + 1
   if S > 1000000000000000000:
        print(-1)
        break
   elif i == l:
        print(S)
        break

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

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

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

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

pyn()

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

Solution (Python):
a =int(input())
l = list(map(int,input().split()))
l.sort()
import numpy as np
times = 1
for i in l:
  times*=i
  if times>10**18:
    times = -1
    break
print(times)

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

if a[0]==0 :
  print(0)
  exit()

res = 1

lim = 10**18

for i in(a):
  res *= i
  if res > lim :
    print(-1)
    exit()
  
print(res)

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

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

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

Solution (Python):
def main():
    n = int(input())
    A = list(map(int, input().split()))
    
    if A.count(0) != 0:
        print(0)
        return

    ans = 1

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

    print(ans)
    
main()

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

ans = 1

ok = True
for i in range(n):
    ans *= a[i]
    if ans > 10 ** 18:
        ok = False
        break

for i in range(n):
    if a[i] == 0:
        ok = True
        ans = 0

if ok == True:
    print(ans)
else:
    print(-1)

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

  if (0 in A):
    print("0")
    return

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

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

ans = 1

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

print(ans)

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

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

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