Scanf.scanf "%d" (fun n ->
    let rec gcd a b = if b = 0 then a else gcd b (a mod b) in
    let lcm a b = a / gcd a b * b in

    let smooth k l =
        let rec loop r mask = function
            | [] -> if r = 1 then mask else 0
            | (hd :: tl) as l ->
                    if r mod hd = 0 then loop (r / hd) (mask lor (1 lsl hd)) l
                                    else loop r mask tl
        in
        loop k 0 l
    in

    let m2prod mask =
        let rec loop r i c =
            if r = 0 then c else
                if r land 1 = 0 then loop (r lsr 1) (i + 1) c
                                else loop (r lsr 1) (i + 1) (c * i)
        in
        loop mask 0 1
    in

    let rec loop i acc sum mask =
        let c =  smooth i [ 2; 3; 5; 7; 11; 13; 17; 19; 23 ] in
        if c > 0 then (
            Printf.printf "%d " i;
            let acc = acc + 1 in
            let sum = sum + i in
            let mask = mask lor c in
            if acc = n - 1 then Printf.printf "%d\n" (lcm sum (m2prod mask) - sum) else loop (i +1) acc sum mask
        ) else loop (i + 1) acc sum mask
    in
    loop 2 0 0 0
)