import scala.collection.mutable
import java.io.{BufferedReader, InputStreamReader}

object Main extends App {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val map = mutable.HashMap[Int,Int]()

  val n = in.readLine.toInt
  in.readLine.split(" ").map(_.toInt)
    .foreach(e => {
      if(!map.contains(e)) map += e -> 1
      else map(e) +=1
    })

  val x = map.keySet

  val ans = {
    var max = -1
    for {
      i <- x
    } {
      var cnt = 0
      map.foreach(e => {
        if(i-1 <= e._1 && e._1 <= i+1) cnt += e._2
      })

      if(cnt > max) max = cnt
    }
    max
  }

  println(ans)
}