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

Solution (Python):
import sys

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

if a[0] == 0:
    print(0)
else:
    ans = 1
    while a:
        ans *= a.pop()
        if ans > 10**18:
            print(-1)
            sys.exit()
    print(ans)

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

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

Solution (Python):
n = int(input())
a_list = sorted([int(x) for x in input().split()], reverse=True)

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

ans = 1
s = 10 ** 18
for a in a_list:
    ans *= a
    if ans > s:
        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 range(N):
    ans *= A[i]
    if ans > 10 ** 18:
        print(-1)
        exit()

print(ans)

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

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

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

Solution (Python):
def aaa(a_list):
    ans = 1
    for i in a_list:
        ans = ans * i
        if ans > 10**18:
            return -1
    return ans

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

if 0 in a:
    print(0)
else:
    print(aaa(a))

Solution (Python):


import sys
import numpy as np

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

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

a = [s for s in aa if s != 1]
a.sort(reverse=True)









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







print(prod)

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

a = sorted(a)
ans = a[0]
tmp = 0


for i in range(n-1,0,-1):
    ans = ans * a[i]
    if ans > check:
        tmp  = 1
        break
    elif a[0] == 0:
        tmp = 2
        break

if tmp == 1:
    print('-1')
elif tmp == 0:
    print(ans)
elif tmp == 2:
    print('0')

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

while ans <= 10**18 and i < N:
  ans *= A_n[i]
  i +=1
if ans > 10**18:
  if 0 in A_n:
    print(0)
  else:
    print(-1)
else:
  print(ans)

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

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

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

Solution (Python):
def solve():
    _ = int(input())
    a = list(map(int, input().split()))
    res = 1
    for x in a:
        if x == 0:
            print(0)
            return
    for x in a:
        res *= x
        if res > int(1e18):
            print(-1)
            return
    print(res)


solve()

Solution (Python):
N = int(input())
As = list(map(int,input().split()))
c = int(As[0])
i = 0
f = True
if 0 in As:
  print("0")
else:
  for x in As:
    if i == 0:
      i += 1
      continue
    c = c * x 
    if 1000000000000000001 <= c:
      print("-1")
      f = False
      break
  if f:
    print(c)

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

n = int(input())
a = list(map(int, input().split()))
ans = 1
flag = True

for ta in a:
    ans *= ta
    if (ans > 10 ** 18):
        flag = False
        ans = 1

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

Solution (Python):
import sys

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

ans = 1

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

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

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

Solution (Python):
import numpy as np
N    = int(input())
A    = input().split()
Pro  = 1
PrF  = 1
PrFF = 1

if '0' in A:
    print(0)
    PrF = 0
    
if PrF:
    for T in range(0,len(A)):
        if int(A[T]) == pow(10,18):
            PrFF = 0
            print('-1')
            break
        else:
            Pro = Pro*int(A[T])
            if Pro > pow(10,18):
                PrFF = 0
                print('-1')
                break

if PrF & PrFF:
    print(Pro)

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

ans = a_list[0]
count = a_list.count(0)

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

print(ans)

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a1=sorted(a,reverse=True)
a2=sorted(a)
ans=1
if len(a)<90:
    for i in range(len(a)):
        ans*=a[i]

else:
    if a2[0]==0:
        ans=0
    elif a1[90]>1:
        ans=-1
    else:
        del a1[90:]
        for i in range(len(a1)):
           ans*=a1[i]
if ans>10**18:
    print(-1)
else:
    print(ans)

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

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

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

Solution (Python):
n = [int(input()) for i in range(1)][0]
li = list(map(int,input().split()))
a = 1
while True:
    if 0 in li:
        print(0)
        break
    for num in li:
        a = a * num
        if a <= 10**18:
          continue
        if a > 10**18:
          break
    if a <= 10**18:
        print(a)
        break
    if a > 10**18:
        print(-1)
        break

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

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

