local ior = io.input()
local t = {}
for i = 1, 100000 do t[i] = 0 end
local n = ior:read("*n")
for i = 1, n do
  local a = ior:read("*n")
  if 1 < a then t[a - 1] = t[a - 1] + 1 end
  if 0 < a then t[a] = t[a] + 1 end
  t[a + 1] = t[a + 1] + 1
end
local ret = 0
for i = 1, 100000 do
  ret = math.max(ret, t[i])
end
print(ret)
