(* O(n) *)
let kMax = 100000 + 10
let n = Scanf.scanf " %d" @@ (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let ns = Array.make (kMax + 1) 0
let f a =
  for i = 0 to 2 do ns.(a + i) <- ns.(a + i) + 1 done
let _ =
  Array.iter f a_s;
  Array.fold_left max 0 ns |> Printf.printf "%d\n"