def sort(a):
    n = len(a)
    nswaps = 0
    for i in range(n):
        minv = None
        minp = -1
        for j in range(i, n):
            if minv == None or minv > a[j]:
                minv = a[j]
                minp = j
        a[minp], a[i] = a[i], a[minp]
        if i != minp:
            nswaps += 1
    return nswaps

n = int(raw_input())
a = map(int, raw_input().split(' '))
nswaps = sort(a)
print ' '.join(map(str, a))
print nswaps def sort(a):
    n = len(a)
    nswaps = 0
    for i in range(n):
        minv = None
        minp = -1
        for j in range(i, n):
            if minv == None or minv > a[j]:
                minv = a[j]
                minp = j
        a[minp], a[i] = a[i], a[minp]
        if i != minp:
            nswaps += 1
    return nswaps sort n = len(a) n len(a) len a nswaps = 0 nswaps 0 for i in range(n):
        minv = None
        minp = -1
        for j in range(i, n):
            if minv == None or minv > a[j]:
                minv = a[j]
                minp = j
        a[minp], a[i] = a[i], a[minp]
        if i != minp:
            nswaps += 1
     i range(n) range n minv = None minv None minp = -1 minp -1 for j in range(i, n):
            if minv == None or minv > a[j]:
                minv = a[j]
                minp = j
         j range(i, n) range i n if minv == None or minv > a[j]:
                minv = a[j]
                minp = j
         minv == None or minv > a[j] minv == None minv None minv > a[j] minv a[j] a j minv = a[j] minv a[j] a j minp = j minp j a[minp], a[i] = a[i], a[minp] a[minp] a minp a[i] a i a[i] a i a[minp] a minp if i != minp:
            nswaps += 1
     i != minp i minp nswaps += 1 nswaps 1 return nswaps nswaps a a n = int(raw_input()) n int(raw_input()) int raw_input() raw_input a = map(int, raw_input().split(' ')) a map(int, raw_input().split(' ')) map int raw_input().split(' ') ().split () raw_input split ' ' nswaps = sort(a) nswaps sort(a) sort a print ' '.join(map(str, a)) ' '.join ' ' join map(str, a) map str a print a = map(int, raw_input().split(' ')) map(int, raw_input().split(' ')) a def sort(a):
    n = len(a)
    nswaps = 0
    for i in range(n):
        minv = None
        minp = -1
        for j in range(i, n):
            if minv == None or minv > a[j]:
                minv = a[j]
                minp = j
        a[minp], a[i] = a[i], a[minp]
        if i != minp:
            nswaps += 1
    return nswaps def sort(a):
    n = len(a)
    nswaps = 0
    for i in range(n):
        minv = None
        minp = -1
        for j in range(i, n):
            if minv == None or minv > a[j]:
                minv = a[j]
                minp = j
        a[minp], a[i] = a[i], a[minp]
        if i != minp:
            nswaps += 1
    return nswaps sort nswaps = sort(a) sort(a) nswaps n = int(raw_input()) int(raw_input()) n
def sort(a):
    n = len(a)
    nswaps = 0
    for i in range(n):
        minv = None
        minp = -1
        for j in range(i, n):
            if minv == None or minv > a[j]:
                minv = a[j]
                minp = j
        a[minp], a[i] = a[i], a[minp]
        if i != minp:
            nswaps += 1
    return nswaps

n = int(raw_input())
a = map(int, raw_input().split(' '))
nswaps = sort(a)
print ' '.join(map(str, a))
print nswaps