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;
bool isPrime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
void solve() {
  long long int i, j, k, n;
  vector<long long int> pow2(33);
  pow2[0] = 1;
  for (i = 1; i < 33; i++) {
    pow2[i] = 2 * pow2[i - 1];
  }
  cin >> n;
  vector<long long int> v(n);
  map<long long int, long long int> m;
  for (i = 0; i < n; i++) {
    cin >> v[i];
    m[v[i]]++;
  }
  long long int ans = 0;
  for (i = 0; i < n - 1; i++) {
    for (j = 0; j < 33; j++) {
      if (m[pow2[j] - v[i]]) {
        ans += m[pow2[j] - v[i]];
        if (v[i] == pow2[j] - v[i]) ans--;
      }
    }
    m[v[i]]--;
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int i, j, l, k, t, n;
  t = 1;
  while (t--) solve();
}
