import Data.List
import qualified Data.Map as Map

scan :: [Int] -> Int
scan l = iter 0 (Map.fromList [(k,'0')| k <- l]) where
    iter c m
        | Map.null m = c
        | otherwise  =
            if Map.member y m1
                then iter (c+1) (Map.delete y m1)
                else iter c m1
                where
                    ((x,_), m1) = Map.deleteFindMax m
                    y = iter 2 where
                            iter p
                                | x < p = p - x
                                | otherwise = iter (p*2)
    
readData :: IO [Int]
readData = do
    line1 <- getLine
    let xs = map (\x -> read x :: Int) (words line1)
    return xs

main :: IO() 
main = do
    n  <- readLn :: IO Int
    la <- readData
    let ans = scan la
    print ans