import Data.IntMap (IntMap,Key)
import qualified Data.IntMap as IM

main = do
  getLine
  as <- map read.words<$>getLine
  print $ solve as

solve as = go ims where
  ims = IM.fromListWith (+) $ zip as $ repeat 1
  go :: IntMap Int -> Int
  go ims
    | IM.null ims = 0
    | otherwise = case IM.lookup d ims of
      Nothing -> go newIms
      Just 1 -> 1 + go (IM.delete d newIms)
      Just n -> 1 + go (IM.adjust pred d newIms)
    where
    newIms = case mn of
      1 -> IM.delete m ims
      _ -> IM.adjust pred d ims
    (m,mn) = IM.findMax ims
    d = 2^ceiling(logBase 2 $ fromIntegral m)-m
