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
    } {
      val res = a.map(e => {
        if(e == i) e else if (e > i) e - 1 else e + 1
      }).count(_ == i)
      if(res > max) max = res
    }
    max
  }

  println(ans)
}