#K7411. Team Formation from Consecutive Skill Levels

    ID: 34125 Type: Default 1000ms 256MiB

Team Formation from Consecutive Skill Levels

Team Formation from Consecutive Skill Levels

You are given n participants with distinct skill levels. Your task is to form as many teams as possible, where each team consists of exactly three participants whose skill levels form three consecutive integers. In other words, if a team is formed with skill levels a, a+1, and a+2, then it is considered a valid team.

Each participant can only be assigned to a single team. The goal is to count the maximum number of teams you can form. The solution should determine this number by sorting the skill levels and scanning through them to form valid consecutive triples. Use stdin for input and stdout for output.

The consecutive condition can be mathematically expressed in LaTeX as follows:

\(a,\; a+1, \; a+2\)

inputFormat

The input is read from stdin and consists of two lines:

  1. The first line contains a positive integer n, representing the number of participants.
  2. The second line contains n space-separated integers, representing the distinct skill levels of the participants.

outputFormat

Output a single integer to stdout, which is the maximum number of teams that can be formed following the rules.

## sample
6
1 3 2 5 6 4
2