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.util.StringTokenizer;
import java.util.TreeMap;

public class A {

	private static final BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
	private static StringTokenizer st;

	public static void main(String[] args) throws IOException {
		line();
		int n = nextInt();
		long[] array = new long[n];
		line();
		TreeMap<Long, Integer> cant = new TreeMap<>();
		for (int i = 0; i < n; i++) {
			array[i] = nextInt();
			cant.put(array[i], cant.getOrDefault(array[i], 0) + 1);
		}

		long[] pot = new long[32];
		pot[0] = 1;
		pot[1] = 2;
		for (int i = 2; i < pot.length; i++) {
			pot[i] = pot[i - 1] * 2;
		}
		long r = 0;
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < pot.length; j++) {
				long dif = pot[j] - array[i];
				if (dif > 0) {
					int parejas = cant.getOrDefault(dif, 0);
					if (dif == array[i]) {
						parejas--;
					}
					r += parejas;
				}
			}
		}
		System.out.println(r / 2);

	}

	private static void line() throws IOException {
		st = new StringTokenizer(BR.readLine());
	}

	@SuppressWarnings("unused")
	private static void line(String del) throws IOException {
		st = new StringTokenizer(BR.readLine(), del);
	}

	@SuppressWarnings("unused")
	private static String token() {
		return st.nextToken();
	}

	@SuppressWarnings("unused")
	private static int nextInt() {
		return Integer.parseInt(token());
	}

	@SuppressWarnings("unused")
	private static long nextLong() {
		return Long.parseLong(token());
	}

	@SuppressWarnings("unused")
	private static double nextDouble() {
		return java.lang.Double.parseDouble(token());
	}

}
