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 os
import sys
from math import *
from collections import *

from bisect import *
from io import BytesIO, IOBase
def vsInput():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]




n=Int()
a=array()
ans=1
if(0 in a):
    print(0)
    exit()
for i in a:
    ans*=i
    
    if(ans>10**18):
        ans=-1
        break
print(ans)

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

ans = 1

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

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
 
now = 1
ok = False
 
a.sort()
 
for i in range(len(a)):
	now *= a[i]
	if now > 1000000000000000000 :
			print(-1)
			ok = True
			break
 
if ok == False:
	print(now)

Solution (Python):
import sys

input = sys.stdin.readline

N = int(input())
x = sorted(list(map(int, input().split())))
t = 1

for num in x:
    t = t * num
    if t > 10 ** 18:
        print(-1)
        sys.exit()

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

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
x = sorted(list(map(int, input().split())))
t = 1
for num in x:
    t = t * num
    if t > 10 ** 18:
        print(-1)
        sys.exit()

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

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

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

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

ans = 1
thres = 10**18

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

for i in A:
  ans = i * ans
  if ans > thres:
    print(-1)
    sys.exit()

print(ans)

Solution (Python):
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))


def resolve():
    n = ii()
    a = mi()
    if 0 in a:
        print(0)
        return
    res = 1
    for i in a:
        res = res * i
        if(res > 10**18):
            print(-1)
            return
    print(res)

if __name__ == "__main__":
    resolve()

Solution (Python):
import sys

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

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

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

print(cur)

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

Solution (Python):
import sys
n=int(input())
a=input()
a0=a.split()
l=list()
b=1
q= "0" in a0
if q==True:
    print(0)
    sys.exit()
for i in range (n):
    a1=int(a0[i])
    b=b*a1
    if b>10**18:
        print(-1)
        sys.exit()
print(b)

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

if 0 in li_a:
    print(0)
    exit(0)
w = li_a[0]
for a in li_a[1:]:
    w = w * a
    if w > 10 ** 18:
        print(-1)
        exit(0)
else:
    print(w)
    exit(0)

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

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

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

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

Solution (Python):
from collections import Counter
def main():
    N = int( input())
    t = 10**18
    A = list( map( int, input().split()))
    ans = 1
    if Counter(A)[0] > 0:
        print(0)
        return
    for a in A:
        ans *= a
        if ans > t:
            print(-1)
            return
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
array=[]
array+=map(int,input().split())
flag=0
flag2=0
s=1
for m in range(len(array)):
    if array[m]==0:
        flag=1
        break
    s=s*array[m]
    if s>10**18:
        flag2=1
        break
flag3=0
if flag==1:
    print("0")
elif flag2==1:
    for i in range(m,len(array)):
        if array[i]==0:
            flag3=1
            print("0")
    if flag3==0:
        print("-1")

else:print(s)

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

if 0 in li:
  print(0)
else:
  result = 1
  flag = True
  for i in range(n):
    result *= li[i]
    if result > 10 ** 18:
      flag = False
      print(-1)
      break
  if flag == True:
    print(result)

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

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

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

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

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

ans = 1
if 0 in A:
  print(0)
  exit()
  
for r in A:
  ans *= r
  if ans > 1e18:
      print(-1)
      exit()
      
print(ans)

Solution (Python):
N = int(input())
A_list = [int(e) for e in input().split()]
A_list.sort(reverse=False)
ans = A_list[0]
for i in range(1,N):
    ans *= A_list[i]
    
    if ans > 10**18:
        print(-1)
        break
else:
    print(ans)

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

seki = 1

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

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

print(seki)

Solution (Python):
n=int(input())
b=list(map(int,input().split()))
b.sort()
an=1
c=0

for m in b:
  an*=m
  if(an>10**18):
    print("-1")
    c=1
    break
if(c!=1):
  print(an)

Solution (Python):


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

def main():
    print(solve())

main()

Solution (Python):
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 1
    for i in a:
        ans *= i
        if (ans > 1e18):
            print(-1)
            exit()
    print(ans)
main()

Solution (Python):
import math

def a():
    a,b = map(int,input().split())
    print(a * b)


def b():
    n = int(input())
    a = list(map(int, input().split()))
    max = pow(10,18)

    if 0 in a:
        print(0)
    else:
        mul = 1
        for i in a:
            mul *= i
            if mul > max:
                print(-1)
                break
        else:
            print(mul)



