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 = 1
list.sort(a, reverse = True)
ones = a.count(1)
for i in range(len(a)-ones):
    if 0 in a:
        ans =0
        break
    ans = ans * a[i]
    if ans >10**18:
        break

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

Solution (Python):

N = int(input()) 



huga = list(map(int, input().split()))
if 0 in huga:
    print(0)
else:
    ans = 1
    flg = 0
    for number in huga:
        ans = ans * number
        if ans > 10**18:
            flg = 1
            break
    if flg == 0:
        print(ans)
    else:
        print('-1')

Solution (Python):
a = int(input())
c = list(map(int, input().split()))
ans = int(1)
m = int(1000000000000000000)
ok = True
o = False
for i in c :
    if i == 0:
        print(0);
        o = True
        break
    elif ok == True :
        ans = int(ans*i)
        if ans > m:
            ok = False
if not ok and not o:
    print(-1)
elif not o :
    print(ans)

Solution (Python):

import sys
def main():
  n = int(input().strip())
  l = list(map(int, input().split()))
  sum = 1
  if 0 in l :
    print (0)
    return

  for i in l:
    sum *= i
    if sum - 1000000000000000000 > 0:
      print (-1)
      return
  print (sum)
main()

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

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

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

print(ans)

Solution (Python):



import sys


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


def resolve():
    n = int(input().rstrip())
    a_list = list(map(int, input().split()))
    flag = False
    try:
        if a_list.index(0):
            flag = True
            print(0)
            exit()
    except:
        if flag:
            exit()
        ans = 1
        for i in a_list:
            ans *= i

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

        print(ans)



if __name__ == "__main__":
    resolve()

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())
AN = list(map(int, input().split()))
if 0 in AN:
    print(0)
    exit()
ans = 1
for A in AN:
    ans *= A
    if ans > 10 ** 18:
        print(-1)
        exit()
 
print(ans)

Solution (Python):
import sys
 
if __name__ == '__main__':
    str = input()
    str = input().strip()
 
    arr = [int(e) for e in str.split()]
    if 0 in arr:
        print(0)
        sys.exit()
 
    total = 1
    for e in arr:
        total *= e

        if total > 10 ** 18:
            total = -1
            break

    print(total)

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

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

Solution (Python):
import sys
input = sys.stdin.readline
largenum = 10**18
from functools import reduce
from operator import mul
def main():
    n = int(input())
    a = list(map(int, input().split()))

    if 0 in a:
        print(0)
        sys.exit()
    r = 1
    for i1 in range(n):
        r *= a[i1]
        if r > largenum:
            print(-1)
            sys.exit()
    print(r)


if __name__ == '__main__':
    main()

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

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

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

ans = 1
for i in range(N):
    if A[i] == 0:
        ok1 = True
for i in range(N):
    ans *= A[i]
    if ans > 1000000000000000000:
        ok2 = True
        break

if ok1:
    print(0)
elif ok2:
    print(-1)
else:
    print(ans)

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

for i in a:
  multi *= i
  if multi > pow(10,18):
    break
if multi > pow(10,18):
  print("-1")
else:
  print(multi)

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

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

Solution (Python):
INFTY=10**18

def readinput():
    n=int(input())
    a=list(map(int,input().split()))
    return n,a

def main(n,a):
    if(a.count(0)!=0):
        return 0
        
    res=a[0]
    for i in range(1,n):
        res*=a[i]
        if res>INFTY:
            return -1
    return res

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(ans)

Solution (Python):
import sys
n = int(input())
a = list(map(int,input().split()))
f = False;
for i in range(n):
  if a[i] == 0:
    f = True
if f:
  print(0)
  sys.exit(0)
ans = 1
for i in range(n):
  ans *= a[i]
  if ans > 1e18:
    print(-1)
    sys.exit(0)
print(ans)

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

Solution (Python):
n = int(input())
values = input().split(' ')
for idx in range(0, n):
    values[idx] = int(values[idx])

result = 1
limit = 10**18
if 0 in values:
    result = 0
else:
    for idx in range(0, n):
        result = result * values[idx]
        if result > limit:
            result = -1
            break

print(result)

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

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
ans = 1
if 0 in A:
  ans = 0
if ans != 0:
  for num in A:
    if ans * num > 1e+18:
      ans = -1
      break
    ans = ans * num
print(ans)

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

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

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

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

Solution (Python):


N = int(input())
A = sorted(list(map(int,input().split())))
if A[0] == 0:
    ans = 0
else:
    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()))

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

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

