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.
public class _702B {

    static boolean valid(int i) {
        return Integer.bitCount(i) == 1;
    }

    static int[] calc(int x) {
        int[] n = new int[x];
        for (int i = 1; i < n.length; i++)
            n[i] = i;
        return n;
    }

    public static void main(String[] args) {
        java.util.Scanner in = new java.util.Scanner(System.in);
        int n = in.nextInt();
        java.util.HashMap<Integer, Integer> map =
            new java.util.HashMap<>(n);
        
        int[] power2 = new int[31];
        power2[0] = 1;
        
        for (int i = 1; i < 31; i++)
            power2[i] = 1 << i;

        for (int i = 0; i < n; i++) {
            int x = in.nextInt();
            Integer temp = map.get(x);
            map.put(x, temp == null ? 1 : temp + 1);
        }

        map.forEach((numb, count) -> {
            if (valid(numb + numb)) add((long)count * (count - 1) >> 1);
        });
        map.forEach((numb, count) -> {
            for (int pow : power2)
                if (map.containsKey(pow - numb) && pow - numb != numb)
                    add((long)count * map.get(pow - numb));
            map.put(numb, 0);
        });
        System.out.println(ans);
    }
    static long ans = 0;

    static void add(long x) {
        ans += x;
    }

    static boolean solve(int[] x) {
        long sum = 0;
        for (int i = 0; i < x.length - 1; i++)
            for (int j = i + 1; j < x.length; j++)
                if (Long.bitCount(x[i] + x[j]) == 1)
                    sum++;
        System.out.println(sum);
        return true;
    }
}
