let N = readLine()
let a = readLine()!.characters.split(" ").map{Int(String($0))!}
var dic = [Int : Int]()
for i in (a + a.map{$0+1} + a.map{$0-1}) {
    if dic[i] == nil {
        dic[i] = 0
    }
    dic[i]! += 1
}
print(dic.values.maxElement()!)