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.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.swing.event.TreeSelectionEvent;

public class Test {
	static int k, n, m, b;
	static int[][] arr;
	static int[] premute;
	static TreeMap<Integer, String> map;
	static ArrayList<Long> powers;

	public static long pow(long a, long b) {
		return help(a, b, 0);
	}

	public static long help(long a, long b, int i) {
		if (i == b)
			return 1;
		return a * 1l * help(a, b, i + 1) * 1l;
	}

	static void generate() {
		int i = 0;
		while (pow(2, i) <= 2e9) {
			powers.add(pow(2, i++));
		}
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		TreeMap<Long, Integer> Map = new TreeMap<Long, Integer>();
		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			long a = sc.nextLong();
			if (Map.containsKey(a*1l)) {
				Map.put((long)(a*1l), Map.get(a) + 1);
			} else {
				Map.put(a*1l, 1);
			}
			arr[i] = a;
		}
		powers = new ArrayList<Long>();
		generate();
		long c = 0;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < powers.size(); j++){
				if (Map.containsKey((powers.get(j) - arr[i])*1l)) {
					if (powers.get(j) - arr[i] == arr[i] && Map.get(powers.get(j) - arr[i]) > 1) {
						c += (Map.get(powers.get(j) - arr[i])) - 1;
					} else if (powers.get(j) - arr[i] != arr[i])
						c += Map.get(powers.get(j) - arr[i]);
				}
			}
		}
		System.out.println(c / 2);

	}

	public static class Dragons implements Comparable<Dragons> {
		int x, y;

		public Dragons(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public int compareTo(Dragons A) {
			if (x == A.x)
				return A.y - y;
			return x - A.x;
		}

		public String toString() {
			return x + " " + y;
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}