program preparing_boxes
    implicit none
    integer(4):: n, i, j
    integer(4), allocatable:: a(:), b(:)
    

    read*, n
    allocate(a(n), b(n))
    read*, a(:)
    b(:)=0
    do i=n, 1,-1
        if (a(i) > 1 .or. a(i) < 0)then
            print*, -1
            stop
        else if (a(i) == 1) then
            b(i) = 1
            do j=2,nint(sqrt(dble(i)))
                if (mod(i,j) == 0) a(i/j)=a(i/j)-1
            end do
        end if
        ! print*, 'b',b(:)
    end do

    print'(i0)', sum(b(:))
    do i=1,n
        if (b(i)==1) write(*,'(i01x)',advance='no') i 
    end do
    write(*,*)
end program preparing_boxes