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 sys

import math





input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
ans=1
if 0 in a:
  print(0)
  exit()
for i in range(n):
    ans*=a[i]
    if ans>pow(10,18):
      print(-1)
      break
else:
    print(ans)

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

LIMIT = 18

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

ans = 1
for a_i in a:
    if len( str( ans ) ) + len( str( a_i ) ) > LIMIT + 2:
        print( -1 )
        break
    elif len( str( ans ) ) + len( str( a_i ) ) > LIMIT:
        if ans * a_i > 10 ** 18:
            print( -1 )
            break
    ans *= a_i
else:
    print( ans )

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

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

Solution (Python):
def resolve():
    N = int(input())
    A_list = [int(i) for i in input().split()]
    if 0 in A_list:
        print(0)
        return
    prod = 1
    for A in A_list:
        prod = prod * A
        if prod > (10**18):
            print(-1)
            return
    print(prod)

resolve()

Solution (Python):
from __future__ import division, print_function

''' Hey stalker :) '''
INF = 10 ** 10
TEST_CASES = False

def main():
    get_int()
    li = get_list()
    res = 1
    if 0 in li:
        print(0)
        return
    limit = 10**18
    for i in li:
        res *= i
        
        if res > limit:
            print(-1)
            return
    print(res)
''' FastIO Footer: PyRival Library, Thanks @c1729 and contributors '''
import os
import sys
from bisect import bisect_left, bisect_right
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)



input = lambda: sys.stdin.readline().rstrip("\r\n")
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
if __name__ == "__main__":
    if TEST_CASES:
        [main() for _ in range(int(input()))]
    else:
        main()

Solution (Python):


import sys

def main():
    n = int(input())
    numbers = [int(i) for i in input().split()]
    ans=1
    if 0 in numbers:
        print(0)
        sys.exit()
    else:
        for number in numbers:
            ans*=number
            if ans <= 1000000000000000000:
                continue
            else:
                print(-1)
                sys.exit()
        print(ans)            

if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
lis = list(map(int,input().split()))
a = 1
tf = True
zero = False
for k in range(N):
  if lis[k] == 0:
    zero = True
if not zero:
  for i in range(N):
    a *= lis[i]
    if a > 10**18:
      tf = False
      break
if zero:
  print(0)
else:
  if tf:
    print(a)
  else:
    print('-1')

Solution (Python):
n = int(input())
a = 1
f1 = 0
f2 = 0
l = input().split()
for i in range(n):
    a *= int(l[i])
    if a > 1000000000000000000 :
        f1 = 1
        a = 1
    if a == 0:
        f2 = 1
    
if f2 == 1:
    print(0)
elif f1 == 1:
    print(-1)
else :
    print(a)

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

p = 10 ** 18

ans = 1

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

print(ans)

Solution (Python):
import math
import sys
from collections import *
from itertools import *

N = int(input())

OVERFLOW = 10 ** 18

seq = list(map(int, input().split()))
seq.sort()
if seq[0] == 0:
    print(0)
    sys.exit(0)

result = 1
for n in reversed(seq):
    result *= n
    if result > OVERFLOW:
        print(-1)
        sys.exit(0)
print(result)

Solution (Python):


import sys

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

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

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

    total = total * x;

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

print(total)

Solution (Python):
import sys

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

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

kijun = 10 ** 18

res = 1
for x in a:
  res *= x
  if res > kijun:
    print("-1")
    sys.exit()
print(res)

Solution (Python):
def default():
    maxi=1000000000000000000
    n=int(input())
    answer=1
    temp=input()
    temp=temp.split()
    flag=0
    for i in range(0,n):
        temp[i]=int(temp[i])
    temp.sort()
    for i in range(0,n):
        answer*=temp[i]
        if(answer>maxi):
            flag=1
            break
        if(temp[i]==0):
            flag==2
            break
    if(flag==1):
        print(-1)
    else:
        if(flag==2):
            print(0)
        else:
            print(answer)

if(__name__=="__main__"):
    default()

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
t = int('1'+'0'*18)
ans = 1
if min(A)==0:
    print(0)
else:
    for a in A:
        ans *= a
        if ans > t:
            print(-1)
            exit()
    print(ans)

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

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

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

print(c)

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

A = list(map(int,input().split(" ")))
flag = 0
ans = 1

