# 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), 0
A.length.times {
  A.sort.reverse.combination(2) {|a, b|
    if ((a + b) & (a + b - 1)) == 0
      A.delete(a)
      A.delete(b)
      ans += 1
      break
    end
  }
}
p ans