def print_list(A):
    print(*A, sep=" ")

def swap(a, b):
    return b, a

def find_minj(A, i, n):
    minj = i
    for j in range(i, n):
        if A[j] < A[minj]:
            minj = j
    return minj

def selection_sort(A, n):
    replace_num = 0
    for i in range(0, n):
        minj = find_minj(A, i, n)
        if A[i] > A[minj]:
            A[i], A[minj] = swap(A[i], A[minj])
            replace_num += 1
    print_list(A)
    print(replace_num)

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

selection_sort(A, n) def print_list(A):
    print(*A, sep=" ") print_list print(*A, sep=" ") print *A A sep=" " sep " " A A def swap(a, b):
    return b, a swap return b, a return b, a b a a a b b def find_minj(A, i, n):
    minj = i
    for j in range(i, n):
        if A[j] < A[minj]:
            minj = j
    return minj find_minj 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 return minj minj A A i i n n def selection_sort(A, n):
    replace_num = 0
    for i in range(0, n):
        minj = find_minj(A, i, n)
        if A[i] > A[minj]:
            A[i], A[minj] = swap(A[i], A[minj])
            replace_num += 1
    print_list(A)
    print(replace_num) selection_sort replace_num = 0 replace_num 0 for i in range(0, n):
        minj = find_minj(A, i, n)
        if A[i] > A[minj]:
            A[i], A[minj] = swap(A[i], A[minj])
            replace_num += 1
     i range(0, n) range 0 n minj = find_minj(A, i, n) minj find_minj(A, i, n) find_minj A i n if A[i] > A[minj]:
            A[i], A[minj] = swap(A[i], A[minj])
            replace_num += 1
     A[i] > A[minj] A[i] A i A[minj] A minj A[i], A[minj] = swap(A[i], A[minj]) A[i] A i swap(A[i], A[minj]) swap A[i] A i A[minj] A minj A[minj] A minj replace_num += 1 replace_num 1 print_list(A) print_list A print(replace_num) print replace_num A A n n 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 selection_sort(A, n) selection_sort A n def selection_sort(A, n):
    replace_num = 0
    for i in range(0, n):
        minj = find_minj(A, i, n)
        if A[i] > A[minj]:
            A[i], A[minj] = swap(A[i], A[minj])
            replace_num += 1
    print_list(A)
    print(replace_num) def selection_sort(A, n):
    replace_num = 0
    for i in range(0, n):
        minj = find_minj(A, i, n)
        if A[i] > A[minj]:
            A[i], A[minj] = swap(A[i], A[minj])
            replace_num += 1
    print_list(A)
    print(replace_num) selection_sort def find_minj(A, i, n):
    minj = i
    for j in range(i, n):
        if A[j] < A[minj]:
            minj = j
    return minj def find_minj(A, i, n):
    minj = i
    for j in range(i, n):
        if A[j] < A[minj]:
            minj = j
    return minj find_minj def swap(a, b):
    return b, a def swap(a, b):
    return b, a swap A = list(map(int,input().split())) list(map(int,input().split())) A n = int(input()) int(input()) n def print_list(A):
    print(*A, sep=" ") def print_list(A):
    print(*A, sep=" ") print_list
def print_list(A):
    print(*A, sep=" ")

def swap(a, b):
    return b, a

def find_minj(A, i, n):
    minj = i
    for j in range(i, n):
        if A[j] < A[minj]:
            minj = j
    return minj

def selection_sort(A, n):
    replace_num = 0
    for i in range(0, n):
        minj = find_minj(A, i, n)
        if A[i] > A[minj]:
            A[i], A[minj] = swap(A[i], A[minj])
            replace_num += 1
    print_list(A)
    print(replace_num)

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

selection_sort(A, n)
