def selection_sort(A):
    n = len(A)
    num_swaps = 0
    for i in range(n):
        min_idx = i
        for j in range(i, n):
            if A[j] < A[min_idx]:
                min_idx = j
        if min_idx != i:
            A[i], A[min_idx] = A[min_idx], A[i]
            num_swaps += 1
    return num_swaps


N = int(input())
A = [int(elem) for elem in input().split()]
num_swaps = selection_sort(A)
print(*A)
print(num_swaps)
 def selection_sort(A):
    n = len(A)
    num_swaps = 0
    for i in range(n):
        min_idx = i
        for j in range(i, n):
            if A[j] < A[min_idx]:
                min_idx = j
        if min_idx != i:
            A[i], A[min_idx] = A[min_idx], A[i]
            num_swaps += 1
    return num_swaps selection_sort n = len(A) n len(A) len A num_swaps = 0 num_swaps 0 for i in range(n):
        min_idx = i
        for j in range(i, n):
            if A[j] < A[min_idx]:
                min_idx = j
        if min_idx != i:
            A[i], A[min_idx] = A[min_idx], A[i]
            num_swaps += 1
     i range(n) range n min_idx = i min_idx i for j in range(i, n):
            if A[j] < A[min_idx]:
                min_idx = j
         j range(i, n) range i n if A[j] < A[min_idx]:
                min_idx = j
         A[j] < A[min_idx] A[j] A j A[min_idx] A min_idx min_idx = j min_idx j if min_idx != i:
            A[i], A[min_idx] = A[min_idx], A[i]
            num_swaps += 1
     min_idx != i min_idx i A[i], A[min_idx] = A[min_idx], A[i] A[i] A i A[min_idx] A min_idx A[min_idx] A min_idx A[i] A i num_swaps += 1 num_swaps 1 return num_swaps num_swaps A A N = int(input()) N int(input()) int input() input int(elem) for elem in input().split() for elem in input().split() elem input().split() ().split () input split for elem in input().split() int(elem) int elem A = [int(elem) for elem in input().split()] A [int(elem) for elem in input().split()] num_swaps = selection_sort(A) num_swaps selection_sort(A) selection_sort A print(*A) print *A A print(num_swaps) print num_swaps num_swaps = selection_sort(A) selection_sort(A) num_swaps N = int(input()) int(input()) N def selection_sort(A):
    n = len(A)
    num_swaps = 0
    for i in range(n):
        min_idx = i
        for j in range(i, n):
            if A[j] < A[min_idx]:
                min_idx = j
        if min_idx != i:
            A[i], A[min_idx] = A[min_idx], A[i]
            num_swaps += 1
    return num_swaps def selection_sort(A):
    n = len(A)
    num_swaps = 0
    for i in range(n):
        min_idx = i
        for j in range(i, n):
            if A[j] < A[min_idx]:
                min_idx = j
        if min_idx != i:
            A[i], A[min_idx] = A[min_idx], A[i]
            num_swaps += 1
    return num_swaps selection_sort A = [int(elem) for elem in input().split()] [int(elem) for elem in input().split()] A
def selection_sort(A):
    n = len(A)
    num_swaps = 0
    for i in range(n):
        min_idx = i
        for j in range(i, n):
            if A[j] < A[min_idx]:
                min_idx = j
        if min_idx != i:
            A[i], A[min_idx] = A[min_idx], A[i]
            num_swaps += 1
    return num_swaps


N = int(input())
A = [int(elem) for elem in input().split()]
num_swaps = selection_sort(A)
print(*A)
print(num_swaps)

