"use strict";
    
const main = arg => {
  let NumAmount = arg.split("\n")[0]*1;
  let Nums = arg.split("\n")[1].split(" ").map(n => n*1);  
  let ans = 0;
  let PlusNums = Nums.map(x=> x + 1);
  let MinusNums = Nums.map(x=> x - 1);
  let AllArr = Nums.concat(...PlusNums,...MinusNums);
  //console.log(AllArr);
  let AllArrObj = {};
  let AllArrValues = [];
  for(let i = 0; i < AllArr.length; i++){
  if( isNaN(AllArrObj[AllArr[i]]) ){
	AllArrObj[AllArr[i]] = 0;
  }
  AllArrObj[AllArr[i]] += 1;
  }
  //console.log(AllArrObj);
  // valueのみ抽出して最大値を求める
  Object.keys(AllArrObj).forEach( function(value) {
      AllArrValues.push(this[value]);
  }, AllArrObj)
  console.log(Math.max(...AllArrValues)); 
}

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