let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let cs = Array.make 100001 0
let ans = ref 0
let _ = Array.iter (fun a -> cs.(a) <- cs.(a) + 1) a_s;
  for x = 1 to 100000 - 1 do ans := max !ans @@ cs.(x - 1) + cs.(x) + cs.(x + 1) done;
  Printf.printf "%d\n" !ans