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-----
2
1000000000 1000000000

-----Sample Output-----
1000000000000000000

We have 1000000000 \times 1000000000 = 1000000000000000000.

Difficulty: introductory

Starter code:

Solutions:
a=1
for i in[*open(0)][1].split():a*=int(i);a=[-1,a][0<=a<=10**18]
print(a)

from typing import List


def answer(n: int, a: List[int]) -> int:
    if 0 in a:
        return 0

    max_value = 10 ** 18
    product = 1
    for i in a:
        product *= i
        if max_value < product:
            return -1

    return product


def main():
    n = int(input())
    a = list(map(int, input().split()))
    print(answer(n, a))


def __starting_point():
    main()
__starting_point()

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

for i in range(N):
    ans *= A[i]
    if ans > 1e18:
        print(-1)
        return

print(ans)

i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=int(j)
  if x>1e18:x=-1;break
print(x)


input();l=input().split();x=not"0"in l
for j in l:x=x*int(j)if 0<=x*int(j)<=1e18else-1
print(x)

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

if 0 in A:
  print(0)
  return
else:
  flag = True
  prd = 1
  A.sort(reverse=True)
  for i in range(N):
    prd *= A[i]
    if prd > 10**18:
      flag = False
      break
if flag:
  print(prd)
else:
  print(-1)

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

if 0 in aa:
    print('0')
    return

result = 1
for a in aa:
    result *= a
    if result > pow(10, 18):
        print('-1')
        return

print(result)


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

a,b=open(0);c=1;
for i in b.split():c=[-1,d:=int(i)*c][-1<d<=10**18]
print(c)

import math
import decimal
def i_input(): return int(input())


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


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


def i_row(N): return [int(input()) for _ in range(N)]


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

n= i_input()
aa=i_list()
aa.sort()
ans=1
for a in aa:
    ans*=a
    if ans>10**18:
        ans=-1
        break
print(ans)

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

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

print(ans)


import math


def main():
    n = int(input())
    aList = list(map(int, input().split()))
    sumA = 1
    if aList.count(0) > 0:
        print((0))
        return
    for a in aList:
        sumA *= a
        if sumA > 10 ** 18:
            print((-1))
            return
    print(sumA)



def __starting_point():
    main()

__starting_point()

import sys

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

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


i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=int(j);
  if x>1e18:x=-1;break
print(x)

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

a,b=open(0);c=1;
for i in sorted(b.split()):c=[-1,d:=int(i)*c][-1<d<=10**18]
print(c)

a=1
for i in[*open(0)][1].split():a*=int(i);a=[-1,a][-2<a-1<1e18]
print(a)

import sys

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

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

n = int(input())
aaa = sorted(map(int, input().split()))
ans = 1
limit = 10 ** 18
for a in aaa:
    ans *= a
    if ans > limit:
        ans = -1
        break
print(ans)


def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(map(int, input().split()))
def i_row(N): return [int(input()) for _ in range(N)]
def i_row_list(N): return [list(map(int, input().split())) for _ in range(N)]

n=i_input()
aa=i_list()
aa.sort()
ans=1
inf=10**18
for a in aa:
    ans*=a
    if ans>inf:
        ans=-1
        break
print(ans)

n = int(input())
mod = 10**18
li = list(map(int, input().split()))
li.sort()
ans = 1
for i in range(n):
    ans *= li[i]
    if ans > mod:
        ans = -1
        break
print(ans)


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

if 0 in A:
  print(0)
  return

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

print(AA)

a,b=open(0);c=1;
for i in sorted(b.split()):
    c*=int(i)
    if c>10**18:c=-1;break
print(c)

i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=int(j)
  if x>1e18:x=-1;break
print(x)


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

print(ans)

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

if 0 in A:
    print(0)
    return
product = 1
for num in A:
    product = product * num
    if product > 10 ** 18:
        print(-1)
        return

print(product)

a=1
for i in[*open(0)][1].split():a=[-1,a:=a*int(i)][-1<a<=1e18]
print(a)

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

num=int(input())
line=input().split(" ")
checklis=sorted(line)
if checklis[0]=="0":
    res=0
else:
    res=1
    i=0
    while res<=1000000000000000000 and i<num:
        res *= int(line[i])
        i+=1
        
    if res>1000000000000000000:
        res= -1
 
print(res)


import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
#from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import breadth_first_order, depth_first_order, shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
import sys

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

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))
      return

print(ans)


n=int(input())
a=sorted([int(x) for x in input().split()])

