def serect_sort(r, n):
    cnt = 0
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if r[j] < r[minj]:
                minj = j
        r[i],r[minj] = r[minj],r[i]
        if i != minj:
            cnt +=1
    print(*r)
    print(cnt)

N = int(input())
A = list(map(int, input().split()))
serect_sort(A, N) def serect_sort(r, n):
    cnt = 0
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if r[j] < r[minj]:
                minj = j
        r[i],r[minj] = r[minj],r[i]
        if i != minj:
            cnt +=1
    print(*r)
    print(cnt) serect_sort cnt = 0 cnt 0 for i in range(0, n):
        minj = i
        for j in range(i, n):
            if r[j] < r[minj]:
                minj = j
        r[i],r[minj] = r[minj],r[i]
        if i != minj:
            cnt +=1
     i range(0, n) range 0 n minj = i minj i for j in range(i, n):
            if r[j] < r[minj]:
                minj = j
         j range(i, n) range i n if r[j] < r[minj]:
                minj = j
         r[j] < r[minj] r[j] r j r[minj] r minj minj = j minj j r[i],r[minj] = r[minj],r[i] r[i] r i r[minj] r minj r[minj] r minj r[i] r i if i != minj:
            cnt +=1
     i != minj i minj cnt +=1 cnt 1 print(*r) print *r r print(cnt) print cnt r r 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 serect_sort(A, N) serect_sort A N N = int(input()) int(input()) N A = list(map(int, input().split())) list(map(int, input().split())) A def serect_sort(r, n):
    cnt = 0
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if r[j] < r[minj]:
                minj = j
        r[i],r[minj] = r[minj],r[i]
        if i != minj:
            cnt +=1
    print(*r)
    print(cnt) def serect_sort(r, n):
    cnt = 0
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if r[j] < r[minj]:
                minj = j
        r[i],r[minj] = r[minj],r[i]
        if i != minj:
            cnt +=1
    print(*r)
    print(cnt) serect_sort
def serect_sort(r, n):
    cnt = 0
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if r[j] < r[minj]:
                minj = j
        r[i],r[minj] = r[minj],r[i]
        if i != minj:
            cnt +=1
    print(*r)
    print(cnt)

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