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 math
n = int(input())

val = pow(10,18)
p = 1
a = list(map(int,input().strip().split()))
	
a.sort()

for i in range(n):
	p = p*a[i]
	if (p>val):
		p = -1
		break

print (p)

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

if 0 in a:
    print('0')
else:
    for b in a:
        res *= b
        if res > 1e18:
            print('-1')
            break
    else:
        print(res)

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

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *





































def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007




def main():
	N = inputInt()
	A = inputList()

	ans = 0
	for i,vol in enumerate(A):
		if i == 0:
			ans = vol
			continue
		ans = ans * vol
	
		if ans > 1000000000000000000:
			if 0 in A:
				print(0)
				sys.exit()
			else:
				print(-1)
				sys.exit()

	print(ans)






def bisect_left_reverse(a, x):
    if a[0] <= x:
        return 0
    if x < a[-1]:
        return len(a)
    
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] <= x:
            ok = mid
        else:
            ng = mid
    return ok

def bisect_right_reverse(a, x):
    if a[0] < x:
        return 0
    if x <= a[-1]:
        return len(a)
    
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] < x:
            ok = mid
        else:
            ng = mid
    return ok





def binary_search(list, item):
    low = 0
    high = len(list) - 1

    while low <= high:
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
            return mid
        if guess > item:
            high = mid -1
        else:
            low = mid + 1
    return None




def sunuke(N, K, mod=10**9+7):
	if N < K or K-1 < 0:
		return 0
	else:
		return combination(N-1, K-1, mod)




def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y




def H(n, r, mod=10**9+7):
	
	
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        
        
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv



def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)



if __name__ == "__main__":
	main()

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

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

print(ans)

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

Solution (Python):
import sys

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

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

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

if 0 in xs:
  print(0)
else:
  s = 1
  for x in xs:
    s *= x
    if s > 10 ** 18:
      print(-1)
      break
  else:
    print(s)

Solution (Python):
N=int(input())
n=list(map(int,input().split()))
A=n[0]

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

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
s = 1
over = False
zero = False

for i in range(N):
    if A[i] == 0:
        zero = True
        break

if zero:
    print(0)
else:
    for i in range(N):
        s *= A[i]
        if s > 10**18:
            over = True
            break
    if over :
        print('-1')
    else:
        print(s)

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

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

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

print(ans)

Solution (Python):
def main():
    n = int(input())
    A = list(map(int, input().split()))
    max_ans = 10 ** 18
    ans = 0
    if 0 in A:
        print(0)
        exit()

    for i, a in enumerate(A):
        if i == 0:
            ans = a
            continue

        ans = ans * a
        if ans > max_ans:
            print(-1)
            exit()

    if max_ans < ans:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()

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

an = 1

for x in a:
  an *= x
  if (an > 10**18):
    print(-1)
    exit(0)

print(an)

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

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

print(ans)

Solution (Python):
N = int(input())
List = list(map(int,input().split()))
import math
def seki(L):
  num = 1
  for i in L:
    num *= i
  return num
