import Data.List

scan :: [Int] -> Int
scan l = iter [] sl where
    iter ac [] = length ac
    iter ac (x:xs)
        | elem y xs && (all (\a -> not (elem x a || elem y a)) ac) = iter ([x, y]:ac) xs
        | otherwise = iter ac xs
        where
            y = f x
            f x = iter 2 where
                iter p
                    | x < p = p - x
                    | otherwise = iter (p*2) 
    sl = reverse (sort l)

count :: [[Int]] -> Int
count = iter [] where
    iter ac [] = length ac
    iter ac ([a, b]:xs)
        | take1 > drop1 = take1
        | otherwise = drop1
        where
            take1 = iter ([a, b]:ac) (filter (\x -> not (elem a x || elem b x)) xs)
            drop1 = iter ac xs
    
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