import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto n = lread();
    auto a = aryread();
    auto a_so = a.sort();
    // writeln(a_so);
    long[long] ary;
    foreach (i; 0 .. n)
    {
        ary[a_so[i] - 1] = ary.get(a_so[i] - 1, 0) + 1;
        ary[a_so[i]] = ary.get(a_so[i], 0) + 1;
        ary[a_so[i] + 1] = ary.get(a_so[i] + 1, 0) + 1;

    }
    long ans = -1;
    foreach (key, value; ary)
    {
        // writeln(key, ':', value);
        ans = max(ans, value);
    }
    writeln(ans);
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}
