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())
num = sorted([int(e) for e in input().split(" ")])
ans = 1
for a in num:
    ans *= a
    if(ans > 10 ** 18):
        print(-1)
        break
    elif(ans == 0):
        print(0)
        break
else:
    print(ans)

Solution (Python):
N = int(input())
num = sorted([int(e) for e in input().split(" ")])
lim = 10 ** 18
i = -1
ans = 1
for a in num:
    ans *= a
    if(ans > lim):
        print(-1)
        break
    elif(ans == 0):
        print(0)
        break
else:
    print(ans)

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

Solution (Python):


n = int(input())
numlist = list(map(int, input().split()))
ans = 1;

if 0 in numlist:
    ans = 0
else:
    for i in numlist:
        ans *= i
        if ans > 10**18:
            ans = -1
            break

print(ans)

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

num = 1
if 0 in a:
  num = 0
  
else:
  for k in range(n):
      num *= a[k]
      if num > 10**18:
        num = "-1"
        break

print(num)

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

if 0 in x: ans=0

for i in x:
    ans*=i
    if ans > 1000000000000000000:
        print(-1)
        exit()

print(ans)

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

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

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

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

print(c)

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

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

out_range = 10**18

ans=1
if  0 in P:
    print(0)
    exit()

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

print(ans)

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

Solution (Python):
def solve(A):
    if 0 in A:
        return 0

    product = 1

    for a in A:
        product *= a

        if product > 10 ** 18:
            return -1

    return product


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

print(solve(A))

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

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):
n=int(input())
A=list(map(int,input().split(" ")))
ans=1
POW=pow(10,18)
check=False
answer=1
for i in range(n):
  ans*=A[i]
  if ans>POW:
    ans=0
    check=True
    answer=-1
  if A[i]==0:
    answer=0
if answer<1:
  print(answer)
else:
  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 x in A:
		prod = prod*x
		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:
  result=1
  for i in A:
    result*=i
    if result>10**18:
      result=-1
      break
  print(result)

Solution (Python):
t = int(input())
list_v = list(map(int,input().split()))
 
res = 1
if 0 in list_v:
  res = 0
else:
  for v in list_v:
    res *= v
    if res > 10**18:
      res = -1
      break
print(res)

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

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

a.sort(reverse=True)
ans = 1

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

print(ans)

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

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

print(ans)

Solution (Python):
t = int(input())
list_v = list(map(int,input().split()))
 
res = 1
if 0 in list_v:
  res = 0
else:
  for v in list_v:
    res *= v
    if res > 10**18:
      res = -1
      break
print(res)

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

if mult <= 1e18:
  print(mult)

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

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

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

print(kotae)

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

Solution (Python):

import numpy as np
 
n = int(input())
numlist = list(map(int, input().split()))
ans = 1;

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

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

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

Solution (Python):
tenzyou=10**18
input()
A=[int(i) for i in input().split()]
if 0 in A:
  print(0)
  exit()
sortedA=sorted(A)[::-1]
multi = 1
for a in A:
  multi *= a
  if multi > tenzyou:
    print(-1)
    exit()

print(multi)

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

Solution (Python):
import math
n=int(input())
a=[int(x) for x in input().split()]
a_log=[]
if 0 not in a:
  for i in a:
    i_log=math.log10(i)
    a_log.append(i_log)
  
  if sum(a_log)>18:
    print("-1")
  else:
    for i in range(n-1):
  	  a[i+1]*=a[i]
    if a[n-1]>10**18:
      print("-1")
    else:
      print(a[n-1])
else:
  print("0")

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

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

main()

Solution (Python):
a=int(input())
x=list(map(int, input().split()))
ans=1
x.sort()
for i in range(a):

	if x[i]!=1 and x[i]!=0:
		ans=ans*x[i]
	if ans>10**18:
		break
	if x[i]==0:
		ans=0
		break
if ans>10**18:
	print(-1)
else:
	print(ans)

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

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

Solution (Python):
import sys
l = 10**18
n = int(input())
A = list(map(int,input().split()))
S = 1
if 0 in A:
    print(0)
    sys.exit()