else:
  for a in A:
    X*=a
    if X>=1000000000000000001:
      print(-1)
      break
  else:
    print(X)

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

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

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

answer = 1
for _ in A:
    answer *= _
    if answer > 1000000000000000000:
        print('-1') 
        exit()

print(answer)

Solution (Python):
n = int(input())
A = [int(i) for i in input().split()]
check = [i for i in A if i == 0]
if 0 in check:
    print(0)
else:   
    A.sort(reverse=True)
    work = 1
    for a in A:
        work *= a
        if work > 10**18:
            print('-1')
            break
    else:
        print(work)

Solution (Python):
n = int(input())
nums = list(map(int,input().split()))
limit = 10**18
res = 1
i = 0
if 0 in nums:
    print(0)
    exit()
while i<n:
    res *= nums[i]
    i += 1
    if res > limit:
        res = -1
        break
print(res)

Solution (Python):
n = map(int, input().split())
a = list(map(int, input().split()))
flag0 = False
flag1 = False
b = 1
for e in a:
    if e == 0:
        flag0 = True

    if b * e > 1000000000000000000:
        b = 0
        flag1 = True

    b *= e

if flag0 == True:
    print(0)
elif flag1 == True:
    print(-1)
else:
    print(b)

Solution (Python):
n=int(input())
a=list(input().split(" "))
pro=1
if "0" in a:
  print(0)
  quit()
for i in a:
  pro*=int(i)
  if pro>10**18:
    print(-1)
    quit()
print(pro)

Solution (Python):
N = int(input())
A = input().split()
if '0' in A:
	print(0)
else:
	cutoff = 10**18
	res = 1
	for n in range(N):
		res *= int(A[n])
		if res > cutoff:
			res = '-1'
			break
	print(res)

Solution (Python):

def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    for x in a:
        if x==0:
            print(0)
            return

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

    print(ans)

solve()

Solution (Python):
N = int(input())
arr = sorted(map(int, input().split()))
INF = 10 ** 18
ans = 1
for num in arr:
    ans *= num
    if ans > INF:
        ans = -1
        break
    elif ans == 0:
        break

print(ans)

Solution (Python):
'''

                            Online Python Compiler.
                Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute it.

'''

n = int(input()) 
  
a = list(map(int,input().strip().split()))[:n] 
x=1
flag=0
flag1=0
for i in range(n):
    if a[i]==0:
        x*=0
        flag1=1
        break
if flag!=1: 
    for i in range(n):
        if x*a[i]>1000000000000000000:
            flag=1
            break
        else:
            x*=a[i]
        
if flag1==1:
    print(0)
elif flag==1:
    print(-1)
else:
    print(x)

Solution (Python):
import sys

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

if 0 in A:
    print(0)
    sys.exit();

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

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

Solution (Python):
import math

line = input().rstrip()
N = int(line)
line = input().rstrip()
line = line.split(' ')
mult = 1

numbers = []
for i in range(N):
    numbers.append(int(line[i]))
numbers.sort()

if numbers[0] == 0:
    mult = 0
else:
    for A in numbers:
        if math.log10(mult) + math.log10(A) > 18.0:
            mult = -1
            break
        mult = mult * A
        if mult > 10**18:
            mult = -1
            break

print(mult)

Solution (Python):
N = int(input())
numbers = [int(n) for n in input().split()]
mlt = 1
if 0 in numbers:
    print(0)
else:
    for n in numbers:
        mlt *= n
        if mlt > 1000000000000000000:
            mlt = -1
            break
    print(mlt)

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

s = 1
for i in range(N):
    if mlist[i] == 0:
        print(0)
        s = 0
        break
    elif s > 0:
        s *= mlist[i]

    if s > 10 ** 18:
        s = -1
if i == N-1 and s != 0:
    print(s)

Solution (Python):
from sys import stdin
n = int(stdin.readline().rstrip())
data = stdin.readline().rstrip().split()
out = 1
for d in data:
    out *= int(d)
    if out > 10**18:
        out = -1
        break

