import std.algorithm, std.conv, std.range, std.stdio, std.string;

const ma = 10 ^^ 5;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto a = readln.split.to!(int[]);
  auto b = new int[](ma);

  foreach (ai; a) {
    if (ai > 0) ++b[ai-1];
    ++b[ai];
    if (ai < ma-1) ++b[ai+1];
  }

  writeln(b.reduce!max);
}