if a[0]==0: print(0); return
ans=1
for ai in a:
  ans*=ai
  if ans>10**18: print(-1); break
else:
  print(ans)

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

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

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

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

a,b=open(0);c=1;
for i in sorted(b.split()):c=[d:=int(i)*c,-1][10**18<d or c<0]
print(c)

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

def calc():
    n = int(input())

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

    
    if 0 in a:
        print(0)
        return 

    ans = 1

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


calc()

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


def ans():
    if 0 in A:
        return print(0)
    product = 1
    for num in A:
        product = product * num
        if product > 10 ** 18:
            return print(-1)

    print(product)


ans()

input();a=1
for i in input().split():a*=int(i);a=[-1,a][0<=a<=10**18]
print(a)

i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=int(j)
  if x>1e18:
    x=-1;break
print(x)


_,b=open(0);a=1
for i in b.split():a*=int(i);a=[-1,a][-1<a<=1e18]
print(a)

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

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

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


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

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

if 0 in a:
    print(0)
    return

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

print(ans)

import random
import time
import copy
import io, sys

#def pow(a, b):
#    res = 1;
#    for ()

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

sum = 1
for a_ in a:
    if (sum != -1): sum *= a_
    if sum != 0 and sum > pow(10, 18):
        sum = -1
    if a_ == 0:
        sum = 0
        break

print(sum)


N = int(input())
A = [int(i) for i in input().split()]
ans = 1
if(0 in A):
    print(0)
    return
for i in range(N):
    ans *= A[i]
    if(ans > 10 ** 18):
        print(-1)
        return
print(ans)

N = int(input())

A = list(map(int, input().split()))
B = 0
C = 1

if 0 in A:
    print(0)
    return

for i in range(N):
    C = C * A[i]
    if C > 1000000000000000000:
        print(-1)
        return

print(C)

n=int(input())
a=list(map(int,input().split()))
s=1000000000000000000
k,c=1,0
for i in a:
    if k*i>s:
        c=1
        break
    k*=i
if 0 in a:
    print(0)
    
elif c==0:
    print(k)
else:
    print(-1)

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

result = 1
A = sorted(A)

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




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

if al.count(0) > 0:
    print(0)
else:
    for a in al:
        ans *= a
        if ans > 10**18:
            print(-1)
            return
    print(ans)

a=1;d=10**18
for i in[*open(0)][1].split():a=min(a*int(i),d+1)
print([a,-1][a>d])

n = int(input())

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

  print(ans)

i=input;i();l=i().split();x=not '0' in l
for j in l:
  x*=int(j)
  if x>1e18:
    print((-1));return
print(x)


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

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


input();l=input().split();x=1
for j in sorted(l):
  x*=int(j)
  if x>1e18:x=-1;break
print(x)

n = input()
a = list(map(int,input().split()))
ans = 1
a.sort()
for i in a:
  ans *= i
  if ans > 1000000000000000000:
    print(-1)
    return
print(ans)

n = int(input())
li = list(map(int, input().split()))
pr = 1
gr = 0
for l in li:
    pr = pr*l
    if pr>10e17:
        gr = 1
        break
if gr==1:
    if 0 in li:
        print((0))
    else:
        print("-1")
else:
  print(pr)


n=int(input())
l=list(map(int,input().split()))
m=1
l.sort()
for i in range(n):
    m *= l[i]
    if m>10**18:
        print(-1)
        return
    
print(m)

i=input;i();l=i().split();x=not'0'in l
for j in l:
  x*=int(j);
  if x>1e18:x=-1;break
print(x)

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

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




from heapq import *

N = int(input())
As = list(map(int, input().split()))
heapify(As)
while len(As) >= 2:
    A1 = heappop(As)
    A2 = heappop(As)
    heappush(As, A1 * A2)
    
if As[0] > 10 ** 18:
    print((-1))
else:
    print((As[0]))


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

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

m = 10**18
ans = 1
for x in a:
    ans *= x
    if ans > m:
        print((-1))
        return
 
print(ans)



import sys
N = int(input())
lsA = list(map(int,input().split()))
if 0 in lsA:
    print(0)
    return
ans = 1
for i in range(N):
    ans *= lsA[i]
    if ans > 10 ** 18:
        print(-1)
        return
print(ans)

n = int(input())
tmp = list(map(int, input().split()))
tmp.sort()
bound = int(10**18)
ans = 1
for i in range(0, n):
    ans *= int(tmp[i])
    if (ans > bound):
        print((-1))
        return
