n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)
count = 0

for i in 0..n-1
    min = i
    for j in i..n-1
        if arr[j] == arr[i+1..n-1].min && arr[j] < arr[min]
            min = j
            arr[i],arr[min] = arr[min],arr[i]
            count += 1
        end
        min = i
    end
end

puts arr.join(" ")
puts count