n = input()
A = map(int, raw_input().split())
count = 0
for i in xrange(n):
    mini = min(A[i:])
    if i < A.index(mini)-1:
        A.insert(A.index(mini),A.pop(i))
        A.pop(A.index(mini))
        A.insert(i,mini)
        count += 1
print ' '.join(map(str, A))
print count