def selection_sort(seq):
    l = len(seq)
    cnt = 0
    for i in range(l):
        mi = i
        for j in range(i+1, l):
            if seq[j] < seq[mi]:
                mi = j
        if i is not mi:
            seq[i], seq[mi] = seq[mi], seq[i]
            cnt += 1
    return seq, cnt

n = int(input())
a = list(map(int, input().split()))
sorted_a, num_swap = selection_sort(a)
print(' '.join(map(str, sorted_a)))
print(num_swap) def selection_sort(seq):
    l = len(seq)
    cnt = 0
    for i in range(l):
        mi = i
        for j in range(i+1, l):
            if seq[j] < seq[mi]:
                mi = j
        if i is not mi:
            seq[i], seq[mi] = seq[mi], seq[i]
            cnt += 1
    return seq, cnt selection_sort l = len(seq) l len(seq) len seq cnt = 0 cnt 0 for i in range(l):
        mi = i
        for j in range(i+1, l):
            if seq[j] < seq[mi]:
                mi = j
        if i is not mi:
            seq[i], seq[mi] = seq[mi], seq[i]
            cnt += 1
     i range(l) range l mi = i mi i for j in range(i+1, l):
            if seq[j] < seq[mi]:
                mi = j
         j range(i+1, l) range i+1 i 1 l if seq[j] < seq[mi]:
                mi = j
         seq[j] < seq[mi] seq[j] seq j seq[mi] seq mi mi = j mi j if i is not mi:
            seq[i], seq[mi] = seq[mi], seq[i]
            cnt += 1
     i is not mi i mi seq[i], seq[mi] = seq[mi], seq[i] seq[i] seq i seq[mi] seq mi seq[mi] seq mi seq[i] seq i cnt += 1 cnt 1 return seq, cnt return seq, cnt seq cnt seq seq 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 sorted_a, num_swap = selection_sort(a) sorted_a selection_sort(a) selection_sort a num_swap print(' '.join(map(str, sorted_a))) print ' '.join(map(str, sorted_a)) ' '.join ' ' join map(str, sorted_a) map str sorted_a print(num_swap) print num_swap a = list(map(int, input().split())) list(map(int, input().split())) a num_swap = selection_sort(a) selection_sort(a) num_swap sorted_a, num_swap = selection_sort(a) selection_sort(a) sorted_a def selection_sort(seq):
    l = len(seq)
    cnt = 0
    for i in range(l):
        mi = i
        for j in range(i+1, l):
            if seq[j] < seq[mi]:
                mi = j
        if i is not mi:
            seq[i], seq[mi] = seq[mi], seq[i]
            cnt += 1
    return seq, cnt def selection_sort(seq):
    l = len(seq)
    cnt = 0
    for i in range(l):
        mi = i
        for j in range(i+1, l):
            if seq[j] < seq[mi]:
                mi = j
        if i is not mi:
            seq[i], seq[mi] = seq[mi], seq[i]
            cnt += 1
    return seq, cnt selection_sort n = int(input()) int(input()) n
def selection_sort(seq):
    l = len(seq)
    cnt = 0
    for i in range(l):
        mi = i
        for j in range(i+1, l):
            if seq[j] < seq[mi]:
                mi = j
        if i is not mi:
            seq[i], seq[mi] = seq[mi], seq[i]
            cnt += 1
    return seq, cnt

n = int(input())
a = list(map(int, input().split()))
sorted_a, num_swap = selection_sort(a)
print(' '.join(map(str, sorted_a)))
print(num_swap)