let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let ans = Array.make (n + 1) 0 in
  for i = n downto 1 do
    ans.(i) <- Array.fold_left ( lxor ) as_.(i - 1) @@
      Array.init (n / i - 1) @@ fun j -> as_.(i * (j + 2) - 1)
  done;
  Printf.printf "%d\n" n;
  for i = 1 to n do
    Printf.printf "%d " ans.(i)
  done;
  print_newline ()
  