print(ans)


n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    if a[i]==0:
        print(0)
        return
tmp=1
for i in range(n):
    if a[i]<=(int(1e18)//tmp):tmp*=a[i]
    else:
        print(-1)
        return
print(tmp)

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 > 10 ** 18:
            print((-1))
            break
    else:
        print(ans)


n = int(input())

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

ans = 1

if 0 in a:
    print(0)
    return

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

import sys

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

if 0 in li:
    print(0)
    return

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

print(ans)

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

dontt_use = input()
str_list = list(input().split())
n = map(int,str_list)

def foo(n):
    total = 1  
    for number in n:
        total = total * number
        if total > 10**18:
            print('-1')
            return
    print(total)
if '0' in str_list :
    print(0)
else:
    foo(n)

n = int(input())
aaa = sorted(map(int, input().split()), reverse=True)
if aaa[-1] == 0:
    ans = 0
else:
    ans = 1
    limit = 10 ** 18
    for a in aaa:
        ans *= a
        if ans > limit:
            ans = -1
            break
print(ans)

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

if a.count(0) > 0:
  print("0")
  return
  
ans = 1
for i in range(n):
    ans *= a[i]
    if ans > 10 ** 18:
      print("-1")
      return
    
print(ans)


i=input;i();l=i().split();x=1-('0'in l)
for j in l:
  x*=int(j)
  if x>1e18:
    print((-1));return
print(x)


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

input();ans,a=1,[*map(int,input().split())]
if 0 in a:
  print(0)
else:
  for i in a:
    ans*=i
    if ans>10**18:
      print(-1);break
  else:
    print(ans)

input();x=1;*A,=map(int,input().split())
if 0in A:print(0);return
for a in A:
 x*=a
 if x>10**18:print(-1);return
print(x)

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

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

for i in[*open(0)][(a:=1)].split():a*=int(i);a=[-1,a][0<=a<=10**18]
print(a)

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

const = 10**18

if 0 in A:
    print(0)
    return

result = 1
for i in A:
    result *= i
    if result>const:
        print(-1)
        return
print(result)

input();l=input().split();x=1
for j in sorted(l):
  x*=int(j);
  if x>1e18:x=-1;break
print(x)

n=int(input())

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

ans=int(1)
for i in range(n):
    ans*=A[i]
    if(ans>1e18):
        print(-1)
        return

print(ans)

input()

n = list(map(int,input().split(" ")))
ans = int(n[0])
b = n[1:]

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

n=int(input())

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

ans=int(1)

for i in range(n):
    ans*=A[i]
    if ans>1e18:
        print(-1)
        return
print(ans)

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

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

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

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

print(answer)



for i in[*open(0)][(a:=1)].split():a*=int(i);a=[-1,a][0<=a<=10**18]
print(a)

a=1
for i in[*open(0)][1].split():a*=int(i);a=[-1,a][-1<a<=1e18]
print(a)

n=int(input())
A=list(map(int,input().split()))
MAX = 10**18
ans = 1

for a in A:
  if a == 0:
    print(0)
    return

for a in A:
  ans *= a
  if MAX < ans:
    print(-1)
    return
print(ans)

N = int(input())
CONST = 10 ** 18
result = 1
numbers = list(map(int, input().split()))
if 0 in numbers:
    print(0)
    return
numbers.sort(reverse=True)
for i in numbers:
    result = result * i
    if result > CONST:
        print(-1)
        return
print(result)

n = int(input())
a = list(map(int, input().split()))
ans = 1
x = -1
if 0 in a:
    print((0))
    return
for i in range(n):
    x += 1
    ans *= a[x]
    if ans > 1e18:
        print((-1))
        return
print(ans)


n = int(input())
l = list(map(int,input().split())) 
if 0 in l:
    print("0")
    return
result = l[0]
l.pop(0)
for data in l:
    result *= data
    if result > 10 ** 18:
        result = -1
        break
print(result)

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


def calc(N, nums):
    ans = 1
    flg = False
    if 0 in nums:
        return 0
    for i in range(N):
        ans *= nums[i]
        if ans > 10 ** 18:
            flg = True
            break
    if flg:
        return -1
    else:
        return ans


print(calc(N, nums))

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

import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

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

tmp = 0
res = 1

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

print(res)


input();l=input().split();x=not'0'in l
for j in l:
  x*=int(j);
  if x>1e18:x=-1;break
print(x)

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 > 10 ** 18:
            print(-1)
            break
    else:
        print(ans)