if '0' in data:
    print(0)
else:
    print(out)

Solution (Python):
import sys

n = input()
A = sorted([int(x) for x in input().split()], reverse=True)

if A[-1] == 0:
    print(0)
    sys.exit()

product = 1
for a in A:
    product *= a
    if product > 10**18:
        product = -1
        break

print(product)

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

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

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


answer = A[0]

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

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

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

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

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

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

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

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

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

mul=1
i=0

if 0 in p:
  print(0)
else:
  while mul<=1000000000000000000 and i!=n:
    mul=mul*p[i]
    i+=1
  if mul>1000000000000000000 or i!=n:
    print(-1)
  else:
    print(mul)

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

N = int(input())
A = map(int, input().split())
res = int(1)
Lim = int(1000000000000000000)

for X in A:
    
    if X == 0:
        res *= X
        continue
    if res > Lim:
        continue
    res *= X
if res > Lim:
    print(-1)
else:
    print(res)

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

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


ans = 1
over = 10**18

for num in nums:
    ans = ans * num

    if ans > over:
        print(-1)
        exit()

print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
ans = 1
mark = False
if 0 in a:
    print(0)
    mark = True
if mark==False:
    for i in range(n):
        ans *= a[i]
        if ans > 1000000000000000000:
            mark = True
            print(-1)
            break
if not mark: print(ans)

Solution (Python):
import math

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

hoge =1

if 0 in arr:
    print(0)

else:
    for num in arr:
        hoge = hoge*num
        if hoge>1000000000000000000:
            print(-1)
            kosuu=0
            break
    if kosuu>0:
        print(hoge)

Solution (Python):




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

thr = 10**18

res = 1

if 0 in A:
    res = 0
else:
    for a in A:

        res *= a

        if res > thr:
            res = -1
            break

print(int(res))

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

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

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):
        a = A[i]
        for j in range(19):
            if a <= 10**j:
                m = j
                break
        for k in range(19):
            if ans <= 10**k:
                n = k
                break
        if(m+n > 19):
            print(-1)
            break
        elif(ans*a == 10**18):
            ans = ans*a
        elif(ans*a > 10**18):
            print(-1)
            break
        else:
            ans = ans*a
        if i == N-1:
            print(ans)

Solution (Python):
n = int(input())
ans = 1
lst=list(map(int,input().split()))
for i in lst:
	if(ans * i > 1000000000000000000):
		ans = -1

	if(ans != -1):
		ans *= i
	if(i == 0):
		ans = 0
		break
print(ans)

Solution (Python):
n = int(input())
arr = [int(x) for x in input().split()]
res = 1
flag = False
for i in range(n):
    if flag == False:
        res *= arr[i]
    if arr[i] == 0:
        print(0)
        exit()
    if res > 10**18:
        flag = True
if res > 10**18:
    print(-1)
else:
    print(res)

Solution (Python):
import sys
N = int(input())
num = list(map(int,input().split()))
num.sort(reverse=True)
a = 1
if num[-1] == 0:
  print(0)
else:
  for n in range(N):
    a = num[n]*a
    if a> 10**18:
      print(-1)
      sys.exit()
  print(a)

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

if "0" in A_str:
    print(0)
    exit()

res = 1
for A in A_array:
    res *= A
    if res > 10 ** 18:
        res = -1
        break

print(res)

Solution (Python):
MAX = 10 ** 18

N = int(input())
liste = list(map(int, input().split()))
res = 1 
for i in range(N):
    if(liste[i] == 0):
        print(0)
        exit(0)

for i in range(N):
    res *= liste[i]
    
    if(res > MAX):
        print(-1)
        exit(0)

if(res > MAX):
    print(-1)
else: 
    print(res)

Solution (Python):

import sys


sysread = sys.stdin.readline
read = sys.stdin.read



