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
if 0 in A:
    print(0)
else:
    for i in A:
        ans *= i
        if ans > 1000000000000000000:
            print(-1)
            exit()
    print(ans)

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

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

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

A.sort()

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

print(ans)

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

for j in range(len(A)):
  if A[j] == 0:
    flag = 1
    ans = 0

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


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

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

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

ans = 1

has_zero = False
for a in A:
    if a == 0:
        has_zero = True



for a in A:
    
    
    ans *= a
    if ans > 1000000000000000000:
        ans = -1
        break

if has_zero is True:
    print('0')
else:
    print(ans)

Solution (Python):









import os
import sys




def main():
    n = int(input())
    A = list(map(int,input().split()))
    if 0 in A:
        print(0)
        return 
    sum = 1
    for a_ in A:
        sum*=a_
        if sum > 10**18:
            print(-1)
            return
    print(sum)    

if __name__ == "__main__":
    main()

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

Solution (Python):
n = int(input())
A = [*map(int,input().split())]
ok = 0
ans = 1
lim = 10**18
for i in range(n):
  ans *= A[i]
  if(ans>lim):
      ok =1
      break
if(ok and 0 not in A):
    print(-1)
elif(0 in A):
    print(0)
else:
    print(ans)

Solution (Python):
n = int(input())
li = list(map(int, input().split()))
ans = 1
flg = 0
for i in range(n):
  if flg==1 and li[i]!=0:
    continue
  elif li[i]==0:
    ans = 0
    break
  else:
    ans *= li[i]
  if(ans>1000000000000000000):
    flg = 1
if flg==1 and ans==0:
  print(ans)
elif flg==1:
  print(-1)
else:
  print(ans)

Solution (Python):
from collections import deque
n = int(input())
d = deque()

ar = [0 for _ in range(n)]

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

ar.sort()
res = 1
flag = 0

if(ar[0] == 0):
    res = 0
else:
    ar = [i for i in ar if i != 1]
    if(len(ar) < 50):
        for i in ar:
            res = res*i
            if(res > 10**18):
                print(-1)
                flag = 1
                break
    else:
        print(-1)
        flag = 1

if(flag == 0):
    print(res)

Solution (Python):
from functools import reduce
N = int(input())
A = [*map(int, input().split())]

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

mul = 1
for n in A:
    mul *= n
    if mul > 10 ** 18:
        print(-1)
        exit()
print(mul)

Solution (Python):
def f(a):
	res = 1
	for i in range(n):
		res *= int(a[i])
		if res > 10 ** 18:
			if zer(i):
				return 0
			else:
				return -1
	return res

def zer(i):
	for j in range(i, n):
		if a[j] == "0":
			return True
	return False
n = int(input())
a = input().split()

print(f(a))

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

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

ans=1

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

for a in a_list:
    ans*=a

    if ans > 1000000000000000000:
        print(-1)
        sys.exit(0)

print(ans)

Solution (Python):
s = int(input())
l = input().split()

if "0" in l:
    print(0)
else:
    p = int(l[0])
    flag = True
    for el in l[1:]:
        p *= int(el)
        if p > 10**18:
            print(-1)
            flag = False
            break
    if flag:
        print(p)

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

Solution (Python):

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

tmp = 1
A.sort()

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

Solution (Python):
n=int(input())
mul=1
limit=1000000000000000000
x=input().split()
for i in range (n):
    p=int(x[i])
    if(p==0):
        mul=0
        break
if(mul==0):
    print(mul)
else:
    for i in range (n):
        p=int(x[i])
        mul*=p
        if(mul>limit):
            break
    if(mul>limit):
      print(-1)
    else:
      print(mul)

Solution (Python):
import sys
def input():
  return sys.stdin.readline()[:-1]


n = input()
a = input().split()
r = 1

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

for i in range(len(a)):
  aa = int(a[i])
  r *= aa
  if r > pow(10, 18):
    print(-1)
    exit()

print(r)

Solution (Python):

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

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

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

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

product = 1
exe = 1
maxP = 1000000000000000000

for val in ar:
    product *= val
    
    if(product > maxP):
        product = -1
        break

for e in ar:
    if(e == 0):
        exe = 0

print(product * exe)

Solution (Python):
N = int(input())
AS = [int(x) for x in input().split()]
result = 1
for x in AS:
    if x == 0:
        result = 0
        break
    if result == -1:
        continue
    result *= x
    if result > 10 ** 18:
        result = -1

print(result)

Solution (Python):
import sys, io, os, re
import bisect
from pprint import pprint
from math import sin, cos, pi, radians, sqrt
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce

