def selection_sort(A):
    count = 0
    for i in range(len(A)):
        mini = i
        for j in range(i, len(A)):
            if A[j] < A[mini]:
                mini = j
        count += swap(A, mini, i)
    print_array(A)
    return count


def swap(A, i, j):
    if i != j:
        tmp = A[j]
        A[j] = A[i]
        A[i] = tmp
        return 1
    else:
        return 0


def print_array(array):
    print(" ".join([str(x) for x in array]))


amount = int(input())
numbers = [0 for i in range(amount)]
numbers = list(map(int, input().split()))
count = selection_sort(numbers)
print(count) def selection_sort(A):
    count = 0
    for i in range(len(A)):
        mini = i
        for j in range(i, len(A)):
            if A[j] < A[mini]:
                mini = j
        count += swap(A, mini, i)
    print_array(A)
    return count selection_sort count = 0 count 0 for i in range(len(A)):
        mini = i
        for j in range(i, len(A)):
            if A[j] < A[mini]:
                mini = j
        count += swap(A, mini, i)
     i range(len(A)) range len(A) len A mini = i mini i for j in range(i, len(A)):
            if A[j] < A[mini]:
                mini = j
         j range(i, len(A)) range i len(A) len A if A[j] < A[mini]:
                mini = j
         A[j] < A[mini] A[j] A j A[mini] A mini mini = j mini j count += swap(A, mini, i) count swap(A, mini, i) swap A mini i print_array(A) print_array A return count count A A def swap(A, i, j):
    if i != j:
        tmp = A[j]
        A[j] = A[i]
        A[i] = tmp
        return 1
    else:
        return 0 swap if i != j:
        tmp = A[j]
        A[j] = A[i]
        A[i] = tmp
        return 1
    else:
        return 0 i != j i j tmp = A[j] tmp A[j] A j A[j] = A[i] A[j] A j A[i] A i A[i] = tmp A[i] A i tmp return 1 1 return 0 0 A A i i j j def print_array(array):
    print(" ".join([str(x) for x in array])) print_array str(x) for x in array for x in array x array for x in array str(x) str x print(" ".join([str(x) for x in array])) print " ".join([str(x) for x in array]) " ".join " " join [str(x) for x in array] array array amount = int(input()) amount int(input()) int input() input 0 for i in range(amount) for i in range(amount) i range(amount) range amount for i in range(amount) 0 numbers = [0 for i in range(amount)] numbers [0 for i in range(amount)] numbers = list(map(int, input().split())) numbers list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split count = selection_sort(numbers) count selection_sort(numbers) selection_sort numbers print(count) print count amount = int(input()) int(input()) amount numbers = list(map(int, input().split())) list(map(int, input().split())) numbers count = selection_sort(numbers) selection_sort(numbers) count def selection_sort(A):
    count = 0
    for i in range(len(A)):
        mini = i
        for j in range(i, len(A)):
            if A[j] < A[mini]:
                mini = j
        count += swap(A, mini, i)
    print_array(A)
    return count def selection_sort(A):
    count = 0
    for i in range(len(A)):
        mini = i
        for j in range(i, len(A)):
            if A[j] < A[mini]:
                mini = j
        count += swap(A, mini, i)
    print_array(A)
    return count selection_sort def swap(A, i, j):
    if i != j:
        tmp = A[j]
        A[j] = A[i]
        A[i] = tmp
        return 1
    else:
        return 0 def swap(A, i, j):
    if i != j:
        tmp = A[j]
        A[j] = A[i]
        A[i] = tmp
        return 1
    else:
        return 0 swap numbers = [0 for i in range(amount)] [0 for i in range(amount)] numbers def print_array(array):
    print(" ".join([str(x) for x in array])) def print_array(array):
    print(" ".join([str(x) for x in array])) print_array
def selection_sort(A):
    count = 0
    for i in range(len(A)):
        mini = i
        for j in range(i, len(A)):
            if A[j] < A[mini]:
                mini = j
        count += swap(A, mini, i)
    print_array(A)
    return count


def swap(A, i, j):
    if i != j:
        tmp = A[j]
        A[j] = A[i]
        A[i] = tmp
        return 1
    else:
        return 0


def print_array(array):
    print(" ".join([str(x) for x in array]))


amount = int(input())
numbers = [0 for i in range(amount)]
numbers = list(map(int, input().split()))
count = selection_sort(numbers)
print(count)