Dima got into number sequences. Now he's got sequence a1, a2, ..., an, consisting of n positive integers. Also, Dima has got a function f(x), which can be defined with the following recurrence:

  * f(0) = 0; 
  * f(2·x) = f(x); 
  * f(2·x + 1) = f(x) + 1. 



Dima wonders, how many pairs of indexes (i, j) (1 ≤ i < j ≤ n) are there, such that f(ai) = f(aj). Help him, count the number of such pairs. 

Input

The first line contains integer n (1 ≤ n ≤ 105). The second line contains n positive integers a1, a2, ..., an (1 ≤ ai ≤ 109).

The numbers in the lines are separated by single spaces.

Output

In a single line print the answer to the problem.

Please, don't use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

3
1 2 4


Output

3


Input

3
5 3 1


Output

1

Note

In the first sample any pair (i, j) will do, so the answer is 3.

In the second sample only pair (1, 2) will do.
import java.util.*;

import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class  test{
	
	// ArrayList<Integer> lis = new ArrayList<Integer>();
	// ArrayList<String> lis = new ArrayList<String>();
	// PriorityQueue<Integer> que = new PriorityQueue<Integer>();
	//  Stack<Integer> que = new Stack<Integer>();
    //	static long sum=0;
	// 1000000007 (10^9+7)
	static int mod = 1000000007;
	//static int mod = 1000000009,r=0;
   // static int dx[]={1,-1,0,0};
//	static int dy[]={0,0,1,-1};
//	static int dx[]={1,-1,0,0,1,1,-1,-1};
//  static int dy[]={0,0,1,-1,1,-1,1,-1};
	//static long H,L;
	//static Set<Integer> set = new HashSet<Integer>();
public  static void main(String[] args)   throws Exception, IOException{
   //String line=""; throws Exception, IOException
   //(line=br.readLine())!=null
	//Scanner sc =new Scanner(System.in);
	// !!caution!! int long //  
	Reader sc = new Reader(System.in);
  // while( ){
	  // int  n=sc.nextInt(),m=sc.nextInt();//a[]=new int[n],b[]=new int[n];
	//int  n=sc.nextInt();
	
	int n=sc.nextInt();
    long a[]=new long[33];
    ArrayList<Long> lis = new ArrayList<Long>();
    ArrayList<Long> lis2 = new ArrayList<Long>();
    long k=1,z=0;
    
    while( k<=2000000001L ){ lis.add(k);lis2.add(k-1);
  
    k*=2; k++;}
    
    //db(lis.size());
    
    for(int t=0; t<n ;t++){
       long x=sc.nextLong();
       int j=0;
       if( x==0 ){ z++; continue; }
    	 while( 0<x ){
    		 if( lis.contains(x) ){int c=0; while( 1<x ){x/=2; c++;}  a[ c+j ]++;break; }
    		 if( (x&1)==1 ){ x=(x-1)/2; j++;}
    		 else x/=2;
    	 }
   
    }
   long r=0;
  // db(a);
   for(int i=0; i<33;i++){  if(a[i]<2)continue; r+=(a[i]*(a[i]-1))/2;   }
   if( 2<=z )r+= (z-1)*z/2;
		System.out.println(r);

    
     
}

static void db(Object... os){
    System.err.println(Arrays.deepToString(os));

}

}



class Reader
{
	private BufferedReader x;
	private StringTokenizer st;
	
	public Reader(InputStream in)
	{
		x = new BufferedReader(new InputStreamReader(in));
		st = null;
	}
	public String nextString() throws IOException
	{
		while( st==null || !st.hasMoreTokens() )
			st = new StringTokenizer(x.readLine());
		return st.nextToken();
	}
	public int nextInt() throws IOException
	{
		return Integer.parseInt(nextString());
	}
	public long nextLong() throws IOException
	{
		return Long.parseLong(nextString());
	}
	public double nextDouble() throws IOException
	{
		return Double.parseDouble(nextString());
	}
}

/*

class P implements Comparable<P>{
//	implements Comparable<P>
	int v,w;
	P(int v,int w){
		this.v=v;
		this.w=w;
	
	} 
	public int compareTo(P x){
	   	 return w-x.w;//ascend 
	   }
}
*/
