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;
template <typename T>
inline T GCD(T a, T b) {
  a = abs(a);
  b = abs(b);
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
template <typename T>
inline T LCM(T x, T y) {
  T tp = GCD(x, y);
  if ((x / tp) * 1. * y > 9e18) return 9e18;
  return (x / tp) * y;
}
template <typename T>
inline T BigMod(T A, T B, T M) {
  T ret = 1;
  while (B) {
    if (B & 1) ret = (ret * A) % M;
    A = (A * A) % M;
    B = B >> 1;
  }
  return ret;
}
template <typename T>
inline T InvMod(T A, T M) {
  return BigMod(A, M - 2, M);
}
long long gcdr(long long a, long long b) {
  if (a == 0) return b;
  return gcdr(b % a, a);
}
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
void FastIO() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
}
int main() {
  long long t, i, j, n, x, y;
  t = 1;
  while (t--) {
    scanf("%lld", &n);
    vector<long long> V;
    map<long long, long long> tot;
    for (i = 0; i < n; i++) {
      scanf("%lld", &x);
      V.push_back(x);
      tot[x]++;
    }
    sort(V.begin(), V.end());
    vector<long long> power;
    long long p = 1;
    for (i = 1; i < 32; i++) {
      p = p * 2;
      power.push_back(p);
    }
    long long ans = 0;
    for (i = 0; i < n; i++) {
      tot[V[i]]--;
      for (j = 0; j < power.size(); j++) {
        if (power[j] < V[i]) continue;
        long long req = abs(power[j] - V[i]);
        ans += tot[req];
      }
    }
    printf("%lld", ans);
    printf("\n");
  }
  return 0;
}
