import std.stdio, std.string, std.conv, std.bigint, std.typecons, std.algorithm, std.array, std.math, std.range, std.functional;
 
void main() {
    auto N = readln.chomp.to!long;
    auto as = sort(readln.split.to!(long[]));
    sort(as.map!(a => [a-1, a, a+1]).join).uniq
    .map!(a => as.upperBound(a-2).lowerBound(a+2).count).reduce!max.writeln;
}
