import qualified Data.ByteString.Char8 as C
import Data.List

main = C.interact $ C.pack . show . length . get

get = unfoldr (C.readInt . C.dropWhile (<'0')) . last . C.lines

sol :: [Int] -> Int
sol = length . f . concat . filter ((==1) . length) . group . sort

f [] = []
f (a:as) = if null as || a*2>last as 
  then a:as
  else a:f (filter ((>0) . (`rem` a)) as)