n = int(eval(input()))

li = list(map(int, input().split()))

cnt = 0



for i in range(n):

	minj = i

	for j in range(i, n):

		if li[j] < li[minj]:

			minj = j

	if li[i] != li[minj]:

		li[i], li[minj] = li[minj], li[i]

		cnt += 1



print((*li))

print(cnt)
N = int(eval(input()))

A = list(map(int, input().split()))



def selectionSort(A,N):

    cnt = 0

    

    for i in range(N-1):

        minj = i

        for j in range(i, N):

            if A[j] < A[minj]:

                minj = j

        if i != minj:

            cnt += 1

        A[i], A[minj] = A[minj], A[i]

    print((*A))

    print(cnt)

    

selectionSort(A, N)
n = int(eval(input()))
li = list(map(int, input().split()))
cnt = 0
for i in range(n):
    minj = i
    for j in range(i, n):
        if li[j] < li[minj]:
            minj = j
    if li[i] != li[minj]:
        li[i], li[minj] = li[minj], li[i]
        cnt += 1
print((*li))
print(cnt)

N = int(eval(input()))
A = list(map(int, input().split()))


def selectionSort(A, N):
    cnt = 0
    for i in range(N - 1):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if i != minj:
            cnt += 1
        A[i], A[minj] = A[minj], A[i]
    print((*A))
    print(cnt)


selectionSort(A, N)

-n = int(eval(input())) -li = list(map(int, input().split())) -cnt = 0 -for i in range(n): -    minj = i -    for j in range(i, n): -        if li[j] < li[minj]: -            minj = j -    if li[i] != li[minj]: -        li[i], li[minj] = li[minj], li[i] -        cnt += 1 -print((*li)) -print(cnt) +N = int(eval(input())) +A = list(map(int, input().split())) + + +def selectionSort(A, N): +    cnt = 0 +    for i in range(N - 1): +        minj = i +        for j in range(i, N): +            if A[j] < A[minj]: +                minj = j +        if i != minj: +            cnt += 1 +        A[i], A[minj] = A[minj], A[i] +    print((*A)) +    print(cnt) + + +selectionSort(A, N)