def c():
    print('')



def d():
    print('')


b()

Solution (Python):
from sys import exit, stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 1
if 0 in A:
    print(0)
    exit()
for a in A:
    ans *= a
    if ans > 10**18:
        print(-1)
        exit()
print(ans)

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

aa = set(A)
ans = 1
for i in range(len(A)):
    if(ans > 10**18):
        if(0 not in aa):
            ans = -1
            break
        else:
            ans = 0
    ans *= A[i]

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

Solution (Python):
n = int(input())
ans = 1
a = list(map(int, input().split()))
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):
a = int(input())
b = list(map(int,input().split()))
b.sort()
c  = 1
yon = 10**18
for i in b:
    c *= i
    if c > yon :
     print(-1)
     exit()
print(c)

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

input()
l = 10**18
a = 1
*b, = map(int, input().split())
if 0 in b:
    a = 0
else:
    for i in b:
        a *= i
        if a > l:
            a = -1
            break
print(a)

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

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

ok = True;
ans = 1;
a.sort();
for val in a:
    ans *= val;
    if(ans > 1e18):
        ok = False;
        break;
    elif(ans == 0):
        break;

if(ok):
    print(ans);
else:
    print(-1);

Solution (Python):
n = int(input())
a = [int(x) for x in input().split()]
if 0 in a: print(0)
else:
    m = 1
    flag = 0
    for i in a:
        m *= i
        if m > 1e+18:
            print(-1)
            flag = 1
            break
    if flag == 0: print(m)

Solution (Python):
import numpy as np

N=int(input())
A=np.ones(N)
a=np.ones(N)

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


a=sorted(A,reverse=True)

a_product=1
flag_1e18=False
flag_0=False

if a[N-1]==0:
  flag_0=True

for i in range(0,N,1):
  a_product=a_product*a[i]
  if a_product>1e18:
    flag_1e18=True
    break
  else:
    continue
    
if flag_1e18==True and flag_0==False:
  print(-1)
elif flag_0==True:
  print(0)
else:
  print(a_product)

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

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

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

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

Solution (Python):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    if A[N - 1] == 0:
        print(0)
        quit()
    ans = 1
    maxvalue = 10 ** 18
    for a in A:
        ans *= a
        if ans > maxvalue:
            print(-1)
            quit()
    print(ans)


if __name__ == "__main__":
    main()

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

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

v_max = 10 ** 18

result = 1
for v in l:
    
    result *= v
    
    if result > v_max:
        result = -1
        break
    
print(result)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
if A[0] == 0:
  print(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()))
is_zero = False
for i in a:
  if i == 0:
    is_zero = True
    break
if is_zero:
  print(0)
else:
  p = 1
  for i in a:
    p = p*i
    if p > 10**18:
      break
  if p > 10**18:
    p = -1
  print(p)

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

Solution (Python):

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

result = 1
if list_a[-1] == 0 :
    print(0)
else:
    for i in list_a:
        result = result * i
        if result > 1000000000000000000:
            print(-1)
            break

    if result <= 1000000000000000000:
        print(result)

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

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

print(ans)

Solution (Python):
n=int(input()); c=0
a=[int(x) for x in input().split()]
if 0 in a: 
    print(0)
else:
    p=1; m=10**18
    for i in a:
        if(p*i>m):
            c=1;break
        else: 
            p*=i
    if(c==0):
        print(p)
    else:
        print(-1)

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

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

Solution (Python):
from sys import stdin
import sys

n = stdin.readline().rstrip().split()
a = stdin.readline().rstrip().split()

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

total = 1
for i in a:
    total = total*int(i)

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

print(total)

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


max_x = 10 ** 18

result = 1
for x in a:
    result *= int(x)
    if result == 0 or result > max_x:
        break

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

Solution (Python):
N    = int(input())
A    = [int(x) for x in 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)):
        Pro = Pro*A[T]
        if Pro > pow(10,18):
            PrFF = 0
            print('-1')
            break

if PrF & PrFF:
    print(Pro)

Solution (Python):
def main():
  n = int(input())
  arr = list(map(int, input().split()))
  
  
  if 0 in arr:
    print(0)
    return 0
  res = arr[0]
  for a in arr[1:]:
    res *= a
    if res > 1000000000000000000:
      print("-1")
      return 0

  print(res)

main()

