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;
const long long inf = 100000000000000001;
const long long mod = 1000000007;
long long pow(long long x, unsigned long long y, long long p) {
  long long res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long _pow(long long a, long long b) {
  if (!b) return 1;
  long long temp = _pow(a, b / 2);
  temp = (temp * temp);
  if (b % 2) return (a * temp);
  return temp;
}
long long invmod(long long a, long long m) { return pow(a, m - 2, m); }
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
bool isprime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long cl(long long x, long long y) { return (x + y - 1) / y; }
void sub(long long &a, long long b) {
  b %= mod;
  a = (a + mod - b);
  a %= mod;
}
long long fen[(long long)1e5];
void ufen(long long i, long long val) {
  i++;
  for (; i <= 1e5; i += i & -i) fen[i] += val;
}
long long psfen(long long i) {
  long long ans = 0;
  for (; i > 0; i -= i & -i) ans += fen[i];
  return ans;
}
vector<long long> fact;
void factorial() {
  fact.resize(1e5 + 1);
  fact[0] = 1;
  for (int i = 1; i <= 1e5; i++) fact[i] = (fact[i - 1] * i) % mod;
}
unsigned long long ncrmod(unsigned long long n, long long r, long long p) {
  if (n < r) return 0;
  if (r == 0) return 1;
  return (fact[n] * invmod(fact[r], p) % p * invmod(fact[n - r], p) % p) % p;
}
vector<long long> se;
void call() {
  se.resize((long long)1e5 + 1, 1);
  for (int i = 2; i <= 1e5; i++) {
    if (se[i] == 1) {
      se[i] = i;
      for (int j = i * i; j <= 1e5; j += i) se[j] = i;
    }
  }
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> arr(n);
  map<long long, long long> m;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
    m[arr[i]]++;
  }
  long long ct = 0;
  for (long long i = 0; i < n; i++) {
    m[arr[i]]--;
    for (long long j = 0; j <= 31; j++) {
      long long p = 1LL << j;
      ct += m[p - arr[i]];
    }
  }
  cout << ct;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
    cout << endl;
  }
}
