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.math.BigInteger;
import java.util.*;
import java.io.*;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
        FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); }
        String next() { while (st == null || !st.hasMoreElements()) {
            try { st = new StringTokenizer(br.readLine()); }
            catch (IOException e) { e.printStackTrace(); } }
            return st.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }

        String nextLine() {
            String str = "";
            try { str = br.readLine(); }
            catch (IOException e) { e.printStackTrace(); }
            return str;
        }
    }

    public static void main(String[] args) throws IOException {
        FastReader ip = new FastReader();
        OutputStream output = System.out;
        PrintWriter out = new PrintWriter(output);
        int n=ip.nextInt();
        long arr[]=new long[n];
        HashMap<Long,Integer> hm=new HashMap<>();
        HashSet<Long> hs=new HashSet<>();
        for(int i=0;i<n;i++){
            arr[i]=ip.nextInt();
            if(hm.containsKey(arr[i])){
                hm.put(arr[i],hm.get(arr[i])+1);
            }else{
                hm.put(arr[i],1);
            }
            hs.add(arr[i]);
        }

        ArrayList<Long> al = new ArrayList<>(hs);
        long ans=0;
        for(int i=0;i<n;i++){
            long x=arr[i];
            for(int j=0;j<=31;j++){
                long y=(long)Math.pow(2,j);
                long rem=y-x;
                if(rem==x){
                    if(hm.get(x)>1){
                        ans+=(hm.get(x)-1);
                    }
                }else{
                    if(hm.containsKey(rem)){
                        ans+=hm.get(rem);
                    }
                }
            }
        }
        out.println(ans/2);

        out.close();
    }
}