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

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

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

print(ans)

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

Solution (Python):
N = int(input())
nums = [int(s) for s in input().split()]
nums.sort()
LIMIT = 10 ** 18

def multiply(nums):
    result = 1
    for num in nums:
        result *= num
        if result > LIMIT:
            print(-1)
            return
    print(result)

multiply(nums)

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

print(ans)

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

Solution (Python):




def input_int():
    return int(input())



def int1(x):
    return int(x) - 1



def input_to_int_map():
    return map(int, input().split())



def input_to_int_tuple():
    return tuple(map(int, input().split()))



def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n = input_int()
    a = input_to_int_tuple()

    a_sum = 1
    check = 10 ** 18
    if 0 in a:
        return 0

    for _a in a:
        a_sum *= _a
        if a_sum > check:
            return -1

    return a_sum


if __name__ == "__main__":
    print(main())

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

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

A = [int(x) for x in input().split(' ')]
res = 1
if 0 in A:
  res = 0
else:
  for a in A:
    res *= a
    if res > 1e18:
      res = -1
      break 

print(res)

Solution (Python):
import sys


N = int(input().strip())


A = [int(x) for x in input().strip().split(" ")]
if 0 in A:
    print(0)
    sys.exit(0)

m = 1
l = pow(10, 18)
for a in A:
    m *= a
    if m > l:
        print("-1")
        sys.exit(0)
print(m)

Solution (Python):
n=input()

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


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

num=1

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

print(num)

Solution (Python):


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


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

Solution (Python):
import numpy as np

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

b = np.array(a)
c = np.count_nonzero(b)
if len(b) != c:
    print(0)
    exit()
ans = 1

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

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

Solution (Python):
import sys
from collections import deque
import copy
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    for i in range(N):
        if A[i] == 0:
            print(0)
            sys.exit()
    count = 1
    for i in range(N):
        count *= A[i]
        if count > 10 ** 18:
            print(-1)
            sys.exit()
    print(count)

if __name__ == '__main__':
    main()

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

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

res = 1
if 0 in A:
    print(0)
    exit()

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

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

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

    print(ans)

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

print(res)

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

A.sort(reverse=True)

if A[N-1] == 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()))
flag = 0

ans = 1

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

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

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


if __name__ == '__main__':
    resolve()

Solution (Python):
import sys, math,os
from io import BytesIO, IOBase


from collections import defaultdict as dd, deque, Counter

def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
sys.setrecursionlimit(100000)
INF = float('inf')
mod = int(1e9)+7


def main():

    n=int(data())
    A=mdata()
    A.sort()
    ans=1
    l=10**18
    for i in A:
        ans*=i
        if ans>l:
            out(-1)
            exit()
    out(ans)


if __name__ == '__main__':
    main()

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

ans = 1
for x in arr:
    ans *= x

    if ans > int(1e18):
        ans = -1
        break

    if ans == 0:
        break

print(ans)

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

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

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

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

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

p108 = pow(10,18)
ans = A[0]
for a in A[1:]:
  ans *= a
  if ans > p108:
    print(-1)
    exit()

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

print(ans)

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

M = 10 ** 18
c = 1;
for x in a:
    c *= x
    if c > M:
        print(-1)
        exit()
print(c)

Solution (Python):




import math
import sys
import bisect
import heapq  
from collections import deque
inf = 10 ** 18
mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
tmp = 1
for i in a:
    if i == 0:
        print(0)
        sys.exit()
for i in a:
    if i > inf:
        print(-1)
        sys.exit()
    tmp = tmp*i
    if tmp > inf:
        print(-1)
        sys.exit()
print(tmp)

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
if a.count(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()))
if 0 in A:
    print(0)
    exit()
ans = 1
for a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        exit()

print(ans)

Solution (Python):
import sys

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

if As.count(0) > 0:
    print(0)
    sys.exit()

ans = 1
for A in As:
    ans *= A
    if ans > 10**18:
        ans = -1
        break

print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
if(a.count(0) != 0):
	print(0)
	exit(0)
m = 1e18
p = 1
for i in a:
	if(p*i > m):
		print(-1)
		break
	p *= i
