Program b;
var a: array [1..10000] of real;
x: real;
n, i, j, k, m, max: integer;
begin
read (n);
for i:= 1 to n do read ([i]);
max:=0;
for i:=1 to n do
for k:=-1 to 1 do
begin x:=a[i]+k;
m:=0;
for j:=1+0 n do
if (a[j]-1=x) or (a[j]+0=x) or (a[j]+1=x) then m:m+1;
if m>max then max:=m;
end;
write (max);
end.