import Data.List
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B

p2s = map (2^) [1..32]
main=do
    _<-getLine
    as<-foldl' (\m a->M.insertWith (+) a 1 m) M.empty.unfoldr (B.readInt.B.dropWhile(==' '))<$>B.getLine
    print $ sol 0 as
sol c as
    | M.null as = c
    | otherwise = case M.lookup fcc as' of
                    Just x  -> sol (c+1) (M.alter f fcc as')
                    Nothing -> sol c as'
    where
        (k,a) = M.findMax as
        as' = M.alter f k as
        fc = head $ dropWhile (<k) p2s
        fcc = if fc==k then k else fc-k

f (Just c) | c==1=Nothing | c>1 = Just (c-1)
