{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}

module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust, fromMaybe )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.IO as IOA
import qualified Data.Array.MArray as MA
import Control.Monad.ST
import System.IO (stdin)
import Control.Arrow
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Generic as GV
import qualified Data.Vector.Mutable as MV
import qualified Data.Vector.Unboxed.Mutable as UMV
import Data.Ix
import Data.Ord (Down(Down))
import qualified Data.Sequence as Seq
import Data.Foldable (toList)
import Data.Fixed

debug = True

ts :: Show a => a -> a
ts a = if debug then traceShowId a else a

tss a b = if debug then traceShow a b else b


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- readInts
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- readInts
    return (a, b, c)


readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

readIntV :: Int -> IO (UV.Vector Int)
readIntV n = GV.unfoldrN n (fmap (fmap BC.tail) . BC.readInt) <$> BC.getLine

readIntegersV :: Int -> IO (V.Vector Integer)
readIntegersV n = GV.unfoldrN n (fmap (fmap BC.tail) . BC.readInteger) <$> BC.getLine

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BC.readInteger) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

divMax :: Int -> Int -> (Int, Int)
divMax a b = go a 0 where
    go acc n = let
        (x, y) = acc `divMod` b
        in
            if y == 0 then go x (n + 1) else (acc, n)

primeNums :: Int -> [(Int, Int)]
primeNums a = if last == 1 then reverse primeList else reverse $ (last, 1) : primeList where
    findMax = floor . sqrt . fromIntegral $ a
    go (acc, lst) divisor =
        let
            (dividedNum, count) = acc `divMax` divisor
        in
            if count == 0 then (acc, lst) else (dividedNum, (divisor, count) : lst)
    (last, primeList)  = foldl' go (a, []) [2..findMax]

solve ::  [Int] -> Int
solve as = go as 0 (negate 1) where
  go [] num prev = num
  go (a:as) num prev
    | a == prev = go as num a
    | vec UV.! a < 1 = case as of
        [] -> go as (num + 1) a
        m:as' -> if m == a then go as num a else go as (num + 1) a
    | otherwise = go as num a
  maxA = last as
  vec :: UV.Vector Int
  vec = runST $ do
    v <- UMV.replicate (maxA + 1) 0
    forM_ as $ \a -> do
      aNum <- UMV.read v a
      when (aNum == 0) $ forM_ [a*2, a*3..maxA] $ \num -> UMV.modify v (+1) num
    UV.freeze v



main :: IO ()
main = do
  getLine
  as <- sort <$> readInts
  print $ solve as


Measured memory_bytes: 43712