if 0 in A:
    flag = 2
    print(0)

if flag != 2:
    for x in A:
        ans *= x
        
        if ans > 10**18:
            flag = 1
            break

if flag == 0:
    print(ans)
elif flag == 1:
    print("-1")

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

print(number)

Solution (Python):
from math import log10

N = int(input())
A = list(map(int, input().split()))
s = 1
threshold = 10**18
if 0 in A:
    print(0)
else:
    for a in A:
        s *= a
        if s > threshold:
            print(-1)
            break
    else:
        print(s)

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

answer = 1
zero_exist = False
up_to_threshold = False
for i in range(n):
    if answer>int(1e+18):
        up_to_threshold = True
    else:
        answer*=a[i]
    if a[i] == 0:
        zero_exist = True
    
if zero_exist == True:
    print(0)
elif up_to_threshold == True or answer > int(1e+18):
    print(-1)
else:
    print(answer)

Solution (Python):
n = int(input())
*arr, = map(int, input().split())
arr.sort()
res = 1
for i in range(n):
    res *= arr[i]
    if res > 10 ** 18:
        break
print(res if res <= 10 ** 18 else - 1)

Solution (Python):

import sys

N = int(input())
A = [int(x) for x in input().split()]

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

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

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

Solution (Python):


import re
import math
from collections import defaultdict
from collections import deque
import collections
from fractions import Fraction
from queue import PriorityQueue
import itertools
from copy import deepcopy
import random
import time
import os
import sys
import datetime
from functools import lru_cache
from functools import reduce
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
alphabet="abcdefghijklmnopqrstuvwxyz"
numbers="0123456789"
mod=int(10**9+7)
inf=int(10**19)
class Edge():
    def __init__(self,x,y,val=1):
        self.x=x
        self.y=y
        self.val=val
class unionfind():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(n)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):
            self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def yn(b):
    if b:print("yes")
    else:print("no")
def Yn(b):
    if b:print("Yes")
    else:print("No")
def YN(b):
    if b:print("YES")
    else:print("NO")
def ispow(a,b):
    now=b
    while now<a:
        now*=b
    return now==a
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def getfacs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def nextcomb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def getprimes(n):
    if n==0:return []
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    ret=[]
    for a in range(n+1):
        if(A[a]):ret.append(a)
    return ret
def isprime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(bbool,ret1,ret2):
    if bbool:return ret1
    else:return  ret2
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n):
    b = 2
    ret=defaultdict(int)
    while b * b <= n:
        while n % b == 0:
            n //= b
            ret[b]+=1
        b+=1
    if n > 1:ret[n]+=1
    return ret
def pm(x):
    return x//abs(x)
def inputintlist(): 
    return list(map(int,input().split()))