for i in range(n):
    S = S * A[i]
    if S > l:
        print(-1)
        break
if S <= l:
    print(S)

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

ans = 1

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

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

Solution (Python):
n = input()
l = map(int, raw_input().split())
ans = 1
for i in l:
    if i == 0:
        ans = 0
if (ans != 0):
    for i in l:
        if (ans * i) <= 1e18:
            ans = ans * i
        else:
            ans = -1
            break
print(ans)

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

res = 1

l.sort()

for i in l:
    res *= i
    if res > 10**18:
        res = -1
        break

print(res)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
c = 1
max = pow(10, 18)

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

Solution (Python):
x = input()
t = int(x)
x2 = input()
n = list(map(int, x2.split(" ")))


def main():
  if 0 in n:
    print(0)
    return
  p = 1
  for v in range(t):
    p *= n[v]
    if (p > 10 **18):
      print("-1")
      return
  print(p)

main()

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

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

print(num)

Solution (Python):
def main():
    N = input()
    str_num = input()
    num_list = str_num.split()
    
    if '0' in num_list:
        print(0)
        return
    
    answer = 1
    for num in num_list:
        answer *=int(num)
        if answer > 10**18:
            answer = -1
            break

    print(answer)

main()

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

Solution (Python):
import sys
inp = int(input())
lst = list(map(int,input().split()))
sum = 1
if 0 in lst:
    print(0)
    sys.exit(0)
else:
    num = 1;
    for i in range(inp):
        num *= lst[i]
        if num > 10 ** 18:
            print("-1")
            sys.exit()
    print(num)

Solution (Python):

import string

n = int(input())
a = list(map(int,input().split()))
res = 1
for i in range(n):
    res *= a[i]
    if(res>pow(10,18)):
      	break

if(res<=pow(10,18)):
    print(res)
elif(0 in a):
    print(0)
else:
    print(-1)

Solution (Python):



import sys
import copy

THREASHHOLD = 10 ** 18


def main():
    
    line = sys.stdin.readline()
    n = int(line.rstrip())

    
    line = sys.stdin.readline()
    list_a1_an = list(map(lambda x: int(x), line.rstrip().split(' ')))

    if 0 in list_a1_an:
        result = 0
    else:
        result = list_a1_an[0]
        for index in range(1, len(list_a1_an)):
            result = result * list_a1_an[index]
            if result > THREASHHOLD:
                result = -1
                break
    print(result)

    
    


if __name__ == '__main__':
    main()

Solution (Python):

import sys
import math
import numpy as np
import itertools

n = int(input())
a=1
ll = [int(i) for i in input().split()] 
ll.sort()

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

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

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

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

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

Solution (Python):
import sys
O = pow(10, 18)
N = int(input())
L = list(map(int, input().split()))
M = 1

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

for i in range(N):
    M = M * L[i]
    if O < M:
        print(-1)
        sys.exit()
    else:
        continue
print(M)

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

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

if __name__ == "__main__":
    main()

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

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

print(ans)

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

ans = 1


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

for i in range(n):
    if x[i] == 0:
        ans = 0
        break


print(ans)

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

flag = 0

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

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

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

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

print(ans)

Solution (Python):
import sys
n = int(input())
a = list(map(int, input().split()))
limit = 10 ** 18
res = 1

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

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

print(res)

Solution (Python):
c = int(input())
n_list = list(map(int, input().split()))

if min(n_list) == 0:
    print(0)
else:
    i = 1
    ERR = 10 ** 18
    flag = False
    for n in n_list:
        i = i * n
        if i > ERR:
            flag = True
            break

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

Solution (Python):
N = int(input())
max_value = 10**18
answer = 1
over = False
a = list(map(int, input().split()))


for i in range(N):
    answer *= a[i]
    if answer > max_value:
        over = True
        break

if 0 in a:
    print(0)
else:
    if not over:
        print(answer)
    else:
        print(-1)

Solution (Python):
import math
 
n=int(input())
arr=list(map(int,input().split()))
if 0 in arr:
  print("0")
  exit()
