시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB22161368.421%

문제

Consider the binary operator $\oplus_b(x, y)$ that is defined for $b \in \{2, 4\}$ as follows. First, convert both $x$ and $y$ into base $b$. Then, for each corresponding digit pair, the resulting digit can be calculated by adding the digit pair modulo $b$. Finally, convert the result back to base ten. Notice that $\oplus_2$ is the bitwise XOR operator.

For instance, $\oplus_4(18, 7) = 21$ can be calculated as follows. The base four representations of $18$ and $7$ are $(102)_4$ and $(013)_4$, respectively. After the addition for each digit pair, the result is $(111)_4$, or $21$ in base ten.

You are given a list of $N$ integers, $A_1, A_2, \dots , A_N$.

Determine the number of pairs $(i, j)$ such that $1 ≤ i < j ≤ N$ and $\oplus_2(A_i , A_j ) = \oplus_4(A_i , A_j )$.

입력

The first line consists of an integer $N$ ($2 ≤ N ≤ 200\, 000$).

The next line consists of $N$ integers $A_i$ ($0 ≤ A_i ≤ 10^{12}$).

출력

Output a single integer representing the number of pairs $(i, j)$ such that $1 ≤ i < j ≤ N$ and $\oplus_2(A_i , A_j ) = \oplus_4(A_i , A_j )$.

예제 입력 1

5
2 2 0 1 3

예제 출력 1

9

The only pair that does not satisfy the requirements is $(4, 5)$, because $\oplus_2(1, 3) = 2$ and $\oplus_4(1, 3) = 0$.

예제 입력 2

2
17 13

예제 출력 2

0

예제 입력 3

10
13 7 29 4 18 0 4 21 12 20

예제 출력 3

14

예제 입력 4

10
0 0 0 0 0 0 0 0 0 0

예제 출력 4

45