eolymp
bolt
Try our new interface for solving problems
Problems

Picking Numbers

Picking Numbers

Given an array of integers, find and print the maximum number of integers you can select from the array such that the absolute difference between any two of the chosen integers is less or equal to 1.

Input

The first line contains a single integer n (2n100), denoting the size of the array. The second line contains n integers describing the respective values of a0, a1, ..., an-1 (0 < ai < 100).

Output

Print a single integer denoting the maximum number of integers you can choose from the array such that the absolute difference between any two of the chosen integers is ≤ 1. The answer is ≥ 2.

Time limit 1 second
Memory limit 122.17 MiB
Input example #1
6
4 6 5 3 3 1
Output example #1
3
Input example #2
6
1 2 2 3 1 2
Output example #2
5