void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  
  int n; rd(n);
  auto a=readln.split.to!(int[]);

  auto c=new int[](100009);
  foreach(ref e; a) e+=2;
  foreach(e; a) c[e]+=1;

  int mx=0;
  foreach(i; 2..c.length-2){
    mx=max(mx, c[i-1]+c[i]+c[i+1]);
  }

  writeln(mx);

}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}