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

object Main extends App {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val set = mutable.HashSet[Int]()
  val n = in.readLine.toInt
  val a = in.readLine.split(" ").map(_.toInt)

  a.foreach(e => {
    // set += e -1
    set += e
    // set += e +1
  })

  val x = set.toArray

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

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

  println(ans)
}