Scanf.scanf "%d" (fun n ->
    let arr = Array.init 55556 (fun i -> if i < 2 then 0 else i) in
    let rec loop_i i =
        let rec loop_j j =
            if j <= 55555 then (arr.(j) <- 0; loop_j (j + i)) else loop_i (i + 1)
        in
        if i * i <= 55555 then loop_j (i * i)
    in
    loop_i 2;
    let q = Array.fold_right (fun v acc -> if v = 0 then acc else v :: acc) arr [] in
    let q = Array.of_list q in
    let rec loop rest i =
        if rest > 0 then (
            if q.(i) mod 5 = 1 then (
                Printf.printf "%d " q.(i);
                loop (rest - 1) (i + 1)
            ) else loop rest (i + 1)
        )
    in
    loop n 0;
    print_newline ()
)