ans=1
for i in range(n):
  ans *= arr[i]
  if math.log10(ans) >= 18 and ans!=1000000000000000000:
    print("-1")
    exit()
print(ans)

Solution (Python):
input()
b = [int(i) for i in input().split()]

if 0 not in b:
  last = 1
  for i in b:
      last*=i
      if last > 10**18:
        last = -1
        break
    
else:
  last = 0
    
print(last)

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

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

if 0 in A:
  ans = 0
  N = 0

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

print(ans)

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

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

result = 1
for a in list_A:
    result *= a
    if result > 1e18:
        print(-1)
        exit()

print(result)

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

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

    if 0 in a:
        print(0)
        return
    for i in a:
        prod *= i
        if prod > 1e+18:
            print(-1)
            break
    else:
        print(prod)

if __name__ == "__main__":
    main()

Solution (Python):

import sys
input = sys.stdin.readline

def main():
  n = int(input().strip())
  a = list(map(int, input().strip().split()))
  result = 1
  LIMIT = 10**18
  if 0 in a:
    print(0)
    sys.exit()
  for i in a:
    result *= i
    if result > LIMIT:
      print(-1)
      sys.exit()
  print(result)

main()

Solution (Python):
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

def main():
    GI()
    CEIL = 10 ** 18

    xs = LGIS()

    prod = 1
    for x in xs:
        prod *= x
        if prod > CEIL:
            prod = -1
            break

    if prod == -1:
        print(0 if 0 in xs else -1)
    else:
        print(prod)

main()

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


solve()

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

Solution (Python):

n = int(input())
a = list(map(int, input().split()))
res = 1 
if 0 in a:
  res = 0
else:
  for num in a:
    res *= num
    if res > 10**18:
      res = -1
      break
print(res)

Solution (Python):

n = int(input())
a = list(map(int, input().split()))
res = 1 
if 0 in a:
  res = 0
else:
  a.sort(reverse=True)
  for num in a:
    res *= num
    if res > 10**18:
      res = -1
      break
print(res)

Solution (Python):

n = int(input())
a = list(map(int, input().split()))
res = 1 
if 0 in a:
  res = 0
else:
  for num in a:
    res *= num
    if res > 10**18:
      res = -1
      break
print(res)

Solution (Python):

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

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):
import sys
N=int(input())
a=list(map(int, input().split()))
s=1

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

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

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





if __name__ == '__main__':
    solve()

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

ans = 1
flag_overflow = False
flag_zero = False
for a in A:
  if(flag_overflow) :
    if(a == 0) :
      flag_zero = True
  else :
    ans *= a
    if(ans > 10 ** 18) :
      flag_overflow = True

if(flag_zero) :
  print(0)
elif(flag_overflow) :
  print(-1)
else :
  print(ans)

Solution (Python):
def cal():
    n = int(input())
    lst = list(map(int,input().split()))
    if 0 in lst:
    	return 0
    else:
        prod = 1
        for a in lst:
            prod *= a
            if prod > 1000000000000000000:
                return -1
    return prod
print(cal())

Solution (Python):


import numpy as np

N = int(input())

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

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

mul = A[0]

for i in A[1:]:
    if 1000000000000000000 / i < mul:
        print(-1)
        exit(0)
    mul *= i

if mul > 1000000000000000000:
    print(-1)
    exit(0)

print(mul)

Solution (Python):


import numpy as np

N = int(input())

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

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

mul = A[0]

for i in A[1:]:
    if 1000000000000000000 / i < mul:
        print(-1)
        exit(0)
    mul *= i

if mul > 1000000000000000000:
    print(-1)
    exit(0)

print(mul)

Solution (Python):


import numpy as np

N = int(input())

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

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

mul = A[0]

if np.sum(A < 0) % 2 == 1:
    for i in A[1:]:
        mul *= i
else:
    for i in A[1:]:
        if 1000000000000000000 / i < mul:
            print(-1)
            exit(0)
        mul *= i

if mul > 1000000000000000000:
    print(-1)
    exit(0)

print(mul)

