import Data.List

scan :: [Int] -> Int
scan l = iter 0 2 sl where
    iter c p [] = iter c (p*2) sl
    iter c p (x:xs)
        | p > limit = c
        | x > p = iter c (p*2) sl
        | d > 0 && elem d xs = iter (c+1) (p*2) sl  
        | otherwise = iter c p xs
        where d = p - x
    limit = 10 ^ 9
    sl = sort l
  
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