Solution (Python):
import numpy as np
N = int(input())
A = list(map(int, input().split()))
ans = A[0]
if 0 in A:
  ans = 0
for i in range(N-1):
  ans = ans * A[i+1]
  if ans > 10**18 or ans < -1:
    ans = -1  

print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
m = 1
for i in range(n):
    if a[i] == 0:
        m = 0
        print("0")

if m == 1:
    for j in range(n):
        m = m * a[j]
        if m > 10**18:
            break
    if m > 10**18:
        print("-1")
    else:
        print(m)

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

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

Ans=1
if As.count(0):
    print(0)
    exit()
else:
    for A in range(N):
        if Ans>10**18:
            Ans=-1
            print(Ans)
            exit()
        else:
            NewAns=Ans*As[A]
            Ans=NewAns
    if Ans>10**18:
        Ans=-1
    
    print(Ans)

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

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

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

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

print(ans)

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

x = 1000000000000000000
res = 1

A.sort(reverse=True)

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

for val in A:
    res = res * val
    if res > x:
        print('-1')
        break
else:
    print(res)

Solution (Python):

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

if a.count(0) > 0:
    print(0)
else:
    for num in a:
        total *= num
        if total > 1000000000000000000:
            total = -1
            break
    print(total)

Solution (Python):
from sys import stdin

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

ans = 0

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

print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
def B(N,A):
    result = 1
    if 0 in A:
        return 0
    for i in A:
        result *= i
        if result > 10**18:
            return -1
    return result

print(B(N,A))

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

Solution (Python):
import operator
from functools import reduce

def main():
    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:
            print(-1)
            exit()

    
    print(ans)
    
if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
ans = 1
flag = 0
A = map(int,input().split())
A = list(A)
list.sort(A)
for a in A:
    ans *= a
    if ans == 0:
        print(0)
        flag = 1
        break
    if ans > 1e18:
        print(-1)
        flag = 1
        break

if flag == 0:
    print(ans)

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

Solution (Python):
border = 1000000000000000000

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

result = 1
for n in nums:
    result = result * n
    if result > border:
        print(-1)
        exit()
print(result)

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

def judge(A):
  for i in range(len(A)):
    if A[i] == 0:
      print(0)
      return
  result = 1
  for i in range(N):
    result = result * A[i]
    if result > 1000000000000000000:
      print(-1)
      return
  if result <= 1000000000000000000:
    print(result)
    return
  
judge(A)

Solution (Python):
n = int(input())
num_list = list(map(int, input().split()))
     
a = 1
if 0 in num_list:
    print(0)
else:
    for x in num_list:
        a = a * x
        if (a > 1000000000000000000):
            print("-1")
            break
    if (a <= 1000000000000000000):
      print(a)

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

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

Solution (Python):

n = int(input())
y = list(map(int, input().split(" ")))
s = 1
hoge = False
for i in y:
    if i ==0:
        print(0)
        hoge = True

def f():
    s = 1
    for i in y:
        s *= i
        if s>10**18:
            print(-1)
            return
    print(s)
if not hoge:
    f()

Solution (Python):
n=int(input())
a_list=list(map(int,input().split()))
num1=a_list.count(1)
import functools
import operator
if 0 in a_list:
    print("0")
elif n > 60+num1:
    print("-1")
else:
    p = functools.reduce(operator.mul, a_list)

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

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

print(ans)

Solution (Python):
import numpy as np
N = int(input())
buf = list(map(int,input().split()))
cnt = 1
flag = True
for i in range(N) :
    if buf[i] == 0 :
        print(0)
        exit()
for i in range(N) :
    cnt = cnt * buf[i]
    if cnt > 10 ** 18 :
        flag = False
        break

if flag == True :
    print(cnt)
else :
    print("-1")

Solution (Python):



n = s=list(input())
li = list(map(int,input().split()))

ans = 1
for i in li:
    if(i == 0):
        ans = 0

for i in li:
    ans *= i
    if(ans > 1000000000000000000):
        ans = -1
        break
    
print(ans)

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

A = sorted(A)

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

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

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

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

limit = pow(10,18)

f = 0
for i in range(N):
    if A[i] != 0 and f == 0:
        ans *= A[i]
    elif A[i] != 0:
        pass
    else:
        print(0)
        exit()

    if ans > limit:
        f = 1

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

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

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

mul = 1
for i in A:
    mul = mul * i
    if mul > 10 ** 18:
        mul = -1
        break

if 0 in A:
    mul = 0

print(mul)

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

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

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

cnt = 1
if 0 in a:
    print(0)
    exit()

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