def istanchouzouka(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>=a:
            f=False
        prev=a
    return f
def istanchouhigensyou(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>a:
            f=False
        prev=a
    return f
def getallsum(A):
    s=sum(A)
    dp=defaultdict(int)
    dp[0]=1
    for a in range(0,len(A)):
        for b in range(s,-1,-1):
            if b-A[a]>=0:
                dp[b]+=dp[b-A[a]]
    return dp
def yuukoutomukou(edges):
    ret=deepcopy(edges)
    for edge in edges:
        if not edge.x==edge.y:
            ret.append(Edge(edge.y,edge.x,edge.val))
    return ret
def dijkstra(edges,V,start):
    mincost=[inf]*V
    G=[[] for a in range(V)]
    for edge in edges:
        G[edge.x].append([edge.val,edge.y])
    Q=PriorityQueue()
    Q.put([0,start])
    while not Q.empty():
        nowcost,nowx=Q.get()
        if mincost[nowx]==inf:
            mincost[nowx]=nowcost
            for cost,y in G[nowx]:
                newcost=nowcost+cost
                Q.put([newcost,y])
    return mincost
def warshallfloyd(edges,V):
    mincost=[[inf for b in range(V)] for a in range(V)]
    for a in range(V):mincost[a][a]=0
    for edge in edges:
        mincost[edge.x][edge.y]=min(mincost[edge.x][edge.y],edge.val)
    for k in range(V):
        for s in range(V):
            for t in range(V):
                if mincost[s][k]==inf or mincost[k][t]==inf:continue
                mincost[s][t]=min(mincost[s][t],mincost[s][k]+mincost[k][t])
    return mincost
def bellemanford(edges,V,start):
    mincost=[inf]*V
    mincost[start]=0
    for _ in range(V):
        for edge in edges:
            if mincost[edge.x]==inf:continue
            mincost[edge.y]=min(mincost[edge.y],mincost[edge.x]+edge.val)
    return mincost
def ruisekiwa(A):
    ret=[0]*(len(A)+1)
    for a in range(len(A)):
        ret[a+1]=ret[a]+A[a]
    return ret
def getmd(x1,y1,x2,y2):
    return abs(x1-x2)+abs(y1-y2)
def geted(x1,y1,x2,y2):
    return math.sqrt((x1-x2)**2+(y1-y2)**2)
class fordfulkerson():
    def __init__(self,edges,V,s,t):
        self.V=V
        self.used=[False]*V
        self.G=[[] for a in range(V)]
        self.s=s
        self.t=t
        for edge in edges:
            self.G[edge.x].append({"x":edge.x,"y":edge.y,"cap":edge.val,"rev":len(self.G[edge.y])})
            self.G[edge.y].append({"x":edge.y,"y":edge.x,"cap":0,"rev":len(self.G[edge.x])-1})
    def dfs(self,v,t,f=inf):
        if v==t:return f
        self.used[v]=True
        for a in range(len(self.G[v])):
            x=self.G[v][a]["x"]
            y=self.G[v][a]["y"]
            cap=self.G[v][a]["cap"]
            rev=self.G[y][self.G[x][a]["rev"]]
            if self.used[y] or cap==0:continue
            f2=self.dfs(y,t,min(f,cap))
            if f2>0:
                self.G[v][a]["cap"]-=f2
                rev["cap"]+=f2
                return f2
        return 0
    def maxflow(self):
        flow=0
        while True:
            self.used=[False]*V
            zouka=self.dfs(self.s,self.t)
            if zouka==0:break
            flow+=zouka
        return flow










n=int(input())
A=inputintlist()
ans=1
if A.count(0)>0:
    ans=0
else:
    for a in A:
        ans*=a
        if ans>10**18:
            break
if ans>10**18:
    print(-1)
else:
    print(ans)

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

print(S)

Solution (Python):
import sys
n=int(input())
a=[int(x) for x in input().split()]
a=sorted(a, reverse=True)
m=1
if a[-1] == 0:
  print(0)
else:
  for i in a:
    m*=i
    if m > 10**18:
      print('-1')
      sys.exit()
  print(m)

Solution (Python):
from sys import stdin
N = stdin.readline().rstrip()
An = [int(x) for x in stdin.readline().rstrip().split()]
W = 1
if any([A == 0 for A in An]):
    print(0)
    exit()
for A in An:
    W = W * A
    if 1000000000000000000 < W:
        print(-1)
        exit()
print(W)

Solution (Python):
n = int(input())
A = [*map(int,input().split())]
A.sort()

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

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

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

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

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

print(ans)

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


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

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

print(ret)

Solution (Python):
import sys


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

if A[0] == 0:
    print(0)
    sys.exit()

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

print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
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):
import sys

def main():
    n, *a = map(int, sys.stdin.read().split())
    a.sort()
    res = 1
    for x in a:
        res *= x
        if res > 10**18:
            print(-1)
            return
    print(res)
if __name__ == '__main__':
    main()

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

if 0 in lst:
    print("0")
    quit()

res = 1
for a in lst:
    res = res*a
    if res > 1000000000000000000:
        print("-1")
        quit()
    else:
        pass

print(res)

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

s = 1
ten18 = 10**18
over = False

for b in a:
  if not over:
    s *= b
  if s > ten18:
    
    over = True
  if b == 0:
    s = 0
    over = False
    break
  
if over:
  print(-1)
else:
  print(s)

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

if 0 not in a:

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

print(res)

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

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

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

for i in a:
    ans *= i

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

if(0 in a): print(0)
else: print(ans)

Solution (Python):
n = int(input())
arr = list(map(int, input().split(' ')))
start = 1
maxi = int(1e18)
arr.sort()
for num in arr:
  start *= num
  if start > maxi:
    start = -1
    break
    
print(start)

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

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

Solution (Python):
n = int(input())
a_lst = list(map(int, input().split()))
max_ = 10 ** 18

if 0 in a_lst:
    print(0)
    quit()
else:
    res = a_lst[0]
    for a in a_lst[1:]:
        res *= a
        if res > max_:
            print(-1)
            quit()
    print(res)

Solution (Python):
import sys

n = int(input())
l = []
l += list(map(int, input().split()))

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

r = 1
for e in l:
    r = r * e

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

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

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

print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
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):
n = input()