sys.setrecursionlimit(10 ** 7)









def run():
    N = int(input())
    A = list(map(int, input().split()))
    limit = 10 ** 18
    ret = 1
    if 0 in A:
        print(0)
        return None
    for a in A:
        ret *= a
        if ret > limit:
            print('-1')
            return None
    print(ret)



if __name__ == "__main__":
    run()

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

Solution (Python):
import math

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

Solution (Python):
import sys
N = int(input())
A = list(map(int, input().split()))
for a in A:
  if a == 0:
    print(0)
    sys.exit()
x = 1
for a in A:
  x = x * a
  if x > 1000000000000000000:
    print(-1)
    sys.exit()
print(x)

Solution (Python):
from sys import stdin, stdout 
def main(): 
	n = stdin.readline() 
	arr = [int(x) for x in stdin.readline().split()] 
	ok = 0
	pro = 1 
	INF = 1e18
	for x in arr:
		if(x == 0):
			ok = 1
	if(ok==1):
		return 0 
	else:
		for x in arr:
			pro = pro*x ;
			if(pro > INF):
				return -1
	return pro

if __name__ == "__main__": 
	ans = main()
	stdout.write(str(ans))

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

reg = A[0]
flg=True
if 0 in A:
    print(0)
    flg=False
    reg=0
for i in range(1, N):
    reg *= A[i]
    if reg>10**18:
        print(-1)
        flg=False
        break
if flg:
    print(reg)

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

print(ans)

Solution (Python):

n = int(input())
a = list(map(int,input().split()))
re = 1
if 0 in a:
    print("0")
else:
    for i in a :
        re = re * i
        if re > 1000000000000000000:
            print("-1")
            quit()
    print(re)

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

ans = 1
for i in range(len(li)):
    if li[i] == 0:
        ans = 0

if ans == 0:
    print(ans)
else:
    possible = True
    for i in range(len(li)):
        if int(li[i]) * ans > 1000000000000000000:
            possible = False
            break
        else:
            ans *= li[i]
    if (possible):
        print(ans)
    else:
        print(-1)

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

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

Solution (Python):
import numpy as np

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

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

ans=1
P.sort(reverse=True)

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

print(ans)

Solution (Python):
N = int(input())
numbers = [int(n) for n in input().split()]
mlt = 1
if 0 in numbers:
    print(0)
else:
    for n in numbers:
        mlt *= n
        if mlt > 1000000000000000000:
            mlt = -1
            break
    print(mlt)

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

Solution (Python):
from functools import reduce
from operator import mul
import sys
input = sys.stdin.readline

count = int(input())
list = list(map(int, input().split()))
sum = list[0]
if 0 in list:
    print(0)
    exit()
else:
    for i in range(count - 1):
        sum = sum * list[i + 1]
        if sum > 1000000000000000000:
            print(-1)
            exit()


    print(sum)

Solution (Python):
def ans(a):
    ans = 1
    if 0 in a:
        return 0
    for i in A:
        ans *= i
        if 10 ** 18 < ans:
            ans = -1
            return ans
    return ans


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

print(ans(A))

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
ans=1
if A.count(0) >= 1:
  print(0)
else:
  B=[i for i in A if i != 1]
  if len(B) >= 100:
    print("-1")
  else:
    for k in range(len(B)):
      ans=ans*B[k]
    if ans > 1000000000000000000:
      print("-1")
    else:
      print(ans)

Solution (Python):
import sys

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

Solution (Python):
import sys

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

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

if "0" in line:
  x = 0
else:
  x = 1
  for i in range(num):
    x = x * int(line[i])
    
    if x > 10 ** 18:
      x = -1
      break
  
print(x)

Solution (Python):
N = int(input())
S = input().split()
S.sort()
ans = 1

for i in range(N):
    A = int(S[i])
    if(A==0):
        ans = 0
        break
    else:
        ans *= A
    if ans>1000000000000000000:
        ans = -1
        break
