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.
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.*;

/**
 *
 * @author Bryan AW
 */
public class Codeforces {

    /**
     * @param args the command line arguments
     */
     
    static int Pos(ArrayList <Integer> arr, int l, int r, int p) {
        
            while (l<r){
                int m=(l+r)/2;
                if (arr.get(m)<=p){
                    l=m+1;
                }
                else {
                    r=m;
                }
            }

            return l;
    }
     
    public static void main(String[] args) {
        
        //Powers of Two
            
        Scanner sc=new Scanner(System.in);
    
        int n=Integer.parseInt(sc.next());

        Integer[] a=new Integer[n];

        HashMap <Integer, ArrayList <Integer>> idx
        =new HashMap <Integer, ArrayList <Integer>> ();

        for (int i=0;i<n;i++){
            a[i]=Integer.parseInt(sc.next());
            ArrayList <Integer> v=idx.get(a[i]);
            if (v==null){
                ArrayList <Integer> arr=new ArrayList <Integer> ();
                arr.add(i);
                idx.put(a[i], arr);
            }
            else {
                idx.get(a[i]).add(i);
            }
        }

        long ans=0;

        for (int i=0;i<n;i++){
            int x=2;
            for (int j=1;j<=32;j++){
                ArrayList <Integer> arr=idx.get(x-a[i]);
                if (arr!=null){
                    int sz=arr.size();
                    int ind=Pos(arr, 0, sz, i);
                    ans+=(sz-ind);
                }
                x*=2;
            }
        }

        System.out.print(ans);

        System.out.println();
        
    }
    
}