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 digits(long long n) {
  int digit = 0;
  while (n) {
    digit++;
    n /= 10;
  }
  return digit;
}
long long power(long long base, long long exp) {
  long long answer = 1;
  for (int i = 0; i < exp; i++) {
    answer *= base;
  }
  return answer;
}
vector<long long> powersOf2;
void generate() {
  long long number;
  long long i = 0;
  do {
    number = power(2, i);
    powersOf2.push_back(number);
    i++;
  } while (digits(number) <= 9);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  generate();
  int n;
  cin >> n;
  vector<long long> input;
  for (int i = 0; i < n; ++i) {
    long long temp;
    cin >> temp;
    input.push_back(temp);
  }
  long long answer = 0;
  sort(input.begin(), input.end());
  for (int i = n - 1; i >= 0; i--) {
    long long current = input[i];
    input.pop_back();
    for (int j = 0; j < powersOf2.size(); j++) {
      long long required = powersOf2[j] - current;
      if (required <= 0)
        continue;
      else {
        if (binary_search(input.begin(), input.end(), required)) {
          int size = upper_bound(input.begin(), input.end(), required) -
                     lower_bound(input.begin(), input.end(), required);
          answer += size;
          break;
        }
      }
    }
  }
  cout << answer << endl;
  return 0;
}