else:
	print(p)

Solution (Python):






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

ans = 1
for i, v in enumerate(a):
  ans *= v
  if ans > 10**18:
    ans=-1
    break

if 0 in a:
  ans = 0

print(ans)

Solution (Python):
import math

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

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

ans = li[0]
del li[0]

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

print(ans)

Solution (Python):
import sys


import math
import collections

import bisect
import itertools
import fractions

import copy
import heapq
import decimal

import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))





def main():
    n = ni()
    a = na()
    a.sort()

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

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
n = int(input())
ls = [int(u) for u in input().split()]

ls.sort()
ans = 1

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

print(ans)

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

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

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    a = list(map(int, readline().split()))
    a.sort()
    
    cur = 1
    for x in a:
        cur *= x
        if cur > 10 ** 18:
            print(-1)
            sys.exit()

    print(cur)


if __name__ == '__main__':
    main()

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

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

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

if 0 in a_ls:
	ans=0

print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))
n=n_in()
A=l_in()

res = 1

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


for a in A:
    res *= a


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

Solution (Python):
N = int(input())
arr = [int(x) for x in input().strip().split()]
ans = 1

if 0 in arr:
    ans = 0
else:
    for x in arr:
        ans *= x
        if ans > 1e18:
            ans = -1
            break

print(ans)

Solution (Python):

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


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


print(ans)

Solution (Python):
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
A = rl()

lim = pow(10,18)

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

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

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

if min(A)==0:
    print(0)
    exit()

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

print(ans)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")


def solve():
    n = II()
    a = LI()
    a.sort()
    ans = 1
    for ai in a:
        ans *= ai
        if ans > 10 ** 18:
            print(-1)
            return
    print(ans)
    return



if __name__ == '__main__':
    solve()

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

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

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

Solution (Python):
n = int(input())
list_A = list(map(int, input().split()))
ans = 1
p = pow(10, 18)
list_A.sort()
for num in list_A:
    ans *= num
    if ans > p:
        ans = -1
        break

print(ans)

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


if __name__ == '__main__':
    main()

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

inf=10**18
ans=1
if 0 in a:
    print(0)
    sys.exit()


for x in a:
    ans*=x
    if ans>inf:
        print(-1)
        sys.exit()
print(ans)

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque 


from collections import Counter

from itertools import accumulate

from heapq import heapify,heappop,heappush


from functools import lru_cache


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 10**9+7
    

    N = int(input())
    
    A = tuple(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)




if __name__ == "__main__":
    main()

Solution (Python):

import math 













mod = int(1e9+7)

INF = 1<<29
lINF = 1<<35

def readInt():
    return list(map(int,input().split()))

def main():
    n = int(input())
    a = readInt()
    a.sort()
    if a[0]==0:
        print(0)
        return
    ans = a[0]
    for i in range(1,n):
        ans *= a[i]
        if ans>int(1e18):
            print(-1)
            return
    print(ans)
    return

if __name__=='__main__':
    main()

Solution (Python):
n=int(input())
ar=list(map(int,input().split()))
s=1
ex=1e18
z=1
for i in ar:
    s*=i
    if s>ex:
        z=0
        break
if ar.count(0)>0: print(0)
elif z: print(s)
else: print(-1)

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

limit = 10 ** 18
result = A[0]
for a in A[1:]:
    result *= a
    if result > limit:
        print(-1)
        exit()
print(result)

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

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

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

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

print(ans)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N, *A = map(int, read().split())
    ans = 1
    lim = pow(10,18)
    
    try:
        zero = A.index(0)
        print(0)
        return
    except:
        pass
    
    for a in A:
        ans *= a
        if ans > lim:
            print(-1)
            return
            
    print(ans)
    return


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

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

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

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

print(ans)

Solution (Python):

import sys


def solve(N: int, A: "List[int]"):
    result = 1
    if 0 in A:
        print(0)
        return
    for n in range(N):
        result *= A[n]
        if result > (10 ** 18):
            print('-1')
            return
    print(result)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)

if __name__ == '__main__':
    main()

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

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

    print(ans)

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

Solution (Python):
import sys

