Scanf.scanf "%d" (fun n ->
    let i = int_of_float @@ ceil (sqrt (2. *. float n) -. 0.5) in

    let s =
        if i * (i + 1) >= 2*n && i * (i - 1) < 2 * n then i else
        if i * (i - 1) >= 2*n                        then i - 1 else i + 1
    in

    let rec loop rest cur =
        if rest = 0 then () else
            if rest >= cur then (Printf.printf "%d\n" cur; loop (rest - cur) (cur - 1))
                           else loop rest (cur - 1)
    in
    loop n s
)