Problem list
Log in
#r03605 · CCC 2024 Senior

Hat Circle

Bronze III 2.0 s 256 MB

At a recent social gathering, $N$ people sit around a circular table, where $N$ is even. The seats are numbered clockwise from $1$ to $N$. Each person is wearing a hat with a number on it. Specifically, the person at seat $i$ is wearing a hat with the number $H_i$ on it.

Each person looks at the person who is directly across (diametrically opposite) them in the circle.

Determine the number of people who see someone with a hat with the same number as their own.

Input

The first line of input will consist of one even positive integer $N$, representing the number of people at the social gathering.

The next $N$ lines each contain a single non-negative integer $H_i$, representing the hat number of person $i$.

Output

Output a single integer representing the number of people who see their hat number on the person directly across from them.

Example 1

Input
4
0
1
0
1
Output
4

The four seats around the table are shown below. Hat numbers are shown inside each seat and seat numbers are shown beside each seat.

Notice that every person sees their hat number. The people in seats $1$ and $3$ both see hat number $0$, and the people in seats $2$ and $4$ both see hat number $1$.

Example 2

Input
4
1
0
0
1
Output
0

The four seats around the table are shown below. Hat numbers are shown inside each seat and seat numbers are shown beside each seat.

Notice that no person sees their hat number. The people in seats $1$ and $4$ both see hat number $0$, and the people in seats $2$ and $3$ both see hat number $1$.

Source
CCC 2024 Senior
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code