input = sys.stdin.readline
INF = 10 ** 18


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

    if 0 in A:
        ans = 0
    else:
        ans = 1
        for a in A:
            ans *= a
            if ans > INF:
                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)
    exit()
ans = 1
for a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)

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

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

Solution (Python):
from collections import deque
import sys

def input():
    return sys.stdin.readline().rstrip()

N = int(input())
li = list(map(int, input().split()))
li.sort()

ans = 1
for i in li:
    ans *= i
    if (ans > int(1e18)):
        print(-1)
        sys.exit(0)

if ans > int(1e18):
    print(-1)
else:
    print(ans)

Solution (Python):
input = raw_input

n = int(input())
As = map(int, input().split(" "))

if 0 in As:
    out = 0
else:
    m = 10 ** 18 
    for i, a in enumerate(As):
        if a > m:
            out = -1
            break

        if i == 0:
            out = a
        else:
            out *= a

        if out > m:
            out = -1
            break

print(out)

Solution (Python):




if(__name__ == '__main__'):
    
    n = int(input())
    a_list = list(map(int, input().split(" ")))
    a_list.sort()

    ans = 1

    for elem in a_list:
        ans *= elem
        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 ai in a:
    ans *= ai
    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 a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

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

Solution (Python):
import sys
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)
        sys.exit()
print(ans)

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

INF = 10 ** 18 + 1
ans = 1
for e in a:
    ans *= e
    ans = min(ans, INF)

if ans == INF:
    ans = -1

print(ans)

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

ans=1
INF = pow(10,18)
if 0 in L:
    print(0)
    exit()
for l in L:
    ans*=l
    if ans>INF:
        print(-1)
        exit()
print(ans)

Solution (Python):
INF = 10**18
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 > INF:
      ans = -1
      break
  
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]





N = ii()
A = li()
ans = 1
for num in A:
    ans *= num
    if ans > 10**18:
        if 0 in A:
            print(0)
        else:
            print(-1)
        exit()

print(ans)

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

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

Solution (Python):
import sys

N = int(sys.stdin.readline().rstrip())

A = [int(x) for x in sys.stdin.readline().rstrip().split(" ")]

INF = 10 ** 19

answer = 1

for x in A:
	answer *= x
	if answer > INF:
		answer = INF

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

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

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

ans = nums[0]
if 0 in nums:
	ans = 0
else:
	for x in nums[1:]:
		ans *= x
		if ans > 10 ** 18:
			ans = -1
			break
print(ans)

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

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

if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys

def main():
    n = int(input())
    A = list(map(int, input().split()))
    co = 10**18

    ans = 1

    if 0 in A:
        print(0)
        return

    for i_A in A:
        ans *= i_A
        if ans > co:
            print(-1)
            return
    
    print(ans)
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

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

Solution (Python):
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N = input_number()
    A = input_number_list()
    limit = 10**18
    ans = 1
    if 0 in A:
        print(0)
    else:
        for i in A:
            ans *= i
            if ans > limit:
                print("-1")
                break
        else:
            print(ans)
if __name__ == '__main__':
    main()

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

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

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
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()))
A = sorted(A)
ans = 1
for a in A:
  ans *= a
  if ans > 10**18:
    print(-1)
    exit()
if ans > 10**18:
  print(-1)
else:
  print(ans)

Solution (Python):
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub, or_

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())

def read_int_n():
    return list(map(int, input().split()))

def read_float():
    return float(input())

def read_float_n():
    return list(map(float, input().split()))

def read_str():
    return input().strip()

def read_str_n():
    return list(map(str, input().split()))

def error_print(*args):
    print(*args, file=sys.stderr)



def main():
    n = read_int()
    a = read_int_n()
    a.sort()

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

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
r = 1
f = False
for i in A:
    r *= i
    if r > 1000000000000000000:
        f = True
        break
if 0 in A:
    print(0)
elif f:
    print(-1)
else:
    print(r)

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

Solution (Python):
n = int(input())
ans = 1
A = [int(i) for i in input().split()]
if 0 in A:
    print(0)
else:
    for i in range(n):
        ans *= A[i]
        if ans > 1e18:
            print(-1)
            exit()
    print(ans)