#K2696. Maximum Valid Pairs

    ID: 24794 Type: Default 1000ms 256MiB

Maximum Valid Pairs

Maximum Valid Pairs

You are given a list of ages of employees. Your task is to determine the maximum number of valid pairs that can be formed such that the difference in ages between the two employees in a pair is exactly \(1\) year. Each employee can be part of at most one pair.

For example, if the ages are [21, 22, 23, 24, 25], the maximum number of valid pairs is 2.

inputFormat

The input is given via standard input (stdin) and consists of two lines:

  • The first line contains an integer \(n\) representing the number of employees.
  • The second line contains \(n\) space-separated integers representing the ages of the employees.

outputFormat

Output a single integer which is the maximum number of valid pairs that can be formed where the age difference between the two employees is exactly \(1\) year. The output should be written to standard output (stdout).

## sample
5
21 22 23 24 25
2