atcoder#ARC082A. [ABC072C] Together

[ABC072C] Together

Score : 300300 points

Problem Statement

You are given an integer sequence of length NN, a1,a2,...,aNa_1,a_2,...,a_N.

For each 1iN1 \leq i \leq N, you have three choices: add 11 to aia_i, subtract 11 from aia_i or do nothing.

After these operations, you select an integer XX and count the number of ii such that ai=Xa_i=X.

Maximize this count by making optimal choices.

Constraints

  • 1N1051 \leq N \leq 10^5
  • 0ai<105(1iN)0 \leq a_i<10^5 (1 \leq i \leq N)
  • aia_i is an integer.

Input

The input is given from Standard Input in the following format:

NN

a1a_1 a2a_2 .. aNa_N

Output

Print the maximum possible number of ii such that ai=Xa_i=X.

7
3 1 4 1 5 9 2
4

For example, turn the sequence into 2,2,3,2,6,9,22,2,3,2,6,9,2 and select X=2X=2 to obtain 44, the maximum possible count.

10
0 1 2 3 4 5 6 7 8 9
3
1
99999
1