# coding=utf-8

def print_list(X):
    first_flag = True
    for val in X:
        if first_flag:
            print_line = str(val)
            first_flag = False
        else:
            print_line = print_line + ' ' + str(val)
    print(print_line)

def selection_sort(A, N):
    counter = 0

    for i in range(N):
        min_j = i

        for j in range(i, N):
            if A[j] < A[min_j]:
                min_j = j

        if i != min_j:
            A[i], A[min_j] = A[min_j], A[i]
            counter += 1

    print_list(A)
    print(counter)

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

selection_sort(A, N) def print_list(X):
    first_flag = True
    for val in X:
        if first_flag:
            print_line = str(val)
            first_flag = False
        else:
            print_line = print_line + ' ' + str(val)
    print(print_line) print_list first_flag = True first_flag True for val in X:
        if first_flag:
            print_line = str(val)
            first_flag = False
        else:
            print_line = print_line + ' ' + str(val)
     val X if first_flag:
            print_line = str(val)
            first_flag = False
        else:
            print_line = print_line + ' ' + str(val)
     first_flag print_line = str(val) print_line str(val) str val first_flag = False first_flag False print_line = print_line + ' ' + str(val) print_line print_line + ' ' + str(val) print_line + ' ' print_line ' ' str(val) str val print(print_line) print print_line X X def selection_sort(A, N):
    counter = 0

    for i in range(N):
        min_j = i

        for j in range(i, N):
            if A[j] < A[min_j]:
                min_j = j

        if i != min_j:
            A[i], A[min_j] = A[min_j], A[i]
            counter += 1

    print_list(A)
    print(counter) selection_sort counter = 0 counter 0 for i in range(N):
        min_j = i

        for j in range(i, N):
            if A[j] < A[min_j]:
                min_j = j

        if i != min_j:
            A[i], A[min_j] = A[min_j], A[i]
            counter += 1

     i range(N) range N min_j = i min_j i for j in range(i, N):
            if A[j] < A[min_j]:
                min_j = j

         j range(i, N) range i N if A[j] < A[min_j]:
                min_j = j

         A[j] < A[min_j] A[j] A j A[min_j] A min_j min_j = j min_j j if i != min_j:
            A[i], A[min_j] = A[min_j], A[i]
            counter += 1

     i != min_j i min_j A[i], A[min_j] = A[min_j], A[i] A[i] A i A[min_j] A min_j A[min_j] A min_j A[i] A i counter += 1 counter 1 print_list(A) print_list A print(counter) print counter 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 A = list(map(int, input().split())) list(map(int, input().split())) A N = int(input()) int(input()) N def selection_sort(A, N):
    counter = 0

    for i in range(N):
        min_j = i

        for j in range(i, N):
            if A[j] < A[min_j]:
                min_j = j

        if i != min_j:
            A[i], A[min_j] = A[min_j], A[i]
            counter += 1

    print_list(A)
    print(counter) def selection_sort(A, N):
    counter = 0

    for i in range(N):
        min_j = i

        for j in range(i, N):
            if A[j] < A[min_j]:
                min_j = j

        if i != min_j:
            A[i], A[min_j] = A[min_j], A[i]
            counter += 1

    print_list(A)
    print(counter) selection_sort def print_list(X):
    first_flag = True
    for val in X:
        if first_flag:
            print_line = str(val)
            first_flag = False
        else:
            print_line = print_line + ' ' + str(val)
    print(print_line) def print_list(X):
    first_flag = True
    for val in X:
        if first_flag:
            print_line = str(val)
            first_flag = False
        else:
            print_line = print_line + ' ' + str(val)
    print(print_line) print_list
# coding=utf-8

def print_list(X):
    first_flag = True
    for val in X:
        if first_flag:
            print_line = str(val)
            first_flag = False
        else:
            print_line = print_line + ' ' + str(val)
    print(print_line)

def selection_sort(A, N):
    counter = 0

    for i in range(N):
        min_j = i

        for j in range(i, N):
            if A[j] < A[min_j]:
                min_j = j

        if i != min_j:
            A[i], A[min_j] = A[min_j], A[i]
            counter += 1

    print_list(A)
    print(counter)

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

selection_sort(A, N)