import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  readln;
  auto a = readln.chomp.split.map!(to!int);
  auto s = new int[](100003);
  foreach (e; a) {
    s[e]++;
    s[e+3]--;
    //s[e..e+3] +=1;
    //writeln(s[0..10]);
  }
  
  int cnt, prevCnt;
  foreach (i, e; s) {
    cnt += e;
    prevCnt = max(cnt, prevCnt);
  }

  prevCnt.writeln;
}


