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 = [int(x) for x 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())
A = list(map(int, input().split()))
INF = 10 ** 18

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

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

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

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

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

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

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

line  = [int(y) for y in input().split()]
line.sort()

yeet  = 1
solved  = False

if line[0] == 0:
    print(0)
else:
    for i in range(0,x):
        yeet = yeet*line[i]
        if yeet > 10**18:
            solved = True
            print(-1)
            break

    if solved == False:
        print(yeet)

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


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

    ans = 1
    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
n=int(input())
a=[int(x) for x in input().rstrip().split()]
a.sort()
if a[0]==0:
  print(0)
else:
  ans=1
  for i in a:
    ans*=i
    if 10**18<ans:
      print(-1)
      sys.exit()
  print(ans)

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

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy


from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush
from fractions import gcd

sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])
 
def main():
    n = inp()
    a = inpl()
    ans = 1
    a.sort()
    for i in range(n):
        if a[i] == 0:
            print(0)
            return
        ans *= a[i]
        if ans > 10**18:
            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()
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):
n=int(input())
a=list(map(int,input().split()))
if 0 in a:
    print(0)
    exit()
else:
    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()))

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

Solution (Python):
from functools import reduce
from operator import mul
N = int(input())
A = [int(c) for c in input().split()]
ans = 1
if 0 in A:
  print(0)
  import sys
  sys.exit()
for c in A:
  ans *= c
  if ans>10**18:
    print(-1)
    break
else:
  print(ans)

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

main()

Solution (Python):
def main():
    _ = input()
    A = list(map(int, input().split()))
    cnt = 1 
    mi = min(A)
    if mi == 0:
        print(0)
    else:
        for a in A:
            cnt *= a 
            if cnt > 1e18 and mi > 0:
                print(-1)
                break
        else:
            if cnt < 0:
                print(-1)
            else:
                print(cnt)

if __name__ == '__main__':
    main()

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

f=1
c=0
for i in l:
    f*=i
    if f > 10**18:
        c=1
        break
    
if 0 in l:
    print(0)
elif c==1:
    print(-1)
else:
    print(f)

Solution (Python):


import sys
readline = sys.stdin.readline

N = int(readline())
A = list(int(x) for x in readline().split())
A.sort()

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

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

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

Solution (Python):
import sys
import math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
p = list(map(int, input().split()))
ma = int(1e18)

for p_ in p:
    if p_ == 0:
        print(0)
        exit()

ans = 1
for p_ in p:
    ans *= p_
    if ans > ma:
        print(-1)
        exit()
print(ans)

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

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

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

OUT = 1 + 10 ** 18

ans = 1
for i, Ai in enumerate(A):
    if ans == 0: break
    
    Ai_end = (OUT + ans - 1) // ans
    if Ai >= Ai_end:
        ans = -1
        break
    else:
        ans *= Ai

print(ans)

Solution (Python):

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

Solution (Python):



 
import sys
import math



 

fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile


mod=1000000007
 

def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 

t=1
for tt in range(t):
    n=int(input())
    
    a=list(map(int,sys.stdin.readline().split(' ')))
    ams=1

    if 0 in a:
        print(0)
        continue
        
    for x in a:
        ams*=x
        if ams> 1000000000000000000:
            ams=-1
            break

    print(ams)
    
    

if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

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

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

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

print(mul)

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right


from functools import reduce
from pprint import pprint

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

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

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n = I()
a = RI()

a.sort(reverse=True)

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

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

print(ans)

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

ans = 1
a.sort()

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

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

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

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

res = 1
for aa in a:
    res *= aa
    if(res > 1000000000000000000):
        print(-1)
        exit()

print(res)

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

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

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


def solve(nums):
  if any(not n for n in nums):
      return 0

  i = 1
  for n in nums:
      i *= n
      if i > 10 ** 18:
        return -1
  return i

print(solve(nums))

Solution (Python):


import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,*a = map(int,read().split())
x = 1
INF = 10**18

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


for i in a:
    x *= i
    if x > INF:
        print(-1)
        break
else:
    print(x)

Solution (Python):
n = int(input())
lis = list(map(int,input().split()))
prod = 1
if 0 in lis:
    print(0)
    exit(0)
for i in lis:
    if(prod>1000000000000000000):
        print(-1)
        exit(0)
    prod=prod*i
print(prod) if(prod<=1000000000000000000) else print(-1)

Solution (Python):

ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

