407665: GYM102868 C Dark-Green

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Dark-Greentime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Dark-Green is working on the divert power task when he realizes that there are a lot of rooms that currently require power diverted to them. Specifically, there are $$$n$$$ rooms that Dark-Green must divert power to and the $$$i$$$th room has $$$a_{i}$$$ pieces of electronics which require power.

However, due to the strange effects of space travel, he realizes that the amount of power that each room needs is not linear in the number of devices present in the room. He deduces the following recursive function $$$f(x)$$$ defining the amount of power the room needs when there are $$$x$$$ devices in the room:

  • $$$f(0) = 0$$$
  • $$$f(2 \cdot x) = f(x)$$$
  • $$$f(2 \cdot x + 1) = f(x) + 1$$$

Given this, Dark-Green would like to figure out the number of unique pairs of the $$$n$$$ rooms that require the same amount of power.

Input

The first line of input will contain $$$n$$$ which is the number of rooms that require power diverted to them ($$$1 \leq n \leq 10^{4}$$$).

The second line of input will contain $$$n$$$ space-separated integers where the $$$i$$$th integer, $$$a_i$$$, represents the number of devices room $$$i$$$ requires ($$$0 \leq a_i \leq 10^{9}$$$).

Output

A single integer representing the number of unique pairs of rooms that need the same amount of power.

ExamplesInput
3
1 2 4
Output
3
Input
4
5 0 0 2
Output
1
Note

In the first example, computing $$$f(x)$$$ for all the values in the array yields us the same answer for all of them so any pair works and so there are $$$3$$$ unique pairs.

加入题单

上一题 下一题 算法标签: