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.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.regex.Matcher;
import javax.swing.plaf.metal.MetalBorders.PaletteBorder;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
public class Main implements Runnable{
public static void main(String[] args) throws IOException {
new Thread(null , new Main(),"Main", 1<<26).start();
}

public void run(){
try {
PrintWriter out = new PrintWriter(System.out);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = null;
int n = parseInt(br.readLine());
long[] a = new long[n];
st = new StringTokenizer(br.readLine());
for(int i = 0; i < n ;++i) {
a[i] = parseLong(st.nextToken());
}
long count = 0;
HashMap<Long, Integer> map = new HashMap<>();
for(int i = 0 ; i < n ; ++i) {
if(map.containsKey(a[i])) count += map.get(a[i]);
for(int k = 0 ; k < 32 ; ++k) {
long val = 2 << k;
if(val > a[i]) {
if(!map.containsKey(val - a[i])) map.put(val - a[i], 1);
else map.put(val - a[i], map.get(val - a[i]) + 1);
}
}
}

out.println(count);
out.close();
}
catch (Exception e) {
e.printStackTrace();
}
}

}