object Main extends App {
	val N = scala.io.StdIn.readInt
	val A = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	val a = A.min
	val b = A.max

	var result = 0
	var temp = 0

	for(i<-a to b){
		temp = 0
		val x = i-1
		val y = i
		val z = i+1

//		println("(x,y,z)=("+x+","+y+","+z+")")
		for(j<-0 until N){
//			println(A(j))
			if(A(j)==x || A(j)==y || A(j)==z) temp = temp + 1; 
		}
		if(result < temp) result = temp
	}

	println(result)
}
