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.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.Iterator;
import java.util.PriorityQueue;



public class acm_practice {
	static int x[];
	static long need [];
	static long has [];
	static int n;
	static int m;
	static int s;
	static student [] stu;
	static bugs [] bu;
	public static boolean checkless(int day) {
         int i=n-1;
         int sum=0;
         PriorityQueue<Integer> p = new PriorityQueue<>();
         for(int j=m-1;j>=0&&sum<=s;j=j-day) {
        	 while(i>=0&&stu[i].ab>=bu[j].com) {
        		 p.add(stu[i].cost);
        		 i--;
        	 }
        	 if(p.isEmpty())
        	     return false; 
            sum+=p.remove();
         }
         return sum<=s;
		
		 
	}
	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		HashMap<Integer, Integer> map=new HashMap<>();
//	    Scanner sc=new Scanner(System.in);
        int n=Integer.parseInt(bf.readLine());
        StringTokenizer st = new StringTokenizer(bf.readLine(), " ");
        int x[]=new int [n];
        for(int i=0;i<n;i++) {
        	x[i]=Integer.parseInt(st.nextToken());
        	 if(map.containsKey(x[i])) {
        		 map.put(x[i], map.get(x[i])+1);
        	 }else{
        		 map.put(x[i], 1);
        	 }	
        	}
        long sol=0;
        for(int i=0;i<n;i++) {
        	map.put(x[i], map.get(x[i])-1);
        	if(map.get(x[i])==0)
        		map.remove(x[i]);
        	for(int j=1;j<=40;j++) {
        		if(map.containsKey((int)Math.pow(2, j)-x[i])) {
        			sol+=map.get((int)Math.pow(2, j)-x[i]);
        		}
        	}
        }
        System.out.println(sol);
        
    }
	static class student implements Comparable<student>{
		int ab;
		int cost;
		int idx;
		public student(int ab,int idx) {
			this.ab=ab;
		    this.idx=idx;
		}
		public int compareTo(student o) {
			return ab - o.ab;
		}
	}
	 static class bugs implements Comparable<bugs>{
		int com;
		int idx;
		public bugs(int com, int idx) {
			this.com=com;
		    this.idx=idx;
		}
		public int compareTo(bugs o) {
			return com - o.com;
		}
	}
	
//	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 boolean ready() throws IOException {return br.ready();}
//
//		public double nextDouble(String x) 
//		{
//
//			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);
//		}
//
//
//	}
}