n = inp()
x = ip()
ele = 10**18
prod = 1
if 0 in x:
    print(0)
    exit()
for i in x:
    prod *= i
    if prod > ele:
        print(-1)
        exit()
print(prod)

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

ans = 1
for x in a:
	if ans == 0 or ans == -1:
		break
	ans = ans * x
	if ans > 1000000000000000000:
		ans = -1

print(ans)

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

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

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

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

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

s = input().split()
A = []
for i in range(N):
  A.append(int(s[i]))

result = 1

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

print(result)

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

ans = 1

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

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

    if flag == 0:
        print(ans)

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

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

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

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

print(ans)

Solution (Python):

import sys


def solve(N: int, A: "List[int]"):
    ans = 0
    limit = 10 ** 18
    if 0 in A:
        print(0)
        return
    for i, v in enumerate(A):
        if i == 0:
            ans = v 
            continue
        ans *= v
        if ans > limit:
            print(-1)
            return
    print(ans)
    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):


LI = lambda: list(map(int, input().split()))


N = int(input())
A = LI()


def main():
    if 0 in A:
        print(0)
        return
    x = 1
    t = 10 ** 18
    for a in A:
        x *= a
        if x > t:
            print(-1)
            return
    print(x)


if __name__ == "__main__":
    main()

Solution (Python):



import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf



import math

import bisect


def solve(data):
    ans = 1
    if 0 in data:
        return 0
    for d in data:
        ans *= d
        if ans > 10 ** 18:
            return -1
    return ans


if __name__ == '__main__':
    n = int(input())
    data = list(map(int, input().split()))
    ans = solve(data)
    
    print(ans)

Solution (Python):
import sys 
n = int(input())
arr = input()
ans = 1
arr = list(map(int,arr.split(' ')))
arr.sort()
for i in range(n):
    t = arr[i]
    ans *= t
    if (ans > 1000000000000000000):
        print(-1)
        sys.exit()
print(ans)

Solution (Python):


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


result = 1
if 0 in A:
    result = 0
else:
    sorted_A = list(reversed(sorted(A)))
    for A_n in sorted_A:
        result *= A_n
        if result > pow(10, 18):
            result = -1
            break


print(result)

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

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

sum = 1

for num in sorted(nums):
    sum *= num
    if sum > 1e18:
        print(-1)
        exit()

print(sum)

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    INF = 10 ** 18
    ans = 1
    is_INF = False
    for a in A:
        ans *= a
        if ans > INF:
            is_INF = True
            break
    if is_INF:
        if 0 in A:
            print(0)
        else:
            print(-1)
    else:
        print(ans)
if __name__ == "__main__":
    main()

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

Solution (Python):
from sys import exit

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

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

print(tmp)

Solution (Python):


N=int(input())
List = list(map(int, input().split()))
List=sorted(List)
List=List[::-1]

if List.count(0)!=0:
    print(0)
    quit()
ANS=List[0]
i=1
while i<N:
    ANS=ANS*List[i]
    if ANS>1000000000000000000:
        print(-1)
        quit()
    i+=1

print(ANS)

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 = a[0]
for i in range(1, len(a)):
    ans *= a[i]
    if ans > 1000000000000000000:
        ans = -1
        break

print(ans)

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

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

Solution (Python):
from collections import Counter 
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
import numpy as np
import bisect
import sys
sys.setrecursionlimit(10**6)


def bfs(s,n,node):
    
    check=[False for _ in range(n)]
    check[s]=True
    
    queue=deque([s])
    visited_num=1

    
    
    color=[-1 for _ in range(n)]
    color[s]=0
    
    while visited_num<n:
        
        if len(queue)==0:
            
            
            return color

        now_vertex=queue.popleft()
        
        for next_vertex in node[now_vertex]:


            if check[next_vertex]==True:
                continue

            queue.append(next_vertex)
            check[next_vertex]=True

            
            color[next_vertex]=color[now_vertex]+1
            visited_num+=1

    return color




ceil=lambda x,y: (x+y-1)//y
input_list = lambda : list(map(int,input().split()))



n=int(input())

a=input_list()
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=int(input())
A=list(map(int,input().split()))
want=A.count(0)
if want:
    print(0)
    exit()
use=1 
for i in range(n):
    use*=A[i]
    if use>10**18:
        print(-1)
        exit()

print(use)

Solution (Python):


import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N = I()
A = LI()

ans = 1
for a in A:
    ans *= a

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

print(ans if not 0 in A else 0)

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

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

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

