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.
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BPowersOfTwo solver = new BPowersOfTwo();
        solver.solve(1, in, out);
        out.close();
    }

    static class BPowersOfTwo {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            Map<Long, Integer> map = new HashMap<>();
            long[] arr = new long[n];
            long[] pow = new long[34];
            pow[0] = 1;
            for (int i = 1; i < 34; i++) {
                pow[i] = 2 * pow[i - 1];
            }

            for (int i = 0; i < n; i++) {
                long a = in.nextLong();
                arr[i] = a;
                if (map.containsKey(a))
                    map.put(a, map.get(a) + 1);
                else
                    map.put(a, 1);
            }

            long ans = 0;
            for (int i = 0; i < n; i++) {
                long a = arr[i];
                for (int j = 0; j < 34; j++) {
                    if (pow[j] > a) {
                        long diff = pow[j] - a;
                        if (map.containsKey(diff)) {
                            ans += map.get(diff);

                            if (pow[j] / a == 2 && pow[j] % a == 0) {
                                ans--;
                            }
                        }
                    }
                }
                map.put(a, map.get(a) - 1);
                if (map.get(a) == 0)
                    map.remove(a);
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

