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.*;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        new Solution().solve();
    }

}

class Solution {
    public void solve() throws Exception {
        // FastReader fr = new FastReader("input.txt");
        FastReader fr = new FastReader();
        FastWriter fw = new FastWriter();
        int n = fr.nextInt();
        long[] powersOf2 = new long[33];
        powersOf2[0] = 1;
        for (int i = 1; i <= 32; i++) {
            powersOf2[i] = powersOf2[i - 1] << 1;
        }
        long ans = 0;
        var map = new HashMap<Long, Long>();
        for (int i = 0; i < n; i++) {
            long x = fr.nextLong();
            for(long p : powersOf2){
                ans += map.getOrDefault(p - x, 0L);
            }
            map.put(x, map.getOrDefault(x, 0L) + 1);
        }

        fw.println(ans);

        fw.flush();
    }
}


class FastReader {
    private final BufferedReader br;
    private StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public FastReader(String filePath) throws FileNotFoundException {
        br = new BufferedReader(new InputStreamReader(new FileInputStream(filePath)));
    }

    public String nextString() throws IOException {
        if (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextString());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextString());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextString());
    }
}

class FastWriter {
    private final BufferedWriter bw;

    public FastWriter() {
        bw = new BufferedWriter(new OutputStreamWriter(System.out));
    }

    public void println(Object o) throws IOException {
        bw.write(o.toString());
        println();
    }

    public void println() throws IOException {
        bw.write('\n');
    }

    public void printSp(Object o) throws IOException {
        bw.write(o.toString());
        bw.write(' ');
    }

    public void flush() throws IOException {
        bw.flush();
    }
}
