def showList(A, N):
    for i in range(N-1):
        print(A[i],end=' ')
    print(A[N-1])

def selectionSort(A, N):
    """
    選択ソート
    O(n^2)のアルゴリズム
    """
    count = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            t = A[minj]
            A[minj] = A[i]
            A[i] = t
            count += 1
    showList(A, N)
    print(count)
    

N = int(input())
A = [int(x) for x in input().split(' ')]
selectionSort(A, N) def showList(A, N):
    for i in range(N-1):
        print(A[i],end=' ')
    print(A[N-1]) showList for i in range(N-1):
        print(A[i],end=' ')
     i range(N-1) range N-1 N 1 print(A[i],end=' ') print A[i] A i end=' ' end ' ' print(A[N-1]) print A[N-1] A N-1 N 1 A A N N def selectionSort(A, N):
    """
    選択ソート
    O(n^2)のアルゴリズム
    """
    count = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            t = A[minj]
            A[minj] = A[i]
            A[i] = t
            count += 1
    showList(A, N)
    print(count)
     selectionSort """
    選択ソート
    O(n^2)のアルゴリズム
    """ count = 0 count 0 for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            t = A[minj]
            A[minj] = A[i]
            A[i] = t
            count += 1
     i range(N) range N minj = i minj i for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
         j range(i,N) range i N if A[j] < A[minj]:
                minj = j
         A[j] < A[minj] A[j] A j A[minj] A minj minj = j minj j if minj != i:
            t = A[minj]
            A[minj] = A[i]
            A[i] = t
            count += 1
     minj != i minj i t = A[minj] t A[minj] A minj A[minj] = A[i] A[minj] A minj A[i] A i A[i] = t A[i] A i t count += 1 count 1 showList(A, N) showList A N print(count) print count A A N N N = int(input()) N int(input()) int input() input int(x) for x in input().split(' ') for x in input().split(' ') x input().split(' ') ().split () input split ' ' for x in input().split(' ') int(x) int x A = [int(x) for x in input().split(' ')] A [int(x) for x in input().split(' ')] selectionSort(A, N) selectionSort A N N = int(input()) int(input()) N def showList(A, N):
    for i in range(N-1):
        print(A[i],end=' ')
    print(A[N-1]) def showList(A, N):
    for i in range(N-1):
        print(A[i],end=' ')
    print(A[N-1]) showList A = [int(x) for x in input().split(' ')] [int(x) for x in input().split(' ')] A def selectionSort(A, N):
    """
    選択ソート
    O(n^2)のアルゴリズム
    """
    count = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            t = A[minj]
            A[minj] = A[i]
            A[i] = t
            count += 1
    showList(A, N)
    print(count)
     def selectionSort(A, N):
    """
    選択ソート
    O(n^2)のアルゴリズム
    """
    count = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            t = A[minj]
            A[minj] = A[i]
            A[i] = t
            count += 1
    showList(A, N)
    print(count)
     selectionSort
def showList(A, N):
    for i in range(N-1):
        print(A[i],end=' ')
    print(A[N-1])

def selectionSort(A, N):
    """
    選択ソート
    O(n^2)のアルゴリズム
    """
    count = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            t = A[minj]
            A[minj] = A[i]
            A[i] = t
            count += 1
    showList(A, N)
    print(count)
    

N = int(input())
A = [int(x) for x in input().split(' ')]
selectionSort(A, N)