def array1(n): return [0] * n
def array2(n, m): return [[0] * m for x in range(n)]
def array3(n, m, l): return [[[0] * l for y in xrange(m)] for x in xrange(n)]

a = sys.stdin.readline().strip()
arr = list(map(int, sys.stdin.readline().strip().split()))
mod = 10**18

ans = arr[0]
for i in range(1, len(arr)):
    ans *= arr[i]
    if ans > mod:
        ans = -1
        break

if 0 in arr:
    ans = 0

print(ans)

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

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

Solution (Python):
import numpy as np
import functools
import operator

prod2 = functools.partial(functools.reduce, operator.mul)

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



val = 1
if 0 in nums:
    val = 0

else:
    for num in nums:
        val *= num
    
        if val > 1e18:
            val = -1
            break


print(val)

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

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

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

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

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

print(ans)

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


ans = 1
a.sort()

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

print(ans)

Solution (Python):
def main():
    N = int(input())
    A_i = list(map(int, input().split()))
    t = 10**18

    if 0 in A_i:
        print(0)
        return

    acc = 1
    for i in A_i:
        acc *= i
        if t < acc:
            print(-1)
            return

    print(acc)
    return


main()

Solution (Python):

import sys
readline = sys.stdin.buffer.readline

N = int(readline())
A = list(map(int, readline().split()))
A.sort(reverse=True)

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

for i, x in enumerate(A):
    if i == 0:
        result = x
        continue

    result = result * x

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

else:
    print(result)

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

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):
        if ans > 10 ** 9:
            if A[i] >= 10 ** 9:
                ans = -1
                break
            else:
                pass
        else:
            pass
        ans *= A[i]
        if ans > 10 ** 18:
            ans = -1
            break
        else:
            pass
    print(ans)

Solution (Python):

def main():
    import sys
    import math
    def input():
        return sys.stdin.readline()[:-1]
    N=int(input())
    A=list(map(int,input().split()))
    c=1
    if 0 in A:
        print(0)
        sys.exit()
        
    for x in A:     
        c=c*x
        if c>10**18:
            print(-1)
            sys.exit()

    print(c)
if __name__ == '__main__':
    main()

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

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

result = 1
for i in a:
    result *= i
    if result > pow(10, 18):
        print(-1)
        exit(0)

print(result)

Solution (Python):
n=int(input())
a=map(int,input().split())
val = 1
exceed = 0
for i in a:
	if(exceed==0 or i==0):
		val*=i
	if(val==0):
		print(0)
		exit(0)
	if(val>1000000000000000000):
		exceed=1
if(exceed==0):
	print(val)
else:
	print(-1)

Solution (Python):
import sys
input = sys.stdin.readline
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):

import math
n = int(input())
a= list(map(int,input().split()))
a.sort(reverse=1)

ans = a[0]

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

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

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

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

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

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

A.sort()
ans = 0

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

for i in A:
    if ans != 0:
        ans = ans * i
    else:
        ans = i
    if ans > 1000000000000000000:
        print("-1")
        exit()

print(ans)

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

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

Solution (Python):
N = int(input())
li = input().split()
a = 1
sikataganai = False
try:
  h = li.index('0')
  print(0)
  sikataganai = True
except:
  for i in range(N):
    a *= int(li[i])
    if a > 10 ** 18:
      print(-1)
      exit()
  if not sikataganai :
    print(a)

Solution (Python):

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

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

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

print(ans)

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

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

Solution (Python):
n=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:
        ans = -1
        break


print(ans)

Solution (Python):

N = int(input())
numlist = list(map(int, input().split()))
if 0 < numlist.count(0):
    print('0')
    quit()

total = 1
for i in numlist:
  total *= i
  if 10 ** 18 < total:
    print('-1')
    quit()

print(total)

Solution (Python):


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

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

Solution (Python):
def resolve():
    import numpy as np
    from decimal import Decimal

    n = int(input())
    A = np.array(list(map(Decimal, input().split())))
    if 0 in A:
        print(0)
        return

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

resolve()

Solution (Python):
import sys
N=int(input())
ans=1
numbers=input().split()
zero="0" in numbers
if zero:
  print(0)
  sys.exit()
for j in range(N):
  num=int(numbers[j])
  ans=ans*num
  if ans>1000000000000000000:
    print(-1)
    sys.exit()
print(ans)

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

for ele in a:
    ans *= ele
    if ans > MV :
        print(-1)
        exit()
print(ans)