def Seki(L):
  if len(L) <= int(math.sqrt(N)):
    return seki(L)
  else:
    return Seki(L[:len(L)//2]) * Seki(L[len(L)//2:])
if Seki(List) <= 10**18:
  print(Seki(List))
else:
  print(-1)

Solution (Python):
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    if 0 in A:
        return 0
    prod = 1
    for i in range(N):
        if 10**18//prod < A[i]:
            return -1
        prod *= A[i]
    return prod
print(solve())

Solution (Python):
def main ():
  input()
  result = 1
  for i in map(int, input().split()):
    if i == 0:
      result = 0
      break
    
    if result == -1:
      continue
      
    result = result * i
    if result > 10 ** 18:
      result = -1
  
  return result

print(main())

Solution (Python):
n = int(input())
a = [int(e) for e in 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  
    else:
        print(ans)

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

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

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

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

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

print(x)

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

a.sort()
ans = 1
above = False
for x in a:
	ans *= x
	if ans > 10**18:
		above = True
		break

if not above:
	print(ans)
else:
	print(-1)

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

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

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

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

res = 1
from collections import Counter
count = Counter(al)
cc = count[0]

if cc >=1:
    print(0)
    exit()

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

else:        
    print(res)

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

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

ans = 1
if min(a) == 0:
    print('0')
    exit()
else:
    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):
import sys

N = int(input())
nums = list(map(int, input().split(' ')))

output = 1

if 0 in nums:
  print(0)
  sys.exit()
  
else:
  for x in nums:
    output *= x

    if output > 10**18:
      print(-1)
      sys.exit()

  print(output)

Solution (Python):
n=int(input())
array=list(map(int,input().split()))
ans=array[0]
for i in range(1,n):
    ans*=array[i]
    if ans>10**18:
        ans=-1
        break
if 0 in array:
    ans=0
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):
N = int(input())
org = input().split()
for i in range(len(org)):
    org[i] = int(org[i])
A = sorted(org)

answer = A[0]
overl = False

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

if overl:
    print("-1")
else:
    print(answer)

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 min(int_list) == 0:
            print(0)
        else:
            print(-1)
        break
else:
    print(ans)

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

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

LIMIT = 10**18

if 0 in set(As):
    print(0)
else:
    result = 1
    for a in As:
        result *= a
        if result > LIMIT:
            result = -1
            break
    
    print(result)

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

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

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

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

result = 1
for num in nums:
    result *= num

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

print(result)

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

Solution (Python):
def resolve():
    '''
    code here
    '''
    N = int(input())
    A_list = [int(item) for item in input().split()]

    is_zero = False
    is_over = False
    res = 1

    for item in A_list:
        if item == 0:
            is_zero = True
            break

    if is_zero:
        print(0)
    else:
        for item in A_list:
            res *= item

            if res > 10 ** 18:
                is_over = True
                break
        else:
            print(res)

        if is_over:
            print(-1)

if __name__ == "__main__":
    resolve()

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

results = A[0]
can = True
zero = False
for i in range(N):
    if A[i]==0:
        zero = True
        break

if zero:
    print(0)
else:
    for i in range(N):
        if i==0:
            continue
        results *= A[i]
        if results>10**18:
            can = False
            break

    if can:
        print(results)
    else:
        print(-1)

Solution (Python):
N = int(input())
input_list = [int(i) for i in input().split()]
max_num = 10 ** 18

sum_num = 1
if 0 in input_list:
    print('0')
else:
    for i in input_list:
        sum_num *= i
        if sum_num > max_num:
            sum_num = -1
            break
    print(sum_num)

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

Solution (Python):

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

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

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

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

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

    if A.__contains__(0):
        print(0)
        return

    ans = A[0]
    for v in range(1, N):
        if ans > 10 ** 18:
            print(-1)
            return
        else:
            ans *= A[v]
    if ans > 10 ** 18:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
N = int(input())
A = list(map(int, input().split()))
m = 1
if 0 in A:
    print(0)
    sys.exit()

for item in A:
    m *= item
    if m > 10 ** 18:
        print("-1")
        sys.exit()
print(m)

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

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

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

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import numpy as np

rl = sys.stdin.readline

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

Solution (Python):
N = int(input())
A = list(input().split())
A = [int(i) for i in A]
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):

from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    n = int(input())
    a = [int(x) for x in 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)
                return
        print(ans)


if __name__ == '__main__':
    main()

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

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

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

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

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

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):
        if(ans == -1):
            ans = a[i]
        else:
            ans *= a[i]
            if(ans > 1e18):
                ans = -1
                break
    print(ans)

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

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

print(sum)

Solution (Python):
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")



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


if __name__ == '__main__':
    main()

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

if 0 in a:
    print(0)

else:
    m=1

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

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

Solution (Python):
import math

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

flag_zero = 0
sum = 0
for i in range(n):
  if a[i]==0:
    flag_zero = 1
  else:
    sum += math.log10(a[i])

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

Solution (Python):

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


print(c)

Solution (Python):

n = int(input())
a = input().split()
res = 1
zero = 0
for e in range(n):
	if int(a[e]) == 0:
		zero = 1
for e in range(n):
	res *= int(a[e])
	if res > 1000000000000000000:
		break
if zero == 1:
	print(0)
elif res > 1000000000000000000:
	print(-1)
else:
	print(res)

Solution (Python):
"""
~~ Author : Bhaskar
~~ Dated : 31~05~2020
"""

import sys
from bisect import *
from math import floor,sqrt,ceil,factorial as F,gcd,pi
from itertools import chain,combinations,permutations,accumulate
from collections import Counter,defaultdict,OrderedDict,deque
from array import array
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
mod = 10**18
lcm = lambda a,b : (a*b)//gcd(a,b)
setbit = lambda x : bin(x)[2:].count("1")

