// Coroana te rog
// Manipularea biturilor in timp constant
// Cu bucle - O(n^2) curat
#include <iostream>
int main() {
size_t suma, n, *v, c = 0;
std::cin >> n;
v = new size_t[n];
for (size_t i = 0; i < n; ++i)
std::cin >> v[i];
for (size_t j, i = 0; i < n - 1; ++i)
for (j = i + 1; j < n; ++j) {
suma = v[i] + v[j];
c += !(suma & (suma - 1));
}
std::cout << c;
delete[] v;
}