题目描述
Problem Description
At a recent gathering, $N$ people sat around a circular table, where $N$ is an even number. The seats are numbered in a clockwise direction from $1$ to $N$. Each person wears a hat with a number written on it. Specifically, the person in seat $i$ wears a hat with the number $H_i$.
Each person looks at the person directly opposite them in the circle.
Your task is to determine the number of people who see a hat with the same number as their own.
Input Format
The first line of input contains a positive even number $N$, representing the number of people at the gathering.
The next $N$ lines each contain a non-negative integer $H_i$, representing the number written on the hat of the person in seat $i$.
Output Format
Output a single integer, which is the number of people who see a hat with the same number as their own.
Sample Input and Output
Sample Input #1
4
0
1
0
1
Sample Output #1
4
Sample Input #2
4
1
0
0
1
Sample Output #2
0
Notes
[Sample 1 Explanation]
The four seats around the table are arranged as shown below. The numbers inside the circles represent the numbers on the hats, and the numbers outside the circles represent the seat numbers. Note that everyone sees a number equal to their own hat number. The people in seats $1$ and $3$ see the number $0$, and the people in seats $2$ and $4$ see the number $1$.
[Sample 2 Explanation]
The four seats around the table are arranged as shown below. The numbers inside the circles represent the numbers on the hats, and the numbers outside the circles represent the seat numbers. Note that no one sees a number equal to their own hat number. The people in seats $1$ and $4$ see the number $0$, and the people in seats $2$ and $3$ see the number $1$.
[Data Range]
This problem uses batched testing.
For all data, it is guaranteed that $1 \leq N \leq 10^6$ and $0 \leq H_i \leq 2 \times 10^6$.
The following table shows the distribution of scores for this problem:
| Score | Description | Range of $N$ | Range of $H_i$ |
|---|---|---|---|
| $2$ | Small number of people; only two possible hat numbers | $N \leq 4$ | $H_i \leq 1$ |
| $1$ | Only one possible hat number | $N \leq 100$ | $H_i = 1$ |
| $2$ | People in odd-numbered seats have hat number $1$, and those in even-numbered seats have hat number $0$ | $N \leq 100$ | $H_i \leq 1$ |
| $5$ | Medium number of people | $N \leq 2 \times 10^3$ | $H_i \leq 4 \times 10^3$ |
| $5$ | Large number of people and possible hat numbers | $N \leq 10^6$ | $H_i \leq 2 \times 10^6$ |
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分