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 data
The first line contains a single integer n (2 ≤ n ≤ 100), denoting the size of the array. The second line contains n integers describing the respective values of a[0]
, a[1]
, ..., a[n-1]
(0 < a[i]
< 100).
Output data
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.
Examples
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