#C5178. Maximum Teams from Consecutive Ranks

    ID: 48798 Type: Default 1000ms 256MiB

Maximum Teams from Consecutive Ranks

Maximum Teams from Consecutive Ranks

You are given an array of integers representing the ranks of players. A team is defined as a group of players whose ranks form a contiguous sequence of integers. In other words, if after sorting and removing duplicates the list becomes \(R = [r_1, r_2, \dots, r_k]\), then each maximal subsequence of consecutive integers forms a team.

Your task is to calculate the maximum number of teams that can be formed from the given ranks.

Hint: Two ranks \(a\) and \(b\) are consecutive if \(b = a+1\). Use sorting and duplicate removal to group consecutive elements together.

inputFormat

The input is read from stdin. The first line contains an integer \(n\), which is the number of players. The second line contains \(n\) space-separated integers representing the ranks of the players.

outputFormat

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

## sample
7
1 2 3 4 5 6 7
1

</p>