let is_prime = Array.make 55556 true
let primes = begin
  is_prime.(0) <- false; is_prime.(1) <- false;
  for i = 2 to 55555 do
    if is_prime.(i) then begin
      for j = i to 55555 / i do
        is_prime.(i*j) <- false;
      done
    end
  done;

  Array.mapi (fun i b -> i, b) is_prime
  |> Array.fold_left (fun stk (i, b) -> if b then i::stk else stk) []
  |> List.rev
end

let rec take n xs = if n <= 0 then [] else
  match xs with [] -> [] | x::xs' -> x :: take (n-1) xs'

let () =
  Scanf.scanf "%d" @@ fun g ->
  List.filter (fun x -> x mod 5 = 1) primes
  |> take g |> List.iter (Printf.printf "%d ");
  print_newline ()

