let rec seq a b = if a > b then [] else a :: seq (a+1) b
let rec take n = function
  | [] -> []
  | (x::xs) -> if n <= 0 then [] else (x :: take (n-1) xs)
let is_prime n = 
  let rec f d =
    if d * d > n then true
    else if n mod d = 0 then false
    else f (d+1) in
  n >= 2 && f 2
let () =
  let n = Scanf.scanf "%d" (fun x -> x) in
  seq 1 55555 |> List.filter (fun x -> is_prime x && x mod 5 = 1) |> take n
  |> List.iteri (fun i x -> (if i > 0 then print_string " "); print_int x);
  print_newline ()
