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.
/* package whatever; // don't place package name! */
 
import java.util.*;
import java.lang.*;
import java.io.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;import java.math.BigInteger;
import java.io.OutputStreamWriter;
 
/* Name of the class has to be "Main" only if the class is public. */
public class bbg
{
	public static int result;
	public static int elemente;
 
public static ArrayList<Integer> [] graph;
 
public static int[]cats;
 
public static int vizitat[];
public static int x;
//public static HashMap<String, Integer> map2;
 
 
	public static void main (String[] args) throws IOException {
 
Scanner input = new Scanner(System.in);
 
HashMap<Integer, Integer> contor1= new HashMap<Integer, Integer>();
HashMap<Integer, Integer> contor2= new HashMap<Integer, Integer>();


HashMap<Long, Long> map= new HashMap<Long, Long>();
HashMap<String, Integer> curatare= new HashMap<String, Integer>();
HashMap<String, Integer> combinari= new HashMap<String, Integer>();
 
 


 BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
 
 //StringTokenizer token=new StringTokenizer(str);
 
int n=input.nextInt();

Long v[]=new Long[n];


Long p[]=new Long[65];

p[0]=1l;

for(int i=1;i<65;i++) p[i]=2L*p[i-1];

v[0]=input.nextLong();
map.put(v[0],1l);


Long contor=0l;

for(int i=1;i<n;i++){
v[i]=input.nextLong();

for(int j=0;j<65;j++) if (map.containsKey(p[j]-v[i])){
 contor+=map.get(p[j]-v[i]);
// System.out.println(v[i]+"  "+p[j]);
 
 
} 
if(map.containsKey(v[i]))
map.put(v[i],1l+map.get(v[i]));

else map.put(v[i],1l);


}

	System.out.println(contor);



}


}