Solution (Python):
def main():
    N=int(input())
    a=list(map(int,input().split()))
    cal=1

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

    for i in range(N):
        cal*=a[i]
        if cal>10**18:
            print("-1")
            return

    print(cal)
    return


main()

Solution (Python):
def solve(string):
    n, *a = map(int, string.split())
    a = sorted(a)
    if a[0] == 0:
        return "0"
    ans = 1
    for _a in a[::-1]:
        ans *= _a
        if ans > 10**18:
            return "-1"
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Solution (Python):
def solve(string):
    n, *a = map(int, string.split())
    a = sorted(a)
    ans = 1
    for _a in a:
        ans *= _a
        if ans > 10**18:
            return "-1"
        if ans == 0:
            return "0"
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

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

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

print(ans)

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

Solution (Python):
n = int(input())
ans = 1
a = list(map(int,input().split()))
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())
alist = list(map(int,input().split()))
alist.sort()
mx = 10**18

ans = 1
for a in alist:
    ans *= a
    if ans > mx:
        print(-1)
        exit()
print(ans)

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

main()

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

for i in a:
    result = result * i

    

    if (result > pow(10, 18)):
        result = -1
        break

print(result)

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

nums = list(map(int,input().split(" ")))
s = 1
limit = 10**18
flag = False
for num in nums:
    s = s * num
    if s > limit:
        flag = True
        break

if flag:
    if 0 not in nums:
        print(-1)
    else:
        print(0)
else:
    print(s)

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

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n = int(rl())
	ans = 1
	lim = 10**18
	flag = False
	for a in rli():
		if flag:
			if a == 0:
				ans = 0
				print(0)
				return
			continue
		ans *= a
		if ans > lim:
			flag = True
	print(ans if not flag else -1)
	stdout.close()

if __name__ == "__main__":
	main()

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

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

temp=1
seki=0
for i in range(N):
    temp*=A[i]
    seki*=A[i]
    seki+=(temp//10**9)
    temp%=10**9
    
    if seki*10**9+temp>10**18:
        print(-1)
        exit()
    

print(seki*10**9+temp)

Solution (Python):
n = int(input())
m = list(map(int, input().split()))
ans = 1
if min(m) == 0:
    print(0)
else:
    m.sort(reverse=True)
    for i in m:
        ans *= i
        if ans > 1000000000000000000:
            ans = -1
            break
    print(ans)

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

Solution (Python):

def main():
    _, *A = open(0).read().split()
    if "0" in A:
        print(0)
        return
    prod = 1
    LIM = 10 ** 18
    for i in A:
        prod *= int(i)
        if prod > LIM:
            print(-1)
            return
    print(prod)


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    _, *A = map(int, open(0).read().split())
    if 0 in A:
        print(0)
        return 
    prod = 1
    LIM = 10 ** 18
    for i in A:
        prod *= i
        if prod > LIM:
            print(-1)
            return
    print(prod)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n = int(input())
    m = list(map(int, input().split()))
    ans = 1
    if min(m) == 0:
        print(0)
    else:
        m.sort(reverse=True)
        for i in m:
            ans *= i
            if ans > 1000000000000000000:
                ans = -1
                break
        print(ans) 
if __name__ == "__main__":
    main()

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

ans = 1
if 0 in a_lis:
    ans = 0
    
else:
    for i in a_lis:
        ans *= i
        if ans > pow(10, 18):
            ans = -1
            break
        
print(ans)

Solution (Python):
def main ():
	N = int(input())
	A = list(map(int,input(). split ()))
	if 0 in A:
		print(0)
		return
	prod = 1
	for a in A:
		prod *= a
		if prod > 1000000000000000000:
			print(-1)
			return
	print(prod)
main ()

Solution (Python):
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):
N = input()
A = input().split()
if '0' in A:
  print(0)
else:
  a = 1
  for i in A:
    a *= int(i)
    if a > 10**18:
        print(-1)
        exit()
  else:
    print(a)

Solution (Python):


n = input()
hairu = input()
kita = hairu.split(" ")
seki = 1

for c in kita:
    if c == "0":
        kita[0] = "0"

for c in kita:
    seki = seki * int(c)
    if seki > 10**18:
        break

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

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

Solution (Python):
'''
Fuad Ashraful Mehmet
University of Asia Pacific,Bangladesh
Date:2nd june 2020
'''