print (ans)

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

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

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

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

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

Solution (Python):
n=int(input())
s=input()
a=list(s.split())
ans=1
flag=0
for i in range(0,n):
    ans=ans*int(a[i])
    if(ans>1000000000000000000):
        ans=-1
        j=i
        flag=1
        break
f=0
if(flag==1):
    for i in range(j+1,n):
        if(int(a[i])==0):
            f=1
            ans=0
            break
if(ans<-1 and f==0):
    print("-1")
else:
    print(ans)

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

Solution (Python):
import sys

n = int(input()) 
ans = 1
num_list = list(map(int, input().split()))
for i in range(n):
	if(num_list[i] == 0):
		print(0)
		sys.exit(0)

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

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

ans = 1
flag = 0

if i.count(0) > 0:
    print(0)
    flag = 1

if flag == 0:
    for x in range(len(i)):
        ans = ans * i[x]
        if ans > 1000000000000000000:
            flag = 1
            break

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

Solution (Python):
def main():
    _ = input()
    a = sorted(list(map(int, input().split())), reverse=True)
    if a[-1] == 0:
        print(0)
        return
    x = 1
    m = 10 ** 18
    for i in a:
        if i < 2:
            continue
        x *= i
        if x > m:
            print(-1)
            return
    print(-1 if x > 10 ** 18 else x)


if __name__ == '__main__':
    main()

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

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

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

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





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

Solution (Python):

n = int(input())
a = list(input().split(' '))

def doit(n,a):
  m = 1
  for i in range(n):
    m = m*int(a[i])
    if m > 1000000000000000000:
        for y in range(i+1, n):
            if a[y] == '0':
                return 0
        return -1
    elif m==0:
        return 0



  return m
 
print(doit(n,a))

Solution (Python):
import array


n = int(input())
a=[]
a=input().split(" ")
f=0
f1=0
b=0
for i in a:
    if int(i) == 0:
        print("0")
        f1=1
        break
        

sum =1
if f1==0:
    for i in a:
        sum=sum*int(i)
        if sum>1e18:
            f=1
            print("-1")
            break
    


if f==0 and f1==0:
    print(sum)

Solution (Python):
import numpy as np
N = int(input())
A = list(map(int,input().split()))
B = len(A)
ans = 1
a = 0
for a in range(B) :
    ans = ans*A[a] 
    if ans > 10**18 :
        if 0 in A :
            ans = 0
        else :
            ans = -1 
        break
    else :
        a += 1
print(ans)

Solution (Python):
def main():
    n = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    limit = 10 ** 18
    

    if A[-1] == 0:
        print(0)
    elif A[0] > limit:
        print(-1)
    else:
        ans = A[0]
        for i in range(1, n):
            ans *= A[i]
            if ans > limit:
                print(-1)
                exit()

        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
  print(0)
else:
  p = 1
  f = True
  for i in a:
    p *= i
    if(p > 1000000000000000000):
      f = False
      break
  if(f):
    print(p)
  else:
    print(-1)

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

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

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

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

a.sort()

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

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

Solution (Python):
num = int(input())
numList = list(map(int, input().split()))
max = 1000000000000000000
flg = True
result = 1

if 0 in numList:
    print(0)
else:
    for i in range(num):
        result *= numList[i]
        if result > max:
            flg = False
            break
    if flg:
        print(result)
    else:
        print(-1)

Solution (Python):
import sys

if __name__ == "__main__":
 
    N = int(input())
 
    P = list(map(int,input().split()))

    if(0 in P):
        print(0)
    else:
        P.sort()

        mult = 1
        for i in P:
            mult *= i 
            if (mult > 10 ** 18):
                print(-1)
                sys.exit()

        print(mult)

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

Solution (Python):
import sys

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

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

flg=False
a = 1
for i in l:
	a *= i
	if a>10e17:
		flg=True
		break
 
if flg:
	print(-1)
else:
	print(a)