peterverebics/CodeNet_Python_118 huggingface dataset:
def solve(string):
    n, *a = map(int, string.split())
    a = sorted(a)
    if len(a) == 1:
        return "1"
    ans = [a[0]]
    for _a in a[1:]:
        for b in ans:
            if _a % b == 0:
                break
        else:
            ans.append(_a)
    return str(len(ans) - (a[0] == a[1]))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
counter = [0 for i in range(10**6+1)]
n = int(input())
a = sorted(list(map(int,input().split())))
for i in a:
  counter[i] += 1
l  = [0 for i in range(10**6+1)]
cou = 0
for i in range(n):
  b = a[i]
  if l[b]==0:
    cou += 1
    for j in range(b,10**6+1,b):
      l[j] = 1
    if counter[j]>=2:
      cou -=1
print(cou)
N = int(input())
A = [int(n) for n in input().split()]
AS = sorted(set(A))
ans = 0
if len(AS) == 1:
    print(ans)
    exit()
ans += 1
for i in range(1, len(AS)):
    c = 0
    for j in range(i):
        if AS[i] % AS[j]==0:
            break
        else:
            c += 1
            if c == i:
                ans += 1
print(ans)
N = int(input())
A = list(map(int,input().split(" ")))
ans = 0
dp = [True]*max(A)
A.sort()
for i in range(N):
  if dp[A[i]-1]:
    if i > 1:
      if A[i] == A[i-1]:
        dp[A[i]-1] = False
        continue
    for j in range(2,max(A)//A[i]+1):
      dp[j*A[i]-1] = False
    ans += 1

print(ans)
N=int(input())
A = list(map(int, input().split()))
count=N
A.sort
for i in range(0,N):
    if A[i] == 1:
        count=N-i
        break
    else:
        for j in range(0,N):
            if i!=j and A[i]%A[j]==0:
                count=count-1
                break
print(count)
import bisect
N=int(input())
A=list(map(int,input().split()))
A.sort()
ans=1
for i in range(N-1,-1,-1):
  flag=0
  lb=bisect.bisect_right(A,A[i]//2)
  if lb == 0 and A[i] == A[0]:
    continue
  for j in range(lb-1,-1,-1):
    if A[i]%A[j]==0:
      flag=1
      break
  if flag==0:
    ans+=1

if N>1 and A[0]==A[1]:
  ans-=1
print(ans)
n = int(input())
a = list(map(int, input().split()))

a = sorted(a)

ps = [a[0]]
for ai in a[1:]:
    is_divided = False
    for p in ps:
        if ai % p == 0:
            is_divided = True
            break
    if not is_divided:
        ps.append(ai)

print(len(ps))
N = int(input())
A = list(map(int,input().split()))
def map_all(es):
    return all([e == es[0] for e in es[1:]]) if es else False
if map_all(A):
    print(0)
else:
    B = list(set(A))
    l = len(B)
    k = len(A)-len(B)
    ct = 1-k
    for i in range(1,l):
        for j in range(i):
            if B[i]%B[j] == 0:
                break
            elif j == i-1:
                ct = ct +1
    print(ct)
n = int(input())
a = list(map(int, input().split()))
M=max(a)
ok = [0]*(M+1)
a.sort()
for i in range(n):
    ok[a[i]] += 1

for i in range(n):
    if ok[a[i]] == 1:
        for g in range(a[i], M+1, a[i]):
            if g != a[i]:
                ok[g] = 0

if ok.count(1) == 1:
    print(0)
else:
    print(ok.count(1))
import sys

n = int(input())
list_input = list(map(int, sys.stdin.readline().split()))

list_input.sort()
list_input = list(set(list_input))
if len(list_input) == 1:
    print(0)
    exit()

max_num = list_input[-1]

list_false = []
for i in list_input:
    for j in list_input:
        if i == j:
            continue
        elif i % j == 0:
            list_false.append(i)
            break

print(n-len(list_false))
N = int(input())
p = map(int, input().split())
p = list(p)
cnt = 0
for i in range(N):
  for j in range(N):
    if i == j:
      continue
    if p[i] % p[j] == 0:
      break
    elif j == N-1:
      cnt += 1
print(cnt)
N = int(input())
A = sorted(list(map(int, input().split())))

B = set(A)
count = 0

if len(B) == 1:
    print(0)
    exit()

for i in range(len(B)):
    if i == 0:
        count += 1
    else:
        for j in range(i):
            if A[i] % A[j] == 0:
                break
            elif (j == i - 1) and (A[i] % A[j] != 0):
                count += 1

print(count)
import numpy as np
n = int(input())
a = np.sort(np.array(list(map(int, input().split()))))
max_num = np.max(a)+1
dp = np.array([True]*(max_num))

if np.all(a==a[0]):
    print(0)
else:
    for i in range(1,max_num):
        if dp[i] and i in a:
            for j in np.arange(i*2, max_num, i):
                dp[j] = False
    print(np.count_nonzero(dp[a] == True))
n=int(input())
a=list(map(int,input().split()))
ans=0
def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors
for i in a:
    s=set(a)
    s.discard(i)
    if len(make_divisors(i)&s)==0:
        ans+=1
print(ans)
import collections

n = int(input())
d = list(map(int, input().strip().split()))

# 重複しているやつは削除
counts = collections.Counter(d)
d = []
for a, c in counts.items():
    if c == 0:
        d.append(a)

d = sorted(d)
count = 0

while True:
    if len(d) == 0:
        break

    divisor = d[0]
    d = d[1:]
    count += 1
    d1 = []
    for a in d:
        if a % divisor != 0:
            d1.append(a)

    d = d1

print(count)
n,*a=map(int,open(0).read().split())
d=[0]*(max(a)+1)
ans=0
for i in a:
  d[i]+=1
for i in range(max(a)+1):
  if d[i]:
    if d[i]==1:
      ans+=1
    for j in range(i,max(a),i):
      d[j]=0
print(ans)
import math
import numpy as np
N= int(input())
A = list(map(int, input().split()))
A.sort()
prod = math.prod(A)

count = 0

for i in range(N):
    qualify = 1

    if i < N-1 and A[i + 1] == A[i]:
        continue

    if i > 1 and A[i - 1] == A[i]:
        continue

    max_index = np.searchsorted(A, A[i]/2+1)
    for j in range(max_index):
        if (A[i] % A[j]) == 0:
            qualify = 0
            break


    count += qualify


print(count)
n = int(input())
a = list(map(int, input().split()))
ans = 0
check = 0

a.sort()


for i in range(n):
    if i==0 or (i>=1 and a[i] != a[i-1]):
        for j in range(i+1):
            if a[i] % a[j] == 0:
                check += 1
            if check > 2:
                break
        if check == 1:
            ans += 1
        check = 0

print(ans)
N = int(input())
A = list(map(int, input().split()))
count = 0
for a in A:
    for i in range(len(A)):
        if a % A[i] == 0 and a != A[i]:
            count += 1
            break
if(count != 0):
    print(N-count)
else:
    print(count)
n=int(input())
a=list(map(int,input().split()))
ans=0
a.sort()
dp=[True for i in range(a[-1]+1)]

for i in range(n):
  if dp[a[i]]==False:
    #print(dp)
    continue
  if a[i]*2<=a[-1]+1:
    for j in range(a[i]*2,a[-1]+1,a[i]):
      dp[j]=False
      #print(dp)

for i in range(n):
  if dp[a[i]]:
    ans+=1
print(ans)
from collections import Counter

n=int(input())
A=Counter(sorted(list(map(int,input().split()))))
number=[True for i in range(10**6+1)]

cnt=0
for v,m in A.items():
    if m!=1:
        for i in range(v,10**6,v):
            number[i]=False
    else:
        if number[v]==True:
            cnt +=1
            for i in range(v,10**6,v):
                number[i]=False
print(cnt)
N = int(input())
A = list(map(int, input().split()))
A.sort()

dlen = A[-1]+1
d = [True]*dlen
for a in A:
    if d[a]:
        for i in range(a*2, dlen, a):
            d[i] = False

res = 0
for i in range(N):
    if i > 1:
        if A[i] == A[i-1]:
            continue
    if i < N-1:
        if A[i] == A[i+1]:
            continue
    if d[A[i]]:
        res += 1
print(res)
N = int(input())
A = list(map(int, input().split()))

cnt = N
for i in range(N//2):
    for j in range(i+1, N):
        if i != j and A[i] % A[j] == 0:
            cnt -= 1
            if A[j] % A[i] == 0:
                cnt -= 1
            break
        if i != j and A[j] % A[i] == 0:
            cnt -= 1
            break

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

C=[1 for i in range(10**6+1)]
for i in range(N):
    if C[A[i]]==0:
        continue
    if C[A[i]]==-1:
        C[A[i]]=0
        continue
    C[A[i]]*=-1
    for j in range(2,10**6//A[i]-1):
        C[A[i]*j]=0
        

print(C.count(-1))
a = int(input())
numbers = [int(i) for i in input().split()]
b = 0
numbers = numbers[0:a]
for i in numbers:
    for j in numbers:
        if i%j == 0 and numbers.index(i) != numbers.index(j):
            break
    else:
        b += 1
print(b)
import collections
N = int(input())
A = sorted([int(i) for i in input().split()])

if N == 1:
    print(1)
    exit()

C = collections.Counter(A)
cand = set(A)

ans = 0
for i in range(N):
    if C[A[i]] >= 2:
        continue

    if A[i] in cand:
        ans += 1
        cand -= set([c for c in cand if c % A[i] == 0])
print(ans)
n,*a=map(int,open(0).read().split())
ans=[]
a.sort()
for i in range(1,n):
  for x in a[:i]:
    if a[i]%x==0:
      ans.append(x)
      break
print(len(ans))
n=int(input())
a=list(map(int,input().split()))
ans=0
chklist=[1]*n
for i in range(n):
  for j in range(i+1,n):
    if a[i] < a[j]:
      if a[j]%a[i]==0:
        chklist[j]=0
    else:
      if a[i]%a[j]==0:
        chklist[i]=0
chkflag=True
for i in range(n-1):
  if a[i]!=a[i+1]:
    chkflag=False
    break
if chkflag:
  print(0)
else:
  print(sum(chklist))
# abc170_d.py
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
cnt = 0
for i in range(N):
    can_devide = False
    for j in range(i+1,N):
        if A[i] % A[j] == 0 and i != j:
            # print(A[i] , A[j])
            can_devide = True
            break
    if not can_devide:
        cnt += 1
print(cnt)
#!/usr/local/bin/python3
# coding: utf-8
n = input()
ha = input()
kita = ha.split(" ")
newkita = sorted(kita)
count = 0
for i in range(int(n)):
    ifC = True
    for j in range(int(n)):
        if(i > j):
            a = int(newkita[i])
            b = int(newkita[j])
            if(a%b == 0):
                ifC = False
                break
        else:
            break
    if(ifC):
        count += 1
print(count)
import sys
n = int(input())
a = [int(x) for x in input().split()]
list(set(a))#重複を削除
a.sort()#ソート
count = 0
if(n == 1):
  print(1)
  sys.exit()
for i in range(1,n):
  #２が含まれている場合偶数をとばす
  if(2 in a and a[i] % 2 == 0):
    continue
  flg = False
  for j in range(i):
    if(a[i] % a[j] == 0):
      flg = True
      break
  if(flg == False):
    count += 1
count += 1
print(count)
n = int(input())
a = list(map(int, input().split()))

if 1 in a:
    if a.count(1)==1:
        print(1)
    else:
        print(0)

from copy import deepcopy
b = deepcopy(a)

for i in range(n):
    for j in range(n):
        if a[j]%a[i]==0:
            if not j==i:
                if a[j] in b:
                    b.remove(a[j])

print(len(b))
from copy import deepcopy
N = int(input())
A = list(map(int,input().split()))
count = 0
Aas = sorted(A)
Ades = sorted(A,reverse=True)
for i,a in enumerate(A):
    flag = 0
    A2 = deepcopy(A)
    del A2[i]
    if a not in A2:
        for b in Aas:
            if a % b  == 0:
                flag = 1
                break
            if a/b < 1:
                break
        if flag == 0:
            count += 1
print(count)
import sys

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

Ali.sort()

if len(set(Ali))==1:
    print(0)
    sys.exit()


for index_i,i in enumerate(Ali):
    for j in Ali[index_i+1:]:
        if j%i == 0:
            Ali.remove(j)

print(len(Ali))
import math

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

a = sorted(a)
ans = 1
lst.append(a[0])

for i in range(1,n):
    flg = 0
    for j in range(len(lst)):
        if lst[j] > math.ceil(a[i]/2):
            break
        if a[i] % lst[j] == 0:
            flg = 1
            break
    if flg == 0:
        lst.append(a[i])

print(len(lst))
import numpy as np
 
n = int(input())
a = list(map(int, input().split()))
a.sort()
dp = [True for _ in range(a[-1])]

for x in a:
    if dp[x - 1] == False: continue
    else:
        multiply = x * 2
        while multiply <= a[-1]:
            dp[multiply - 1] = False
            multiply += x
ans = 0
for x in set(a):
    if dp[x - 1] is True:
        ans += 1
print(ans)
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

num = int(input())
a = list(map(int, input().split()))
b = 0
for i in a:
  for f in make_divisors(i)[:-1]:
    if f in a:
      b += 1
      break
print(num - b)
try:
  n  = int(input())
  As = list(map(int, input().split()))
  As.sort(reverse=True)
  ans = 0
  
  for i in range(n):
    flag = True
    if As[i] in As[0:i] or As[i] in As[i+1:n]:
        flag = False
        break
    	
    for j in range(n-1,i,-1):
      #print(As[i], As[j])
             
      if As[i] % As[j] == 0:
        flag = False
        break
    #print(flag)
    if flag:
      ans += 1
  print(ans)
except EOFError:
  print(x)
n = int(input())
a = list(map(int, input().split()))
a.sort()
cnt = n

if n != 1:
    if a[0] == a[1]:
        cnt -= 1

for i in range(1, n):
    for j in range(i):
        if i != n-1:
            if a[i+1] == a[i]:
                cnt -= 1
                break
        if a[i] % a[j] == 0:
            cnt -= 1
            break
        if a[j] > a[i]//2+1:
            break
print(cnt)
N = int(input())
A = list(map(int, input().split()))
Ad = {}
for a in A:
    Ad[a] = Ad.get(a, 0) + 1
A, maxA, ans = sorted(Ad.keys()), max(Ad.keys()), 0

for a in A:
    if Ad[a] == 1:
        ans, m = ans + 1, 2
        if a == 1:
            break
        while a * m <= maxA:
            if a * m in Ad:
                Ad[a * m] = 0
            m += 1

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

cnt=0

for i in range(n):
  for j in range(n):
    if i!=j:
      x=a[i]/a[j]
      if x==int(x):
        break
      if j==(n-1):
        cnt+=1
  

print(cnt)
n = int(input())
a = list(map(int, input().split())) 
res = 0
for i in range(n):
    for j in range(n):
        if  i == j:
           pass
        if a[j] >= a[i]:
            pass
        elif (a[i] == a[j]) or (a[i]%a[j] == 0):
            break
    else:
        res += 1
print(res)
import sys

N = int(sys.stdin.readline())
A = [int(x) for x in sys.stdin.readline().split()]
A.sort(reverse=True)

ans = 0
for i in range(N):
    for j in range(i+1,N):
        if A[i] % A[j] == 0:
            break
    else:
        ans += 1

print(ans)
n = int(input())
list_ = list(map(int, input().split()))
cnt = 0

for i in range(n):
    flag = True
    same_cnt = 0
    for j in range(n):
        if i == j:
            continue

        if list_[i] == list_[j]:
            same_cnt += 1
            continue

        if list_[i] % list_[j] == 0:
            flag = False
            break

    if flag and same_cnt != n - 1:
        cnt += 1

print(cnt)
import numpy as np
from collections import Counter, deque

N = int(input())
A = list(map(int, input().split(' ')))
counter = Counter(A)
A = np.array(sorted([key for key, value in counter.items() if value == 1]))

results = deque()
while len(A) > 0:
    results.append(A[0])
    A = A[A % A[0] != 0]

print(len(results))
N = int(input())
#N = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
C = [True]*len(A)
for i in range(len(A)):
    if C[i]==False:
        continue
    a=A[i]
    for j in range(i+1, len(A)):
        if A[j]%a==0:
            C[j] = False
count = len([i for i in C if i==True])
if A[0] in A[1:]:
    count-=1
print(count)
N = int(input())
A = sorted(map(int, input().split()), reverse=True)
cnt = 0

if N == 1:
    print(1)
else:
  for i in range(N-1):
    for j in range(i+1, N):
      if A[i] % A[j] == 0:
        cnt-=1
        break
    cnt += 1
  if A[-1] != A[-2]:
    cnt += 1
  print(cnt)
N = int(input())
As = list(map(int, input().split()))
st = set(As)
 
As.sort()
if N == 1:
  print(1)
  exit()

st = set(As)
m = As[-1]
rlt = 0
gb = set([])

for i in range(N):
  if i > 1 and As[i] == As[i-1]:
    gb.add(As[i])
    continue
  j = 2
  while As[i]*j <= m:
    if As[i]*j in st:
      gb.add(As[i]*j)
    j += 1

for a in As:
  if a not in gb:
    rlt += 1
    
print(rlt)
N = int(input())
A = list(map(int, input().split()))

div = [[a_i % a_j for a_j in A[i+1:]] for i, a_i in enumerate(A[:N-1])]
ans = 0
for d in div:
  if 0 not in d:
    ans += 1
    
print(ans)
import math
N=int(input())
A=list(map(int,input().split()))
A=sorted(A,reverse=True)
cnt=0
for i in A:
  num=A.index(i)+1
  for j in range(num,N):
    if  math.gcd(i,A[j])==min(i,A[j]) and i!=A[j]:
      cnt+=1
ans=N-cnt
print(ans)
# coding:utf-8

N = int(input())
A = sorted(list(map(lambda x:int(x), input().split())))

count = 0
for i in range(N):
  flag = True
  for j in range(0, i):
    if(i == j):
      continue
    if(A[i] % A[j] == 0):
      flag = False
      break
  if(flag):
    count +=1
print(count)
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)
n = int(input())
al = list(map(int, input().split())) 

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

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

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

else:        
    print(res)
N = int(input())
A = list(map(int, input().split()))

result = 1
ok = True
if 0 in A:
    result = 0
else:
    for a in A:
        result *= a
        if result > 10 ** 18:
            ok = False
            break

if ok:
    print(result)
else:
    print(-1)
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    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:
                ans=-1
                break
        print(ans)
resolve()
n=int(input())
A=list(map(int,input().split()))

ans=1

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

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


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

const = 10**18

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

result = 1
for i in A:
    result *= i
    if result>const:
        print(-1)
        exit(0)
print(result)
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1

    if 0 in A:
        print(0)
        return
    A1 = A[::2]
    A2 = A[1::2]

    if N%2 ==1:
        ans *= A1[-1]
    for i,j in zip(A1,A2):
        ans *= i*j
        if ans >10**18:
            return print(-1)

    return print(ans)


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

print(ans)
n = int(input())
a = list(map(int, input().split()))
import sys
ans = 1
if 0 in a:
    print(0)
    sys.exit()
for i in a:
    if ans <= 1000000000000000000:
        ans = ans * i
      
    else:
        print(-1)
        sys.exit()
if ans <= 1000000000000000000:
    print(ans)
else:
    print(-1)
a=int(input())
b=input().split(" ")
sum1=1
 
if "0" in b:
    print("0")
else:
    for i in range(a):
        sum1=sum1*int(b[i])
        if sum1>10**18:
            sum1=-1
            break
    print(sum1)
N = int(input())
org = input().split()
for i in range(len(org)):
    org[i] = int(org[i])
A = sorted(org)

answer = A[0]
overl = False

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

if overl:
    print("-1")
else:
    print(answer)
n = int(input())
A = list(map(int,input().split()))
ans =1
for i in range(n):
    ans = ans * A[i]
    if ans  > 10**18:
        ans =-1
        break 
if 0 in A:
  print(0)
else:
  print(ans)
N = int(input())
A = list(map(int, input().split()))
MAX = 10**18
A.sort()
ans = 1
for i in range(len(A)):
    ans = ans * A[i]
    if ans > MAX:
        print(-1)
        exit()
print(ans)
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 13 18:45:47 2020

@author: kawati
"""

N = int(input())

MAX = 10**18
ans = 1
a = list(map(int, input().split())) #mapでintにしつつinputで取得

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


for x in a:
    ans *= x
    if ans > MAX:
        print(-1)
        exit(0)
        
        #exit(0)
print(ans)
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)
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict

n=IN()
a=LI()
p=1
if 0 in a:
    print(0)
    exit()
for i in a:
    p*=i
    if p>pow(10,18):
        print(-1)
        exit()
print(p)
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n = int(rl())
	ans = 1
	lim = 10**18
	flag = False
	for a in rli():
		if flag:
			if a == 0:
				ans = 0
				print(0)
				return
			continue
		ans *= a
		if ans > lim:
			flag = True
	print(ans if not flag else -1)
	stdout.close()

if __name__ == "__main__":
	main()
import collections
N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
def main():
    if c[0] >0:
        print(0)
        return

    ans = 1
    for a in A:
        ans *= a
        if ans > 1e18:
            ans = -1
            break
    if ans > 1e18:
        ans = -1
    print(ans)
main()
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)

    if 0 in A:
        print('0')
        return
    prod=1
    for a in A:
        prod*=a
        if prod> 1000000000000000000:
            print('-1')
            return
    print(prod)

ans=main()
n = int(input())
l = list(map(int,input().split()))
l = sorted(l)

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

print(-1 if ans > 10**18 else ans)
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
    if result<=10**18:
        print(result)
n = int(input())
a = list(map(int, input().split()))

a.sort()
tmp = a[0]
f = True
for i in range(1, n):
    tmp *= a[i]

    if tmp > 10 ** 18:
        f = False
        break

if f:
    print(tmp)
else:
    print(-1)
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

MX = 10**18
n=ni()
a = sorted(nl())



num = 1
for i in range(n):
  num*=a[i]
  if num > MX:
    print(-1)
    exit()
print(num)
N = int(input())
A = list(map(int, input().split()))
result = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        result *= A[i]
        if result > 10**18:
            print(-1)
            quit()
    print(result)
N = int(input())
A = list(map(int, input().split()))

if 0 in A:
    ans = 0
else:
    ans = 1
    for Ai in A:
        ans *= Ai
        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)
else:
    for i in range(n):
        ans *= a[i]
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)
n = int(input())
arr = list(map(int,input().split()))
if 0 in arr:
    print(0)
else:
    res = 1
    flag = 0
    for i in arr:
        res = res*i
        if res>10**18:
            flag = 1
            break
    if flag==1:
        print(-1)
    else:
        print(res)