You are given n integers a1, a2, ..., an. Find the number of pairs of indexes i, j (i < j) that ai + aj is a power of 2 (i. e. some integer x exists so that ai + aj = 2x).

Input

The first line contains the single positive integer n (1 ≤ n ≤ 105) — the number of integers.

The second line contains n positive integers a1, a2, ..., an (1 ≤ ai ≤ 109).

Output

Print the number of pairs of indexes i, j (i < j) that ai + aj is a power of 2.

Examples

Input

4
7 3 2 1


Output

2


Input

3
1 1 1


Output

3

Note

In the first example the following pairs of indexes include in answer: (1, 4) and (2, 4).

In the second example all pairs of indexes (i, j) (where i < j) include in answer.
#include <bits/stdc++.h>
using namespace std;
int getInt() {
  int x;
  scanf("%d", &x);
  return x;
}
long long getLongLong() {
  long long x;
  scanf("%I64d", &x);
  return x;
}
double getDouble() {
  double x;
  scanf("%lf", &x);
  return x;
}
char getChar() {
  char x;
  scanf("%c", &x);
  return x;
}
template <typename t>
t abs(t a) {
  if (a >= 0) return a;
  return -a;
}
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream second(s);
  string x;
  while (getline(second, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a << "  ";
  err(++it, args...);
}
void FastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
}
map<int, int> m;
int main() {
  int n = getInt();
  for (int i = 0; i < n; i++) {
    m[getInt()]++;
  }
  long long ans = 0;
  int t;
  for (auto v : m) {
    long long c = 0, ext = 0;
    for (int i = 0; i < 31; i++) {
      t = ((1llu << i) - v.first);
      if (t > v.first && m.find(t) != m.end()) {
        c += (m[t]);
      } else if (t == v.first) {
        ext += ((long long)v.second * (long long)(v.second - 1)) / 2ll;
      }
    }
    m[v.first] = 0;
    ans += (c * (long long)v.second + ext);
  }
  cout << ans << endl;
  return 0;
}