def Solve():
    n=int(input())
    ar=[int(x) for x in input().split()]
    if 0 in ar:
        print(0)
        exit()
    ans=1
    for x in ar:
        ans=ans*x
        if ans>10**18:
            print("-1")
            return
    print(ans)
Solve()

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

Solution (Python):


num = int(input())
s = list(map(int,input().split()))
res = 1
for i in s:
    res *= i
    if res >= 10 ** 18:
        break

if 0 in s:
    print(0)
elif res <= 10 ** 18:    
    print(res)
else:
    print(-1)

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

Solution (Python):
n = int(input())
MX = 10**18
a = list(map(int, input().split()))
for x in a:
    if x == 0:
        print(0)
        exit(0)
ans = 1
for x in a:
    ans *= x
    if ans > MX:
        print(-1)
        exit(0)
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:
        ans = -1
        break
print(ans)

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

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

print(ans)

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

print(ans)

Solution (Python):
def main ():
  N = int(input())
  A = list(map(int,input(). split ()))
  if 0 in A:
    print(0)
    return
  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
    
  print(prod)
main ()

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
if 0 in A:
    print(0)
else:
    ans = 1
    MAX = pow(10,18)
    for i in range(N):
        ans *= A[i]
        if ans > MAX:
            ans = -1
            break
    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 a:
    ans *= i
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)

Solution (Python):
input()
int_list = list(map(int, input().split()))
max_num = 10**18
ans = 1

if 0 in int_list:
    print(0)
    exit()
  
for i in int_list:
    ans *= i
    if ans > max_num:
        print(-1)
        break
else:
    print(ans)

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

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

ans = 1

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

print(ans)

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

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

main()

Solution (Python):
import math
import re
import copy
import sys

n = int(input())
a = list(map(int,input().split()))
ceil = 10 ** 18
ans = 1
if all([b > 0 for b in a]):
    for i in range(n):
        ans *= a[i]
        if ans > ceil:
            break
if any([b == 0 for b in a]):
    print(0)
elif ans > ceil:
    print("-1")
else:
    print(ans)

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

seki = 1
if 0 in a:
  print(0)
else:

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

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

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

	print(prod)


main()

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

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

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

if 0 in a:
    print(0)
else:
    for elem in a:
        ans *= elem
        if 10 ** 18 < ans:
            print(-1)
            exit()
    print(ans)

Solution (Python):
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


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


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

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

print(num)

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

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

if 0 in n_list:
    print(0)

else:

    product = 1
    for num in n_list:
        product = product * num

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


    print(product)

Solution (Python):
N = int(input())
L = list(map(int,input().split()))
dec = 10**18
Ans = 1

if(0 in L):
    print(0)
else:
    for i in L:
        Ans = Ans * i
        if dec < Ans:
            print(-1)
            break
    else:
        print(Ans)

Solution (Python):
N = int(input())
A=list(map(int, input().split()))
 
ans=1
c=0
 
while c<N:
    if A[c]==0:
        ans=0
    elif ans*A[c]>1000000000000000000:
        ans=1000000000000000001
    else :
        ans=ans*A[c]
    
    c+=1
    
if ans>1000000000000000000: print(-1)
else: print(ans)

Solution (Python):
def main():
    _ = int(input())
    a = [int(i) for i in input().split()]

    if 0 in a:
        print(0)
        return

    mul = 1
    for ai in a:
        mul *= ai
        if mul > 1000000000000000000:
            print(-1)
            return

    print(mul)

main()

Solution (Python):
N=int(input())
A=list(map(int, input().split()))
A=sorted(A,reverse=True)
if A[N-1] == 0:
  print(0)
  exit(0)

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

Solution (Python):
N=int(input())
A=list(map(int, input().split()))
A=sorted(A)
if A[0] == 0:
  print(0)
  exit(0)

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

Solution (Python):

import sys
from math import log10
from functools import reduce

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
log = 0.0
for a in A:
    if a == 0:
        print(0); exit()
    log += log10(a)

if log > 18:
    print(-1); exit()

answer = reduce(lambda x, y: x*y, A)
print(answer if answer <= 10 ** 18 else -1)

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

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

Solution (Python):
N = int(input())
nums = input().split()
mul = int(nums[0])
if str(0) in nums:
    mul = 0
else:
    for i in nums[1:]:
        mul *= int(i)
        if len(str(mul)) >= 19 and str(mul) != "1000000000000000000":
            mul = -1
            break
print(mul)