let () =
    let split s =
        let rec loop i cur flag acc =
            if i = String.length s then (
                if flag then cur :: acc else acc
            ) else (
                match flag, s.[i] with
                | true,  ' ' -> loop (i + 1) 0 false (cur :: acc)
                | false, ' ' -> loop (i + 1) 0 false acc
                | true,  v   -> loop (i + 1) (cur * 10 + int_of_char v - 48) true acc
                | false, v   -> loop (i + 1) (cur * 10 + int_of_char v - 48) true acc
            )
        in
        List.rev (loop 0 0 false [])
    in
    let main () =
        let n = int_of_string (read_line ()) in
        let a = Array.of_list (split (read_line ())) in
        let buf = Array.make n 0 in
        let ans = Array.make n 0 in
        for i = n downto 1 do
            let f = buf.(i - 1) lxor a.(i - 1) in
            let () = ans.(i - 1) <- f in
            let rec loop j =
                if i >= j * j then (
                    if i mod j = 0 then (
                     (*   if f <> 0 then Printf.printf "buf %d %d to %d\n" j buf.(j - 1) (buf.(j - 1) lxor f); *)
                        buf.(j - 1) <- buf.(j - 1) lxor f;
                        let l = i / j in
                        if l <> j then (
                     (*   if f <> 0 then Printf.printf "buf %d %d to %d\n" l buf.(l - 1) (buf.(l - 1) lxor f); *)
                        buf.(l - 1) <- buf.(l - 1) lxor f;
                        )
                    );
                    loop (j + 1)
                )
            in
            loop 1
        done;
        Printf.printf "%d\n" (Array.fold_left (+) 0 ans);
        for i = 1 to n do
            if ans.(i - 1) > 0 then Printf.printf "%d  " i
        done;
        print_newline ()
    in
    main ()