def solve():
    n = int(sys.stdin.readline())
    a = list(map(int,sys.stdin.readline().split()))
    ans =  1
    flag = False
    for i in a:
        ans *= i
        
        if ans > mod:
            flag = True
            break
    if 0 in a:
        print(0)
    else:
        if not flag:
            print(ans)
        else:
            print(-1)

if __name__ == "__main__":
    solve()

Solution (Python):
import sys

MAX = 10**18

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

if 0 in A:
    print("0")
else:
    res = 1
    for a in reversed(sorted(A)):
        if a == 1:
            break
        res *= a
        if res > MAX:
            print("-1")
            sys.exit()
    print(res)

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

b = 10 ** 18
cnt = 1

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

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

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


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    limit = 10 ** 18

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

    ans = 1
    for i in a:
        ans *= i
        if ans > limit:
            ans = -1
            break

    print(ans)


if __name__ == '__main__':
    main()

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


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

Solution (Python):
N=int(input())
A=[int(x) for x in input().split()]
x=1
P=10**18
if 0 in A:x=0 
else:
  for a in A:
    x*=a
    if x>P:
      x=-1
      break
print(x)

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
res = 1
for a_i in a:
    if 0 == a_i:
        print(0)
        exit(0)
    elif res > 10 ** 18:
        continue
    else:
        res *= a_i

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

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

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

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

MAX=10**18
ans = 1
fover=False
fzero=False
for A in As:
    if A==0:
        fzero=True
        break
    if not fover:
        ans *= A
        if ans > MAX:
            fover=True

if fzero:
    print(0)
elif fover:
    print(-1)
else:
    print(ans)

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

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
from heapq import *
import sys

INF = 10 ** 17
MOD = 1000000007

from fractions import *
def inverse(f):
    
    return 1/f


def combmod(n, k, mod=MOD):
    ret = 1
    for i in range(n - k + 1, n + 1):
        ret *= i
        ret %= mod

    for i in range(1, k + 1):
        ret *= pow(i, mod - 2, mod)
        ret %= mod

    return ret
def bunsu(n):
    ret = []
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            tmp = 0
            while(True):
                if n % i == 0:
                    tmp += 1
                    n //= i
                else:
                    break
            ret.append((i, tmp))

    ret.append((n, 1))
    return ret

def solve():
    lim = 10 ** 18
    n = getN()
    nums = getList()
    if 0 in nums:
        print(0)
        return
    ans = 1
    for num in nums:
        ans *= num
        if ans > lim:
            print(-1)
            return

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

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

Solution (Python):

n = int(input())

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

  

  

maxa = 10 **18

ans = 1
if min(a) == 0:
  ans = 0

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

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

Solution (Python):
N = int(input())
A = [0] * N
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 > 1000000000000000000:
            print(-1)
            break
        if i == N - 1:
            print(ANS)

Solution (Python):
import numpy as np
import math
import collections

N = 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()

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

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

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

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

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

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

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

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

if ans <= 1000000000000000000 and not already:
    print(ans)

Solution (Python):
n = int(input())
arr = []

z=False
for x in input().split(' '):
    if x == '0':
        z = True
    arr.append(int(x))
if z == True:
    print(0)

else:
    ans = 1
    for x in arr:
        ans *= x
        if ans > int(1e18):
            print(-1)
            exit(0)
    
    print(ans)

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

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

  A.sort()

  m = 10 ** 18
  ans = A[0];

  if(A[0] == 0):
    ans = 0;
  else:
    for i in range(1, N):
      ans *= A[i]

      if(ans > m):
        ans = -1
        break

  print(ans)

if __name__ == "__main__":
  main()

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

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

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

Solution (Python):
def intlist(x):
    y = []
    for i in range(len(x)):
        y.append(int(x[i]))
    return y
N = int(input())
A = intlist(input().split())
M = 1

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

Solution (Python):
def main():
    n = int(input())
    array = [int(x) for x in input().split()]
    mod = 10 ** 18
    ans = 1
    if 0 in array:
        print(0)
        return
    for x in array:
        ans *= x
        if ans > mod:
            print(-1)
            return
    print(ans)


if __name__ == '__main__':
    main()

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

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

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

print(ans)

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