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

public class Main
{
    static InputReader in;
    static OutputWriter out;
    static final boolean OJ = System.getProperty("ONLINE_JUDGE") != null;

    static long[][] C = new long[100000 + 1][3];

    public static void main(String[] args) throws IOException
    {
        in = new InputReader(OJ ? System.in : new FileInputStream("in.txt"));
        out = new OutputWriter(OJ ? System.out : new FileOutputStream("out.txt"));
        computeBinomials();
        run();
        out.close();
        System.exit(0);
    }

    private static void computeBinomials()
    {
        for (int k = 1; k <= 2; k++) C[0][k] = 0;
        for (int n = 0; n <= 100000; n++) C[n][0] = 1;

        for (int n = 1; n <= 100000; n++)
            for (int k = 1; k <= 2; k++)
                C[n][k] = C[n - 1][k - 1] + C[n - 1][k];
    }

    private static void run() throws IOException
    {
        int n = in.getInt();
        int[] sequence = in.getIntArray(n);

        HashMap<Integer, Long> map = new HashMap<Integer, Long>(n << 2);
        HashSet<Long> set = new HashSet<Long>();
        for (int x : sequence)
        {
            set.add(f(map, x));
        }

        out.println(C[n - set.size() + 1][2]);
    }

    private static long f(HashMap<Integer, Long> map, int x)
    {
        if (map.containsKey(x)) return map.get(x);
        long value = 0;
        if (x == 0) return 0;
        if (x % 2 == 0) value = f(map, x >> 1);
        else value = f(map, x >> 1) + 1;
        map.put(x, value);
        map.put(x << 1, value);
        map.put(x * 2 + 1, value + 1);
        return value;
    }
}

class InputReader
{
    private BufferedReader reader;
    private StringTokenizer st;

    public InputReader(InputStream stream)
    {
        reader = new BufferedReader(new InputStreamReader(stream), 1024);
    }

    public String getString() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
        {
            String line = reader.readLine();
            if (line == null) return null;
            st = new StringTokenizer(line);
        }
        return st.nextToken();
    }

    public String getLine() throws IOException
    {
        return reader.readLine();
    }

    public int getInt() throws IOException
    {
        return Integer.parseInt(getString());
    }

    public long getLong() throws IOException
    {
        return Long.parseLong(getString());
    }

    public double getDouble() throws IOException
    {
        return Double.parseDouble(getString());
    }

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

    public int[][] getIntTable(int rowCount, int columnCount) throws IOException
    {
        int[][] table = new int[rowCount][];
        for (int i = 0; i < rowCount; i++) table[i] = getIntArray(columnCount);
        return table;
    }

    public int[] getIntArray(int len) throws IOException
    {
        int[] table = new int[len];
        for (int i = 0; i < len; i++) table[i] = getInt();
        return table;
    }
}

class OutputWriter
{
    private PrintWriter writer;

    public OutputWriter(OutputStream stream)
    {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream)));
    }

    public void print(Object... objects)
    {
        for (int i = 0; i < objects.length; i++)
        {
            if (i != 0) writer.print(' ');
            writer.print(objects[i].toString());
        }
    }

    public void print(String s, Object... objects)
    {
        for (int i = 0; i < objects.length; i++)
        {
            if (i != 0) writer.print(s);
            writer.print(objects[i].toString());
        }
    }

    public void println(Object... objects)
    {
        print(objects);
        writer.println();
    }

    public void printf(String format, Object... objects)
    {
        writer.printf(format, objects);
    }

    public void close()
    {
        writer.close();
    }
}