n = gets.to_i
balls = gets.split(" ").map(&:to_i).sort.reverse

count = 0

def power_of_two?(n)
  (n & (n-1)).zero?
end

done = {}

balls.each_with_index do |ball1, i|
  next if done[ball1]
  balls[i+1..-1].each do |ball2|
    next if done[ball2]
    if power_of_two?(ball1 + ball2)
      done[ball2] = true
      count += 1
      break
    end
  end
end

puts count