Solution (Python):
n=int(input())
m=1
inf=10**18
lol=0
l=list(map(int,input().split()))
if 0 in l:
    print(0)
else:

    for i in l:
      m=m*i
      if(m>inf):
        lol=1
        break
    if(lol):
      print(-1)
    else:
      print(m)

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

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

input = stdin.readline

n = int(input())
arr = list(map(int, input().split()))
arr.sort()
mul = 1
for x in arr:
	mul *= x
	if mul > 10 ** 18:
		print(-1)
		exit(0)
print(mul)

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

main()

Solution (Python):
def main():
    
    MAX_RESULT = 1000000000000000000
    
    N = int(input())
    A = [int(x) for x in input().split()]
    
    if 0 in A:
        result = 0
        print(result)
        return
    
    result = 1
    
    for x in A:
        result *= x
        if result > MAX_RESULT:
            print(-1)
            return
    print(result)
main()

Solution (Python):
n = eval(input())
a = input().split()
prod = 1
for i in range(0, n):
    a[i] = int(a[i])
a = sorted(a)
for i in range(0, n):
    prod *= int(a[i])
    if prod > 1e18:
        break
if prod > 1e18:
    print(-1)
else:
    print(prod)

Solution (Python):
_ = input()
nums = list(map(int,input().split()))
flg = True

ans = nums[0]

if 0 in nums:
  ans = 0
else:
  for num in nums[1:]:
    ans *= num
    if ans > 1e18:
      flg = False
      break
ans = ans if flg else -1
print(ans)

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
ans = 1
for i in l:
    ans *= i
    ans = min(ans, 10**18 + 1)

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

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

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

Solution (Python):
def multipilation():
    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)
    
multipilation()

Solution (Python):
itl = lambda: list(map(int, input().strip().split()))


def solve():
    L = 10 ** 18
    N = int(input())
    A = itl()
    for i in range(N):
        if A[i] == 0:
            return 0
            
    curr = 1
    for i in range(N):
        curr *= A[i]
        if curr > L:
            return -1
    return curr


if __name__ == '__main__':
    print(solve())

Solution (Python):
N = input()
Ai = input().split()
Ai = [int(Ai[k]) for k in range(int(N))]
K = Ai[0]
T = True
for j in range(int(N)):
  if Ai[j] == 0:
    K = 0
    T = False
    print(0)
for i in range(1,int(N)):
  K = K * Ai[i]
  if K > 1000000000000000000:
    K = -1
    break
if T:
  print(K)

Solution (Python):
n = int(input())
MX = 10**18
a = [int(x) for x in 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):
import sys

number = int(input())
box = list(map(int,input().split()))

for var in box:
    if var == 0:
        print("0")
        sys.exit()

overflow = 1e18
ans = 1
for var in box:
    if overflow/var < ans:
        print("-1")
        sys.exit()
    ans *= var

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

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

    if 0 in A:
        print(0)
        return

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

    print(total)


main()

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

Solution (Python):
import sys

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

ans = 1

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

for a in sorted(A, reverse=True):
    ans *= a
    if 10**18 < ans:
        print(-1)
        sys.exit()


print(ans)

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

Solution (Python):
n = int(input())
ans = 1
arr = [int(x) for x in input().split()]
arr.sort()
for each in arr:
    ans *= each
    if (ans > 1e18):
        print(-1)
        exit(0)
print(ans)

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

Solution (Python):

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

if min(As)==0:
    num=0
else:
    num=1
    for i in range(N):
        num *= As[i]
        if num>10**18:
            num=-1
            break

print(num)

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

Solution (Python):
n=int(input())
a=list(map(int,input().strip().split(" ")))
if 0 in a:
  ans=0
else:
  ans=1

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

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

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

Solution (Python):
a = int(input())
lis = list(map(int,input().split(" ")))
N = 1

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

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

print(N)

Solution (Python):



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

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

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

limit = 10**18
ans = 1

if 0 in given_list:
    print(0)
else:
    for i in given_list:
        ans *= i
        if ans > limit:
            print('-1')
            break
    if ans <= limit:
        print(ans)

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

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

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

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

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

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

ans = 1

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