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;
struct seg {
  int cnt;
  seg* nxt[2];
};
const int MAXN = 1E9;
seg* root = new seg{0, NULL, NULL};
int n, m;
long long ans;
int getcnt(seg* p, int l, int r, int t) {
  if (!p) return 0;
  if (l == r) return p->cnt;
  int mid = (l + r) / 2;
  if (t > mid)
    return getcnt(p->nxt[1], mid + 1, r, t);
  else
    return getcnt(p->nxt[0], l, mid, t);
}
void insrt(seg* p, int l, int r, int t) {
  ++p->cnt;
  if (l == r) return;
  int mid = (l + r) / 2;
  if (!p->nxt[0]) {
    p->nxt[0] = new seg{0, NULL, NULL};
    p->nxt[1] = new seg{0, NULL, NULL};
  }
  if (t > mid)
    insrt(p->nxt[1], mid + 1, r, t);
  else
    insrt(p->nxt[0], l, mid, t);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &m);
    for (int j = 1; j <= 30; ++j)
      if ((1 << j) > m && (1 << j) - m <= MAXN)
        ans += getcnt(root, 1, MAXN, (1 << j) - m);
    insrt(root, 1, MAXN, m);
  }
  printf("%lld\n", ans);
}
