def selectionSort(A,N):
    n_swap = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            A[i], A[minj] = A[minj], A[i]
            n_swap += 1
    return n_swap, A

def run():
    n = int(input())
    a = list(map(int, input().split()))
    c, a = selectionSort(a,n)
    print(' '.join([str(i) for i in a]))
    print(c)

if __name__ == '__main__':
    run() def selectionSort(A,N):
    n_swap = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            A[i], A[minj] = A[minj], A[i]
            n_swap += 1
    return n_swap, A selectionSort n_swap = 0 n_swap 0 for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            A[i], A[minj] = A[minj], A[i]
            n_swap += 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:
            A[i], A[minj] = A[minj], A[i]
            n_swap += 1
     minj != i minj i A[i], A[minj] = A[minj], A[i] A[i] A i A[minj] A minj A[minj] A minj A[i] A i n_swap += 1 n_swap 1 return n_swap, A return n_swap, A n_swap A A A N N def run():
    n = int(input())
    a = list(map(int, input().split()))
    c, a = selectionSort(a,n)
    print(' '.join([str(i) for i in a]))
    print(c) run n = int(input()) n int(input()) int input() input a = list(map(int, input().split())) a list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split c, a = selectionSort(a,n) c selectionSort(a,n) selectionSort a n a str(i) for i in a for i in a i a for i in a str(i) str i print(' '.join([str(i) for i in a])) print ' '.join([str(i) for i in a]) ' '.join ' ' join [str(i) for i in a] print(c) print c if __name__ == '__main__':
    run() __name__ == '__main__' __name__ '__main__' run() run def selectionSort(A,N):
    n_swap = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            A[i], A[minj] = A[minj], A[i]
            n_swap += 1
    return n_swap, A def selectionSort(A,N):
    n_swap = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            A[i], A[minj] = A[minj], A[i]
            n_swap += 1
    return n_swap, A selectionSort def run():
    n = int(input())
    a = list(map(int, input().split()))
    c, a = selectionSort(a,n)
    print(' '.join([str(i) for i in a]))
    print(c) def run():
    n = int(input())
    a = list(map(int, input().split()))
    c, a = selectionSort(a,n)
    print(' '.join([str(i) for i in a]))
    print(c) run
def selectionSort(A,N):
    n_swap = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            A[i], A[minj] = A[minj], A[i]
            n_swap += 1
    return n_swap, A

def run():
    n = int(input())
    a = list(map(int, input().split()))
    c, a = selectionSort(a,n)
    print(' '.join([str(i) for i in a]))
    print(c)

if __name__ == '__main__':
    run()
