'use strict'

function main(s) {

  const nums = s.split('\n')[1].split(' ').map(n => Number(n));
  const bucket = [...Array(100000)].fill(0);

  for (const n of nums) {
    bucket[n] += 1;
    if (n > 0) bucket[n - 1] += 1;
    if (n < 99999) bucket[n + 1] += 1;
  }

  const answer = Math.max(...bucket);
  console.log(answer);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
