let () = Scanf.scanf "%d" @@ fun s ->
  if s mod 2 = 0 then begin
    Printf.printf "%d\n" (s * (s - 2) / 2);
    for i = 1 to s do
      for j = i + 1 to s do
        if i + j <> s + 1 then
          Printf.printf "%d %d\n" i j
      done
    done
  end else begin
    Printf.printf "%d\n" (s * (s - 1) / 2 - s / 2);
    for i = 1 to s do
      for j = i + 1 to s do
        if i + j <> s then
          Printf.printf "%d %d\n" i j
      done
    done
  end