ls = list(map(int,input().split()))
inf = 10**18
ans = 1

if 0 in ls:
  print(0)
  exit()
for a in ls:
  ans *= a
  if ans >inf:
    ans = -1 
    break
  
print(ans)

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

a0 = a[0]
a_else = a[1:]
th = 10**18
for ai in sorted(a_else):
    a0 *= ai
    if a0 > th:
        print('-1')
        exit()

print(a0)

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

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


print(ans)

Solution (Python):
import sys
import math
 
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
 
def main():
  K = int(input())
  s = list(map(int, input().split()))
  prod = 1
  a = 10 ** 18
  if 0 in s:
    print(0)
    sys.exit()
  for k in range(K):
    prod = prod * s[k]
    if prod > a:
      print(-1)
      sys.exit()
  
  print(prod)

if __name__ == '__main__':
  main()

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

for i in li:
    if i == 0:
        print(0)
        exit()
    if (ans > 1000000000000000000):
        overflg = True
    else:
        ans *= i

if (ans > 1000000000000000000):
        overflg = True

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

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

Solution (Python):

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

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

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

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


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

    ret = 1

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

    print(ret)
    return


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = 1
s = list(set(a))
if s[0] == 0:
    print(0)
else:

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

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

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

if a > 0:
    print(a)

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

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

print(mul)

Solution (Python):
import sys

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


def multiple(l):
    ans = 1
    if 0 in l:
        return 0
    for i in l:
        if ans * i > 10 ** 18:
            return -1
        else:
            ans *= i
    return ans


print(multiple(a))

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

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

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

Solution (Python):
N=int(input())
M=[int(_) for _ in input().split()]
M.sort(reverse=True)
a=1
if M[-1]==0:
    print(0)
    exit()

else:
    for s in M:
        a=a*s
        if a>10**18:
            print(-1)
            exit()
print(a)

Solution (Python):
import sys
n = int(input())
A = list(map(int,input().split()))
ans = 10**18
tmp = 1

if 0 in A:
    print(0)
else:
    for i in range(n):
        tmp *= A[i]
        if tmp > ans:
            print(-1)
            sys.exit()
    print(tmp)

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

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

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

Solution (Python):

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

chk = A[0]

i = 1




while i < N:
    chk = chk * A[i]
    if chk > 1000000000000000000:
        chk = -1
        break
    i+=1

i = 0
while i < N:
    if A[i] == 0:
        chk = 0
    i+=1

print(chk)

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

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

c = set(a)

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

print(ans)

Solution (Python):
def solve(N, As):
    ans = 1
    _As = sorted(As)
    border = 10 ** 18
    for a in _As:
        ans *= a
        if ans > border:
            print(-1)
            return
    print(ans)


if __name__ == '__main__':
    N = int(input())
    As = [int(i) for i in input().split()]
    solve(N, As)

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

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

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

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

print(ANS)

Solution (Python):
'''     
        
        
        

import sys
import math


def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end=" \ ")

MODPRIME = int(1e9+7); BABYMOD = 998244353;

if __name__ == "__main__":
    
    n = int(input())
    ans = 1
    li = get_array()
    maxii = int(1e18)
    flag = flag2 = False
    for i in li:
        if not flag2:
            ans *= i
        if i == 0:
            flag = True
        if ans > maxii:
            flag2 = True
            ans = -1
        
    if flag:
        ans = 0
    print(ans)



'''
THE LOGIC AND APPROACH IS BY ME @luctivud ( UDIT GUPTA )
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
>>> DO NOT PLAGIARISE.
TESTCASES:
'''

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

print(ans)

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

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

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

Solution (Python):
import sys


N = int(input())

A = list(map(int, input().split()))
if 0 in A:
    print(0)
    sys.exit()

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

print(A1)