def selectionSort(A,N):
    b = 0
    for i in range(0,N):
        minj = i
        for j in range(i,N):
            if A[minj] > A[j]:
                minj = j
        A[i],A[minj] = A[minj],A[i]
        if minj != i:
            b += 1
        
    print(*A)
    print(b)

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

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

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

selectionSort(A,N)
