object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val as = List.fill(n)(sc.nextInt()+1)
  val b = Array.fill(100002)(0)
  for (a <- as) {
    b(a-1) += 1
    b(a) += 1
    b(a+1) += 1
  }
  println(b.max)
}
