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;
int power(unsigned long long int x, unsigned long long int y) {
  unsigned long long int res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
int main() {
  unsigned long long int i;
  vector<unsigned long long int> v;
  for (i = 0; i < 33; i++) {
    unsigned long long int H = power(2, i);
    v.push_back(H);
  }
  unsigned long long int n, m, j, k, l, o, p;
  cin >> n;
  unsigned long long int a[n];
  unordered_map<unsigned long long int, unsigned long long int> M;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    M[a[i]] += 1;
  }
  unsigned long long int ans = 0;
  for (i = 0; i < n; i++) {
    unsigned long long int A = a[i];
    unsigned long long int V = lower_bound(v.begin(), v.end(), A) - v.begin();
    for (j = V; j < 33; j++) {
      unsigned long long int C = (v[j] - A);
      if (M.find(C) != M.end()) {
        if (C == A) {
          ans += (M[C] - 1);
        } else {
          ans += M[C];
        }
      }
    }
  }
  cout << ans / 2 << endl;
}
