import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!T;r.popFront;}}

void main()
{
  int n; readV(n);
  int[] a; readA(n, a);

  auto mi = a.reduce!min, ma = a.reduce!max;
  auto h = new int[](ma-mi+3);
  foreach (ai; a) h[ai-mi+1]++;

  auto r = 0;
  foreach (i; 1..ma-mi+2)
    r = max(r, h[i-1]+h[i]+h[i+1]);

  writeln(r);
}
