class Array
	def selection_sort!
		(0..size-1).each{|i|
			minj = i
			(i..size-1).each{|j|
				if self[j] < self[minj]
					minj = j
				end
			}
			if i != minj
				self[i], self[minj] = self[minj], self[i]
				yield if block_given?
			end
		}
		self
	end
end

gets
a = gets.split.map(&:to_i)
cnt = 0
puts a.selection_sort!{cnt+=1}*" "
puts cnt