s = 1
mod = pow(10, 18)

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

for i in a:
    s = s*i
    if s > mod:
        print(-1)
        exit()
else:
    print(s)

Solution (Python):
n = int(input())
t = 10**18
l = list(map(int, input().split(' ')))
ans = 1

for i in l:
	ans *= i
	if(ans > t):
		ans = -1
		break
if(0 in l):
	ans = 0
print(ans)

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

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

is0 = 0
for i in range(0, n):
    if a[i] == 0:
        is0 = 1

if is0 == 1:
    print(0)
else:
    for i in range(0, n):
        if ok:
            ans = ans * a[i]

        if ans > 1000000000000000000:
            ok = 0

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

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

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

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

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

a = sorted(a);

ans = 1

for i in a:
    ans *= i
    if ans > 1000000000000000000:
        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):
    if flag == 0:
        ans *= A[i]
    if ans > 10**18 and flag != 2:
        flag = 1
    if A[i] == 0:
        flag = 2
if flag == 0:
    print(ans)
elif flag == 1:
    print(-1)
else:
    print(0)

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

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

lim = 10**18

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

T = 1
for i in A:
    T *= i
    
    if T > lim:
        print(-1)
        exit()

print(T)

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

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

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

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

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

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

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

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

print(res)

Solution (Python):


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


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    A = read_ints()
    maximum = 10**18
    if 0 in A:
        return 0
    ans = 1
    for a in A:
        ans *= a
        if ans > maximum:
            return -1
    return ans


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

Solution (Python):
import sys
sys.setrecursionlimit(10**9)

def main():
    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)



if __name__ == "__main__":
  main()

Solution (Python):
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    if a.count(0) > 0:
        ret = 0
    else:
        ret = 1
        for i in a:
            ret *= i
            if ret > 1e18:
                ret = -1
                break
    print(ret)

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

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

A.sort(reverse=True)

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

print(result)

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

ans=1

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

print(ans)

Solution (Python):
n=int(input())
arr=list(map(int,input().strip().split()))[:n]
limit=10**18
mul=1
if(0 in arr):
	print(0)
else:
	for i in arr:
		mul*=i
		if(mul > limit):
			print(-1)
			break
	if(mul <= limit):
		print(mul)

Solution (Python):


n = input()
line = input()
res = 1
data = []
for x in line.split(' '):
    data.append(int(x))
    if int(x) == 0:
        res = 0
for x in data:
    res = res * int(x)
    if pow(10, 18) < res:
        res = -1
        break
print(res)

Solution (Python):
num = int(input())
numbers = input().split(" ")
if "0" in numbers:
  print(0)
else:
  ans = 1
  for number in numbers:
    kake = int(number)
    ans *= kake
    if ans > 10**18:
      print(-1)
      break
  else:
    print(ans)

Solution (Python):
n = int(input())
a = list(map(int, 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
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n = int(readline())
    a = [int(i) for i in readline().split()]
    for i in a:
        if i == 0:
            print(0)
            return
    ans = 1
    INF = int(1e18)
    for i in a:
        ans *= i
        if ans > INF:
            print(-1)
            return
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
mod=10**18
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>mod:
    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 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()))

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

Solution (Python):


import sys

n = int(input())
a = list(map(int, input().split()))
a = sorted(a, key=lambda x: x)

result = 1

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

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

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

sum=1

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

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

if __name__ == "__main__":
    main()

Solution (Python):
import sys


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

INF = 10 ** 18

ans = 1

over = False

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

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

print(ans)

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

Solution (Python):
import sys

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip() 
ni = lambda: int(readline().rstrip()) 
nm = lambda: map(int, readline().split()) 
nl = lambda: list(map(int, readline().split())) 

n = ni()
a = sorted(nl())
ans = 1
for ele in a:
    ans *= ele
    if ans > 10 ** 18:
        break

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

Solution (Python):
n = int(input())
ret = 1
a = sorted(list(map(int, input().split())))
for ai in a:
    ret *= ai
    if ret > 1000000000000000000:
        print(-1)
        exit(0)
print(ret)

Solution (Python):
cumul = 1
n = int(raw_input())
ais = map(int, raw_input().split(' '))
i = 0
ais.sort(key = lambda x:-x)
if ais[-1] == 0:
	cumul = 0
while(i < len(ais) and cumul <= 10 ** 18):
  cumul *= ais[i]
  i +=1
  if cumul == 0:
  	break

print cumul if cumul <= 10 ** 18 else -1