"use strict"
function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0].trim());
  const A = input[1].trim().split(' ').map(Number);

  if(N === 1) {
    console.log('1');
    return;
  }

  const max = 1e5;
  let ret = 0;
  for(let i=1; i<=max; i++){
    let tmp = 0;
    for(let j=0; j<N; j++){
      if((i-1) === A[j]) tmp += 1;
      if(i === A[j]) tmp += 1;
      if((i+1) === A[j]) tmp += 1;
    }
    if(ret < tmp) ret = tmp;
  }
  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));