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 = {
    x./:(0)((acc,e) => {
      val cnt = map.getOrElse(e-1,0) + map.getOrElse(e,0) + map.getOrElse(e+1,0)
      math.max(acc, cnt)
    })
  }

  println(ans)
}