var fs = require("fs");
Main(fs.readFileSync("/dev/stdin","utf-8"));

function Main(input){
  input = input.split("\n");
  N = parseInt(input[0],10);
  input=input[1].split(" ");
  input=input.map(function(value){
    return parseInt(value,10);
  });
  var max = Math.max.apply({},input);
  var ans=0;
  for(var i=1;i<=max;i++){
    var tmp =count(input,i-1)+count(input,i)+count(input,i+1);
    if(ans<tmp) ans=tmp;
  }
  console.log(ans);
}
function count(input,num){
  var count_num=0;
  for(var j=0;j<input.length;j++){
    if(input[j]==num) count_num++;
  }
  return count_num;
}