def serect_sort(r, n):

    cnt = 0

    for i in range(0, n):

        minj = i

        for j in range(i, n):

            if r[j] < r[minj]:

                minj = j

        r[i],r[minj] = r[minj],r[i]

        if i != minj:

            cnt +=1

    print((*r))

    print(cnt)



N = int(eval(input()))

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

serect_sort(A, N)
def selectionSort(n, A):

    cnt =0

    for i in range(n):

        minj = i

        for j in range(i,n):

            if A[minj] > A[j]:

                minj = j

        if i != minj:

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

            cnt += 1

    print((*A))

    print(cnt)



if __name__ == '__main__':

    n = int(eval(input()))

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

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


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

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


if __name__ == "__main__":
    n = int(eval(input()))
    A = list(map(int, input().split()))
    selectionSort(n, A)

-def serect_sort(r, n): +def selectionSort(n, A): -    for i in range(0, n): +    for i in range(n): -            if r[j] < r[minj]: +            if A[minj] > A[j]: -        r[i], r[minj] = r[minj], r[i] +            A[i], A[minj] = A[minj], A[i] -    print((*r)) +    print((*A)) -N = int(eval(input())) -A = list(map(int, input().split())) -serect_sort(A, N) +if __name__ == "__main__": +    n = int(eval(input())) +    A = list(map(int, input().split())) +    selectionSort(n, A)