# ball[i] = A_i, max pair (sum = 2 ^ n)
# 2 ^ n ? = !(n & (n - 1))
n, A, ans = gets.to_i, gets.chomp.split.map(&:to_i).sort!, 0
cnt = A.length
while (cnt -= 1) > 0 && !A.empty?
  # 3 5 11 13 14 -> 14
  # 3 5 11 13 -> 13 [3, 13] del
  # 5 11 -> [5 11] del
  found = false
  A[0..-2].each{|a|
    if ((a + A[-1]) & (a + A[-1] - 1)) == 0
      A.delete(a)
      A.delete(A[-1])
      ans += 1
      found = true
      break
    end
  }
  A.delete(A[-1]) if !found
end
p ans