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.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
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.List;
import java.util.Map;
import java.util.Map.Entry;

//import Number_theory.pair;

import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

//import graph_representation.edge;
public class hacker49 {
	public static int r1=0;
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
static 	ArrayList<Integer>[] f=new ArrayList[400001];
static int[] vis=new int[400001];
static 	int[] deg=new int[100001];
	static HashMap<Long,Integer> e=new HashMap<>();
	public static void main(String[] args) {
		OutputStream outputStream =System.out;
	    PrintWriter out =new PrintWriter(outputStream);
		FastReader s=new FastReader();
HashMap<Long,Long> e=new HashMap<>();
int n=s.nextInt();
//long d=2;
//int c=0;
//while(c<64) {
//	e.add(d);
//	d*=2;
//	c++;
//}

long[] a=new long[n+1];
//long count=0;
for(int i=1;i<=n;i++) {
	a[i]=s.nextLong();
	if(!e.containsKey(a[i])) {
		e.put(a[i], (long) 1);
	}else {
		e.put(a[i], e.get(a[i])+1);
	}
}
long count=0;
for(int i=1;i<=n;i++) {
	long d=1;
	int c=0;
	while(d<a[i]) {
		d*=2;
		c++;
	}
	if(e.get(a[i])==1) {
		e.remove(a[i]);
	}else {
		e.put(a[i], e.get(a[i])-1);
	}
	while(c<63) {
		if(e.containsKey(d-a[i])) {
			count+=e.get(d-a[i]);
		}
		d*=2;
		c++;
	}
}out.println(count);
//HashMap<Long> e=new Hash
//System.out.println(count);
//long dq=(long) Math.pow(10, 18);
//System.out.println(Math.log(dq)/Math.log(2));
		out.close();

	}
	static void dfs(int node) {
		vis[node]=1;
		for(int i=0;i<f[node].size();i++) {
			if(vis[f[node].get(i)]==0) {
				dfs(f[node].get(i));
			}
		}
	}
	static class pair{
		private long a;
		private long b;
		pair(long a,long b){
			this.a=a;
			this.b=b;
		}
	}
	public static long im(long a) {
		return binary_exponentiation_1(a,mod-2)%mod;
	}
	public static long binary_exponentiation_1(long a,long n) {
		long res=1;
		while(n>0) {
			if(n%2!=0) {
				res=((res)%(1000000007) * (a)%(1000000007))%(1000000007);
				n--;
			}else {
				a=((a)%(1000000007) *(a)%(1000000007))%(1000000007);
				n/=2;
			}
		}
		return (res)%(1000000007);
		
	}

	public static long[] fac=new long[100001];
	public static void find_factorial() {
		fac[0]=1;
		fac[1]=1;
		for(int i=2;i<=100000;i++) {
			fac[i]=(fac[i-1]*i)%(mod);
		}
	}
	static long c1=0;
	static long c2=0;
	static boolean bs1(long pos,long n,long x) {
		long l=0;
		long r=n;
		
		out:while(l<r) {
		long mid=(l+r)/2;
			if(mid<pos) {
//				if(l!=pos) {
//				c1++;}
				c1++;
				l=mid+1;
				
			}else {
				r=mid;
				c2++;
			}
		}
		if(c1<=x && c2<=(n-x)) {
//			return true;
//			System.out.println(c1+" "+c2);
		return true;
		}else {
			return false;
		}
		
	}
	static long v1=0;
	static long v2=0;
	static void bs2(long pos,long n,long x) {
		long left = 0, right = n;
		 
	    while(left < right) {
	        long middle = (left + right) / 2;
	        if (pos >= middle) {
	            if (pos != middle) v1++;
	            left = middle + 1;
	        }
	        else if (pos < middle){
	            v2++;
	            right = middle;
	        }
	    }
//		retur true
	    System.out.println(v1+" "+v2);
	}
	
	static long mod=1000000007;
	public static long GCD(long a,long b) {
		if(b==(long)0) {
			return a;
		}
		return GCD(b , a%b);
	}
	static long c=0;
	public static long res=1;
	public static void prime_factorization(long n) {
		for(long i=2;(long)(i*i)<=n;i++) {
			if(n%i==0) {
				long count=0;
				while(n%i==0) {
					count++;
					n/=i;
				}
//			prime_pairs.add(new pair(i,count));
//			res*=(count+1);
				c+=(count);
			}
		}
		if(n>1) {
//			prime_pairs.add(new pair(n,1));
//		res*=2;
			c+=(1);
		}
		
	}
	
		
	
}