Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pairs that can be formed.

Here, a positive integer is said to be a power of 2 when it can be written as 2^t using some non-negative integer t.

Constraints

* 1 \leq N \leq 2\times 10^5
* 1 \leq A_i \leq 10^9
* A_i is an integer.

Input

Input is given from Standard Input in the following format:


N
A_1 A_2 ... A_N


Output

Print the maximum possible number of pairs such that the sum of the integers written on each pair of balls is a power of 2.

Examples

Input

3
1 2 3


Output

1


Input

5
3 11 14 5 13


Output

2
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new PrintStream(System.out));
        int n=Integer.parseInt(f.readLine());
        long[]arr=new long[n];
        StringTokenizer st=new StringTokenizer(f.readLine());
        HashMap<Long,Integer>hs=new HashMap<>();

        for(int i=0;i<n;i++){
            arr[i]=Long.parseLong(st.nextToken());
            if(!hs.containsKey(arr[i])){
                hs.put(arr[i],1);
            }
            else
            hs.put(arr[i],hs.get(arr[i])+1);
        }
        Arrays.sort(arr);
        long ans=0;
        for(int i=n-1;i>=0;i--){
            if(!hs.containsKey(arr[i]))continue;
            if(hs.get(arr[i])==1)
            hs.remove(arr[i]);
            else hs.put(arr[i],hs.get(arr[i])-1);
            long j=1;
            while(j<=arr[i]){

                j*=2;
            }
            if(hs.containsKey(j-arr[i])){
                ans++;
                if(hs.get(j-arr[i])==1)
                    hs.remove(j-arr[i]);
                else hs.put(j-arr[i],hs.get(j-arr[i])-1);
            }

        }
        System.out.print(ans);
        f.close();
        out.close();
    }
}