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.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.Vector;
 
 
 
public class codeforces {
	static int k;
	public static void main(String[] args) throws IOException{
 
		FastScanner sc = new FastScanner();
	    PrintWriter out = new PrintWriter(System.out);
	    int n=sc.nextInt();
	    HashMap<Long,Long> map = new HashMap<Long,Long>();
	    long arr[]= new long [33];
	    arr[0]=1 ;
	    for(int i=1;i<32;i++) arr[i]=2*arr[i-1];
	    long ans =0 ;
	    for(int i=0;i<n;i++){
	    	long x =sc.nextLong();
	    	for(int j=0;j<33;j++){
	    		long z =arr[j]-x ;
	    		if(z>0){
	    			Long t =map.get(z);
	    		if(t!=null) ans+=map.get(z);
	    			}
	    		}
	    	if(map.get(x)==null)
	    		map.put(x, 1L);
	    	else
	    		map.put(x, map.get(x)+1);
	    	}
	    
	    	System.out.println(ans);
	    }
	    
	    

	    
    
	
	
	



  
	    
	}
	
		
		
		









	/*static boolean next_permutation(int[] p) {
		  for (int a = p.length - 2; a >= 0; --a)
		    if (p[a] < p[a + 1])
		      for (int b = p.length - 1;; --b)
		        if (p[b] > p[a]) {
		          int t = p[a];
		          p[a] = p[b];
		          p[b] = t;
		          for (++a, b = p.length - 1; a < b; ++a, --b) {
		            t = p[a];
		            p[a] = p[b];
		            p[b] = t;
		          }
		          return true;
		        }
		  return false;
		}
 
	  */  
 
 
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
class FastScanner {
 
 
 
 
    BufferedReader br;
    StringTokenizer st;
 
    public FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }
 
    public FastScanner(String s) {
        try {
            br = new BufferedReader(new FileReader(s));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
 
    String nextToken() {
        while (st == null || !st.hasMoreElements()) {
            try {
 
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
 
    int nextInt() {
        return Integer.parseInt(nextToken());
    }
 
    long nextLong() {
        return Long.parseLong(nextToken());
    }
 
    double nextDouble() {
        return Double.parseDouble(nextToken());
    }
 
 
}