import io.StdIn._
object Main extends App {
    val n = readInt
    val as = readLine.split(" ").map(_.toInt)
    
    val sorted = as.sorted

    def rec(index: Int, acc: List[Int]): List[Int] = {
        if(n-1 < index) {
            return acc
        } else {
            val target = sorted(index)
            val count_target = sorted.count(_ == target)
            if(index == 0) {
                val next = if(index+count_target+1 <= n) sorted(index+count_target) else 0
                val count_next = sorted.count(_ == next)
                rec(index+count_target, acc:+(count_target+count_next))
            } else if(index == n-1) {
                val prev = sorted(index-1)
                val count_prev = sorted.count(_ == prev)
                rec(index+count_target, acc:+(count_target+count_prev))
            } else {
                val next = sorted(index+count_target)
                val count_next = sorted.count(_ == next)
                val prev = sorted(index-1)
                val count_prev = sorted.count(_ == prev)
                rec(index+count_target, acc:+(count_target+count_prev+count_next))
            }
        }
    }

    val counts = rec(0, Nil)

    println(counts.max)

}