n=io.read("*n")
a={}
for i=1,n do
    x=io.read("*n")
    if not a[x] then
        a[x]=1
    else
        a[x]=a[x]+1
    end
end

max=0
for integer,_ in pairs(a) do
    counter=a[integer]
    if a[integer-1] then
        counter=counter+a[integer-1]
    end
    if a[integer+1] then
        counter=counter+a[integer+1]
    end
    max=math.max(counter,max)
end
print(max)