n = io.read("*n")
t = {}
for i = 1, n do
  a = io.read("*n")
  for j = -1, 1 do
    if not t[a + j] then t[a + j] = 1
    else t[a + j] = t[a + j] + 1
    end
  end
end
c = 0
for k, v in pairs(t) do
  if c < v then c = v end
end
print(c)
