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.*;
import java.math.BigInteger;
import java.util.*;





/**
 *
 * @author ehab
 */

public class JavaApplication7 {
    
  static  int count(Long  arr[], long x, int n , int f)
{
  int i; 
  int j;
     
  
  i = first(arr, f, n-1, x, n);
 

  if(i == -1)
    return i;
    
 
  j = last(arr, i, n-1, x, n);     
    

  return j-i+1;
}
 

static int first(Long  arr[], int low, int high, long x, int n)
{
  if(high >= low)
  {
    int mid = (low + high)/2;  
    if( ( mid == 0 || x > arr[mid-1]) && arr[mid] == x)
      return mid;
    else if(x > arr[mid])
      return first(arr, (mid + 1), high, x, n);
    else
      return first(arr, low, (mid -1), x, n);
  }
  return -1;
}
 
 

static int last(Long arr[], int low, int high, long x, int n)
{
  if(high >= low)
  {
    int mid = (low + high)/2;
    if( ( mid == n-1 || x < arr[mid+1]) && arr[mid] == x )
      return mid;
    else if(x < arr[mid])
      return last(arr, low, (mid -1), x, n);
    else
      return last(arr, (mid + 1), high, x, n);      
  }
  return -1;
}
   static boolean vi [] = new boolean [100001] ;
   static boolean bin(int k , int min , Integer ar[])
   {
    int max = ar.length - 1;
    while(min <= max)
    {
     int mid = (min+max) / 2 ;
     if(ar[mid] == k && !vi[mid])
         return true ;
     else if(ar[mid] > k)
         max = mid - 1 ;
     else min = mid + 1 ;
    
    
    
    }
   
   return false  ;
   }
 
    public static void main(String[] args) throws Exception 
    {
      Reader.init(System.in);
      int n = Reader.nextInt() ;
      long count = 0 ;
      int max = -1 ;
      Long ar [] = new Long [n] ;
      for(int i = 0 ; i < ar.length ; i++)
      { ar[i] = Reader.nextLong() ;
      
      
      }
      Arrays.sort(ar);
   
      long is [] = new long [32] ; long x = 1 ;
      for(int i = 0 ; i <= 31 ;i++)
      {
       is[i] = x ; 
        x *= 2 ;
       
      }
        
      for(int i = ar.length-1; i >= 0 ; i--)
       for(int j = 1 ; j < is.length ; j++)
           
           {  
               x =count(ar, is[j] - ar[i], i , 0); if (x > 0) count+= x ;}
        System.out.println(count);      
    } 
    }
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

   
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException{
    return Long.parseLong(next()) ;
    }
}



