n = int(input())
A = list(map(int,input().split()))
c = 0
for i in range(n):
    minj = i
    for j in range(i,n):
        if A[j] < A[minj]:
            minj = j
            t = A[i]
            A[i] = A[minj]
            A[minj] = t
            c += 1
	
print("".join(map(str,A)))
print(c)