Solution (Python):
def main():
	n = int(input())
	list1 = [int(t) for t in input().split()]
	list1.sort()
	ans = 1
	b = 0
	for i in range (0, n):
		ans = ans * list1[i]
		if int(ans) > int(1000000000000000000):
			print(-1)
			return
	print(ans)
	return

if __name__ == "__main__":
  
  main()

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
MAX = 10**18
ret = 1
flag = True
if 0 in A:
    print(0)
else:
    for a in A:
        ret *= a
        if ret > MAX:
            print(-1)
            flag = False
            break
    if flag and ret <= MAX:
        print(ret)

Solution (Python):
import sys
N = input()
A = list(map(int,input().split()))
B = False
total = 1
for a in A:
    if a == 0:
        print(0)
        sys.exit()
    elif total <=10**18:
        total *= a
    else:
        B = True
if B or total>10**18:
    print(-1)
else:
    print(total)

Solution (Python):
n=int(input())
arr=list(map(int, input().split()))
if 0 in arr:
  print("0")
else:
  done=False
  mul=1
  for i in range(len(arr)):
    if mul*arr[i]<=int(1e18):
      mul*=arr[i]
    else:
      print("-1")
      done=True
      break
  if not done:
    print(mul)

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

b=a[0]
if a.count(0)>0:
    print(0)
    sys.exit()

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

print(b)

Solution (Python):
import sys
read = sys.stdin.readline
n = int(input())
aaa = list(map(int, read().split()))
aaa.sort()
ans = 1
for a in aaa:
    ans *= a
    if ans == 0:
        break
    if ans > 10 ** 18:
        ans = -1
        break
print(int(ans))

Solution (Python):
import math
import fractions
import collections
import itertools
N=int(input())
A=list(map(int,input().split()))
A.sort()


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

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

A_str = input().split()

A = []

for Ai_str in A_str:
    Ai = int(Ai_str)

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

    A.append(Ai)

product = 1

for Ai in A:
    product *= Ai

    if product > 1000000000000000000:
        print(-1)
        exit()

print(product)

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

work = 1
exceeded = False
for i in a:
    work *= i
    if work > 1000000000000000000:
        exceeded = True
        break

if work > 1000000000000000000:
    exceeded = True

if exceeded:
    print(-1)
else:
    print(work)

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)
        break

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

Solution (Python):
import sys 
input = lambda : sys.stdin.readline().strip()
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    ans = 1
    ok = True
    for i in range(n):
        ans*=a[i]
        if ans>(10**18):
            ok = False
            break
    if ok:
        print(ans)
    else:
        print('-1')

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

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

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

print(ans)

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

total = 1
flag = 0
if 0 in inputs:
    print('0')
else:
    for i in range(len(inputs)):
        total = total * inputs[i]
        if total > 10 ** 18:
            print('-1')
            flag = 1
            break
    if flag == 0:
        print(total)

Solution (Python):
import sys
n=int(input())
s=input().split()
if '0' in s:
  print(0)
  sys.exit()
l=list(map(int,s))
max=10**18
ans=1
while n>0:
  ans *= l[n-1]
  n-=1
  if ans>max:
    print(-1)
    sys.exit()
print(ans)

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

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

ans,flag = 1,0
for elem in sorted(arr):
    ans = ans*elem
    if ans>1e18:
        flag = 1
        break
    if ans==0: break
    
if flag==1: print(-1)
else: print(ans)

Solution (Python):
n = int(input())
up = int("1"+"0"*18)

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

def calc(a):
    x = ans
    for i in range(1, len(a)):
        x = x * a[i]

        if (x > up):
            x = -1
            return x

    return x

if (0 in a):
    ans = 0
else:
    ans = calc(a)

print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *a = map(int, read().split())
if 0 in a:
    print('0')
    exit()
ans = 1
for x in a:
    ans = ans * x
    if ans > 10 ** 18:
        print('-1')
        exit()
print(ans)

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

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

Solution (Python):
import sys

t = 10**18


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

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

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

print(ans)

Solution (Python):
import sys

n = int(input())
ans = 1
ass = input().split(" ")

for b in ass:
	a = int(b)
	if ans == -1:
		if a == 0:
			ans = 0
	else:
		ans *= a
		if ans > 1000000000000000000:
			ans = -1;
		
print(ans)

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
ans = int(1)
flag = True

for i in a:
    if i == 0:
        print(0)
        flag = False

if flag:
    for i in range(n):
        ans = ans * a[i]
        if ans > int(1000000000000000000):
            flag  = False
            break

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

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

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

Solution (Python):
N = int(input())
num = input().split()
ans = int(num[0])
cov = 10**18
if ('0' in num):
  ans = 0  
