function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  tmp = input[1].split(" ");
  a = new Array(Math.pow(10,5)-1).fill(0);
  for(i=0;i<n;i++){
    var t = parseInt(tmp[i]);
    a[t-1]++;
    a[t]++;
    a[t+1]++;
  }
  var ans = Math.max.apply(null,a);
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));