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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.HashMap;
public class om {
    public static void main(String[] args)throws IOException {
        FastScanner sc=new FastScanner(System.in);
        HashMap<Integer,Integer>map=new HashMap<>();
        int x=sc.nextInt();
        int k[]=new int[32];
        int p[]=new int[x];
        long ans=0;
        for(int i=0;i<32;i++){
            k[i]=(int)Math.pow(2,i);
        }
        for(int i=0;i<x;i++){
            p[i]=sc.nextInt();
            if(map.containsKey(p[i])){
                map.put(p[i],map.get(p[i])+1);
            }
            else{
                map.put(p[i],1);
            }
        }
        for(int i=0;i<x;i++){
            map.put(p[i],map.get(p[i])-1);
            for(int c=0;c<32;c++){
                if(map.containsKey(k[c]-p[i]) && map.get(k[c]-p[i])!=0){
                    ans=ans+map.get(k[c]-p[i]);
                }
            }
        }
        System.out.println(ans);
    }
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream i) {
            br = new BufferedReader(new InputStreamReader(i));
            st = new StringTokenizer("");
        }
        public String next() throws IOException {
            if (st.hasMoreTokens())
                return st.nextToken();
            else
                st = new StringTokenizer(br.readLine());
            return next();
        }
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
    }
}