Solution (Python):
n = int(input())
numbers = [ int(i) for i in input().split()]
if 0 in numbers:
    print(0)
else:
    result = 1

    max = 10**18
    for i in range(n):
        result *= numbers[i]    
        if result > max:
            break


    if result > max:
        print(-1)
    else:
        print(result)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
ans = 1
if 0 in A:
    ans = 0
else:
    for v in A:
        ans = ans * v
        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())


input_org = input()
keta = input_org.replace(' ', '')
input_list = list(map(int, input_org.split()))
ans = 1


if (0 in input_list):
    ans = 0
elif len(keta) - N > 20:
    ans = -1
else:
    for input in input_list:
        ans = ans*input
        if ans > 1000000000000000000:
            ans = -1

print(ans)

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

l = list(map(int,input().split()))
l.sort(reverse = True)

ans = 1
if 0 in l:
  print(0)
else:
  for i in range(n):
    ans *= l[i]

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

Solution (Python):
import sys

N = int(input())

Line = [int(s) for s in input().split()]
Line.sort()

ans = 1

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

print(ans)

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

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

if az>0:
    print(0)
else:
    for i in range(len(a)):
        ans*= a[i]
    
        if ans>=1000000000000000001:
            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 a:
        ans *= i
        if ans > 10 ** 18:
            print(-1)
            exit()

    print(ans)

Solution (Python):


n = int(input()) 
  

a = list(map(int,input().strip().split()))[:n] 
  
mask = 1;
flag = 0;
for num in a:
    if(num == 0):
            flag = 1
mask = 1;
flagex  = 0;
if(flag == 1):
    print(0)
else:
    for num in a:
        mask *= num;
        if(mask > 1000000000000000000):
            flagex = -1;
            break;
    if(flagex == -1):
        print(-1);
    else:
        print(mask);

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

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

Solution (Python):
N = int(input())
List = list(map(int,input().split()))
ans = 1
for item in List:
  ans *= item
  if ans > 10 **18 or ans <= -1:
    ans = -1
print(ans)

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

ans = l[0]

minn = min(l)

if (minn == 0):
    print(0)
else:
    for i in range(1,len(l)):
        ans = ans * l[i]

        if ans >= 1000000000000000001:
            break
    
    if ans >= 1000000000000000001:
        print(-1)
    else:
        print(ans)

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

ans=1

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

print(ans)

Solution (Python):

import numpy as np

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

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

if c==1:
    print("{}".format(ans))
elif c==0:
    if 0 in A:
        print("{}".format(0))
    else:
        print("{}".format(-1))

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

if 0 in lista:
    ans = 0
else:
    lista.sort(reverse=True)
    for i in range(n):
        ans *= lista[i]
        if(ans > limitNumber):
            ans = -1
            break

print(ans)

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

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

Solution (Python):
import sys
import numpy as np

num_data = sys.stdin.readlines()
str_num_list = num_data[1].split()
num_list = [int(s) for s in str_num_list]
ans = 1
if 0 in num_list:
  ans = 0
else:
  for i in range(int(num_data[0])):
    ans *= num_list[i]
    if ans > pow(10, 18):
      ans = -1
      break

print(ans)

Solution (Python):

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

t = 1
ans = 1
count = 0

if 0 in A:
    ans = 0
else:  
    for a in A:
        ans *= a
        t *= a
        while t >= 10:
            t /= 10
            count += 1
            if count >= 19:
                ans = -1 
                break

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

print(ans)

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

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

a.sort()
if a[0]==0:
  print(0)
  
else:
  s=1
  for i in a:
    s*=i
    if s>10**18:
      print(-1)
      exit()
      
  print(s)

Solution (Python):
import sys
n=int(input())
data=list(map(int,input().split()))
num=1
if any(i==0 for i in data):
    print(0)
    sys.exit()
else:
    for i in data:
        num*=i
        if 10**18<num:
            print(-1)
            sys.exit()
print(num)

Solution (Python):
import sys

N = int(input())

As = [int(n) for n in input().split()]
As_set = set(As)

limit = 10**18

prod = 1

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

over = False
for A in As:
    prod *= A
    if prod > limit:
        print(-1)
        sys.exit(0)

print(prod)

Solution (Python):
n=int(input())
a_list=list(map(int, input().split()))
multi_sum=1
LIMIT=1000000000000000000

if 0 not in a_list:
    for a_i in a_list:
        multi_sum*=a_i
        if multi_sum > LIMIT:
            multi_sum=-1
            break
else:
    multi_sum=0

print(multi_sum)

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

a = sorted(a)

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

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

Solution (Python):


