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