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;
long long GCD(long long a, long long b) { return (b == 0 ? a : GCD(b, a % b)); }
long long getMax(size_t a, size_t b) { return ((a > b) ? a : b); }
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
string CF[] = {"NO", "YES"};
string alpha = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main() {
  long long n;
  long long len = 0, tot = 1;
  vector<long long> re;
  while (tot <= 1e10) {
    re.push_back(tot);
    len++;
    tot <<= 1;
  }
  while (cin >> n) {
    map<long long, long long> s;
    vector<long long> x(n);
    long long res = 0;
    for (int i = 0; i < (int)(n); ++i) cin >> x[i];
    for (int i = 0; i < (int)(n); ++i) {
      for (int j = 0; j < (int)(len); ++j) {
        if (re[j] > x[i]) res += s[re[j] - x[i]];
      }
      s[x[i]]++;
    }
    cout << res << endl;
  }
  return 0;
}
