#P10295. Opposite Hat Matching

    ID: 12296 Type: Default 1000ms 256MiB

Opposite Hat Matching

Opposite Hat Matching

Given an even integer NN representing the number of people sitting around a circular table, each wearing a hat with a number HiH_i. The seats are numbered in clockwise order from 11 to NN. Each person looks directly across the table at the person opposite them. Your task is to determine how many people see that the number on the hat of the person they are facing is the same as the number on their own hat.

Note: If two people facing each other have the same number, both are counted.

inputFormat

The input consists of two lines:
1. The first line contains an even integer NN, the number of people.
2. The second line contains NN space-separated integers H1,H2,,HNH_1, H_2, \dots, H_N, where HiH_i is the number on the hat of the person sitting at seat ii.

outputFormat

Output a single integer representing the number of people who see the same hat number as their own.

sample

4
1 2 1 2
4