n=int(input())
arr=list(map(int,input().split()))
arr.sort()
ans=1
v=True
for i in arr:
    ans=ans*i
    if ans==0:
        v=False
        print(0)
        break
        
    if ans>1000000000000000000:
        v=False
        print(-1)
        break

if v:
    print(ans)

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

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

a.sort()

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

total = a[0]

for i in range(1,N):
    total *= a[i]
    if  10 ** 18 < total:
        print(-1)
        exit()
print(total)

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

Solution (Python):
n=int(input())
l=list(map(int,input().split(" ")))
l.sort();
t=1000000000000000000
at=1;
f=True;
for x in l:
  at=at*x;
  if(at>t):
    f=False
    break
if(f):
  print(at)
else:
  print(-1)

Solution (Python):


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

sum = 1

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

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

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

if A.count(0) != 0:
    print(0)
    sys.exit()

for i in A:

    ans = ans*i
    if ans > int(10**18):
        print(-1)
        sys.exit()
 
if ans > int(10**18):
    print(-1)
else:
    print(ans)

Solution (Python):
n = int(input())
lim = 10**18
ans,exc = 1,False
a = list(map(int,input().split()))

if 0 in a:
  print(0)
else:
  for x in a:
    ans *= x
    if ans > lim:
      exc = True
      print("-1")
      break
  if not exc:
    print(ans)

Solution (Python):
import numpy as np
N = int(input())
num_list = list(map(int, input().split()))


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


if 0  in num_list:
    print(0)
elif ans > 10**18:
    print("-1")
else:
    print(ans)

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

Ans = 1
A.sort()

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

for i in A:
    Ans *= i
    if Ans > 10**18:
        Ans = -1
        break

print(Ans)

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

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

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

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
answer = 1
zero_check = 0 in a

for i in range(n):
    answer = a[i] * answer
    if zero_check:
        print(0)
        break
    elif answer > 1000000000000000000:
        print(-1)
        break
else:
    print(answer)

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

ans = 1

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

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

print(ans)

Solution (Python):
import math

N = int(input())
A_list = [int(i) for i in input().split()]

ans = 1
is_zero = False
is_over = False
for i in A_list:
    if i == 0:
        is_zero = True
        break
    if ans > 10**18:
        is_over = True

    if is_over:
        pass
    else:
        ans *= i

if is_zero:
    print(0)
elif is_over or ans > 10**18:
    print(-1)
else:
    print(ans)

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

li.sort()

ans=1
for i in li:
    ans*=i
    if ans>math.pow(10,18):
        print('-1')
        quit()
print(ans)

Solution (Python):

n = input()
res = 1
num_str = input()  
num_str_arr = num_str.split(' ')
num_arr = [int(x) for x in num_str_arr]
done = 0
for x in num_arr:
	if x == 0:
		res = 0
	if res <= 1000000000000000000:
		res = res * x
if res > 1000000000000000000:
	print(-1)
else:
	print(res)

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

Solution (Python):
import sys
N = int(input())
An = []
mul = 1

An = list(map(int,input().split()))
if An.count(0) > 0:
    print("0")
    sys.exit()

for i in An:
    mul *= i
    if mul > 10**18:
        print("-1")
        sys.exit()

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

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

Solution (Python):
from collections import deque

N = int(input())
A = list(map(int,input().split()))
if 0 in A:
    print(0)
    exit();

A = deque(A)

if N%2 == 1:
    ans_right = A.pop()
else:
    ans_right = 1

ans_left = 1

for i in range(N//2):
    right = A.pop()
    left = A.popleft()
    
    ans_right = ans_right * right
    ans_left = ans_left * left

    if ans_right > 10**18 or ans_left> 10**18 or ans_left*ans_right> 10**18:
        print(-1)
        exit()


else:
    print(ans_right*ans_left)

Solution (Python):

from functools import *
import sys
sys.setrecursionlimit(100000)

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


N=input()
a=acinput()

if min(a)==0:
    print(0)
    sys.exit()
res=1

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

Solution (Python):
n = input()
list = input().split()

ans = 1
max_ans = 10**18

if "0" in list:
    ans = 0
else:       
    for num in list:
        ans = ans * int(num)
        if ans > max_ans:
            ans = -1
            break

print(ans)

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

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

MAX = 1000000000000000000

ans = 1

if not '0' in line:
    for l in line:
        if l == 0:
            ans = 0
            break
        if not ans > MAX:
            ans = int(l) * ans

else:
    ans = 0


if ans <= MAX:
    print(ans)
else:
    print(-1)

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

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

print(ans)