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>
const long long lim = 1e5 + 5;
using namespace std;
vector<long long> v;
bool vis[200005], vis1[lim];
long long n, m, k;
vector<long long> adj[100005];
set<long long> s;
long long ans, cnt;
void dfs(long long node) { vis[node] = 1; }
long long power(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  set<long long> st;
  map<long long, long long> mp;
  long long a[n];
  ;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
    s.insert(a[i]);
  }
  k = 1;
  ;
  for (long long i = 0; i < 30; i++) {
    k = k * 2;
    v.push_back(k);
  }
  for (auto x : s) {
    long long i = x;
    ;
    for (long long j = 0; j < 30; j++)
      if (v[j] > i) {
        if (mp[v[j] - i] > 0) {
          if (v[j] - i == i) {
            k = (mp[i] * (mp[i] - 1)) / 2;
            ans += k;
          } else if (v[j] - i != i) {
            k = mp[i] * mp[v[j] - i];
            ans += k;
          }
        }
      }
    mp[i] = 0;
  }
  cout << ans;
}
