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.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeMap;
	
	
	
	public class ABC {
	
		public static void main(String[] args) throws IOException{
			
			Scanner sc = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out); 
			int n = sc.nextInt();
			long[] a = new long[n];
			TreeMap<Long, Integer> map = new TreeMap<>();
			for(int i = 0; i < n; i++)
			{
				long x = sc.nextLong();
				a[i] = x;
				Integer freq = map.get(x);
				if(freq == null)
					freq = 0;
				map.put(x, freq+1);
			}
			long ans = 0;
			for(int i = 0; i< n; i++)
			{
				for(long j = 2; j <= 1l<<31; j*=2)
				{
					long rem = j - a[i];
					Integer freq = map.get(rem);
					if(freq == null)
						freq = 0;
					if(rem == a[i])
						freq--;
					//System.out.println(freq);
					ans += freq;
				}
				map.put(a[i], map.get(a[i])-1);
			}
			out.println(ans);
			out.flush();
		
		}
		
		static class Scanner 
		{
			StringTokenizer st;
			BufferedReader br;
	
			public Scanner(InputStream System)
			{	
				br = new BufferedReader(new InputStreamReader(System));	
			}
	
			public String next() throws IOException 
			{
				while (st == null || !st.hasMoreTokens()) 
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			}
			public String nextLine()throws IOException
			{
				return br.readLine();
			}
			public int nextInt() throws IOException 
			{
				return Integer.parseInt(next());
			}
			public char nextChar()throws IOException
			{
				return next().charAt(0);
			}
			public Long nextLong()throws IOException
			{
				return Long.parseLong(next());
			}
			public boolean ready() throws IOException
			{
				return br.ready();
			}
	
		}
	}
