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.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.StringTokenizer;






public class B1 {

	/**
	 * @param args
	 */
    static int[] POWER;	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		InputStream inputStream=System.in;
        OutputStream outputStream=System.out;
        InputReader in=new InputReader(inputStream);
        PrintWriter out=new PrintWriter(outputStream);
        TaskB1_R15 solver=new TaskB1_R15();
        POWER=new int [32];
        for(int i=0;i<31;i++) POWER[i]=1<<i;
        //int t=in.nextInt();
        //while(t-->0)
        solver.solve(1, in, out);
        out.close();
	}
	
	static class TaskB1_R15{
		 public void solve(int testNumber,InputReader in,PrintWriter out)
		{
			int n=in.nextInt();
		    HashMap<Integer,Integer> map=new HashMap<Integer,Integer>();
		    int[] a=new int[n];
		    for(int i=0;i<n;i++){
		    	a[i]=in.nextInt();
		    	if(map.containsKey(a[i])){
		    		map.put(a[i], map.get(a[i])+1);
		    	}else{
		    		map.put(a[i], 1);
		    	}
		    }
		    
		    long ans=0;
		    for(int i=0;i<n;i++){
		    	for(int j=0;j<31;j++){
		    	     int b=POWER[j+1]-a[i];
		    	     if(b>0&&map.containsKey(b)){
		    	    	 if(a[i]==b)
		    	    		 ans+=map.get(b)-1;
		    	    	 else
		    	    		 ans+=map.get(b);
		    	     }
		    	}
		    }
		    out.println(ans/2);
		}
	}
	
	static class InputReader{
    	private BufferedReader reader;
    	private StringTokenizer stt;
    	
    	public InputReader(InputStream stream)
    	{
    		reader=new BufferedReader(new InputStreamReader(stream));
    	}
    	
    	public String nextLine(){
    		try{
    			return reader.readLine();
    		}catch (IOException e){return null;}
    	}
    	
    	public String nextString(){
    		while(stt==null||!stt.hasMoreTokens())
    		{
    			stt=new StringTokenizer(nextLine());
    		}
    		return stt.nextToken();
    	}
    	
    	public int nextInt(){
    		return Integer.parseInt(nextString());
    	}
    	
    	public long nextLong(){
    		return Long.parseLong(nextString());
    	}
    	
    	
    }

}