else:
  for i in range (int(N)-1):
    if ans == -1 or ans == 0:
      break
    else:
      ans *= int(num[i+1])
    if int(ans) > int(cov):
      ans = -1
print(ans)

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

print(-1 if x>10**18 else x)

Solution (Python):



import sys
from collections import deque as deq

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

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

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

print(r)

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

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

print(ans)

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



arr = list(map(int, input().split()))
arr.sort()
p = 1
if 0 in arr:
	print(0)
else:
	for i in reversed(arr):
		p *= i
		if p > (10**18):
			print(-1)
			exit()
	print(p)

Solution (Python):
def b():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    max = 10**18
    if 0 in A:
        print(0)
        return

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

    print(ans)



if __name__ == "__main__":
    b()

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

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

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

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = 1
for u in a:
    
    if(ans==-1 and u!=0):
        continue
    if ans*u > 1000000000000000000:
        ans = -1
    else:
        ans *= u
print(ans)

Solution (Python):
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default
      
n = int(input())
la = list(map(int, input().split()))
import sys
if my_index(la, 0) > 0:
  print(0)
  sys.exit()

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

Solution (Python):
n = int(input()) 
a = list(map(int,input().strip().split()))[:n]
pro=1
f=1
a.sort()
for i in a:
  pro=pro*i
  if(pro>1000000000000000000):
    f=0
    print(-1)
    break
if(f==1):
  print(pro)

Solution (Python):
import sys
from bisect import bisect_left
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
lst = list(map(int, readline().split()))
lst.sort()
lst.reverse()
mul = 1
if 0 in lst : 
  print(0)
else :
  for x in lst :
 
    if(mul>10**18):
      mul = -1
      break
    mul*=x

  if mul> 10**18 :
    mul = -1

  print(mul)

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

LIMIT = 10 ** 18

zeroflg = 0
for a in A:
    if a == 0:
        zeroflg = 1
        break

if zeroflg == 1:
    res = 0
else:
    res = 1
    for a in A:
        if a == 0:
            res = 0
            break
        if res > LIMIT:
            break
    
        res = res * a













if res > LIMIT:
    print('-1')
else:
    print(res)

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

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

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

print(ans)

Solution (Python):
a=int(input())
res=1
flag=1
l=list(map(int, input().split()))
for i in l:
    if i==0:
        flag=0
if flag!=0:
    for i in l:
        res*=i
        if res>1000000000000000000:
            res=-1
            break
    if res>1000000000000000000:
        res=-1
else:
    res=0
print(res)

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

ans = 1
flag_over = False
flag_0 = False
len0 = 0

if 0 in A:
    flag_0 = True
for b in B:
    len0 += len(b) - 1
if len0 > 18:
    flag_over = True

if flag_0 == False and flag_over == 0:
    for a in A:
        ans *= a

if ans > 10**18:
    flag_over = True

if flag_0:
    print(0)
elif flag_over:
    print(-1)
else:
    print(ans)

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
s = 1
f = 1
x = 1000000000000000000
l.sort()
if l[0]==0:
  print(0)
elif l[0]==1 and l[-1]==1:
  print(1)
else:
  l = l[::-1]
  for i in l:
      s *= i
      if s>x:
          print(-1)
          f = 0
          break
  if f==1:
    print(s)

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

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

ans = 1

for i in range(0,n):
    if data[i] == 0:
        ans = 0

for i in range(0,n):

    ans *= data[i]

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

Solution (Python):
def main():
    if A.count(0) >= 1:
        print(0)
        return
    ans = 1
    for a in A:
        ans *= a
        if ans > L:
            print(-1)
            return
    print(ans)


if __name__ == "__main__":
    N = int(input())
    A = [int(a) for a in input().split()]
    L = 10**18
    main()

Solution (Python):
N = int(input())
A = input().split(" ")
s = 1

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

for i in range(N):
  if s ==0:
    break
  if s > 10**18:
    break
  s = s*int(A[i])


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

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

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

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

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

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

ans=1

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

print(ans)

Solution (Python):

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

Con = 10**18

ans = 1
if A.__contains__(0):
    print(0)
else:
    for i in A:
        if ans <=Con:
            ans*=i
        else:
            break
    print(ans if ans<=Con else "-1")

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

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

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


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


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

print(ans)

Solution (Python):

import math
n = int(input())
a = list(map(int, input().split()))
a.sort()
q = 1
f = 0
for i in a:
    q *= i
    if q > 10**18:
        f = 1
        break
if f == 1:
    print(-1)
else:
    print(q)

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

Solution (Python):
import numpy as np
N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = 1

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