def selectionSort(a, n):
    count = 0
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if a[j] < a[minj]:
                minj = j
        a[i], a[minj] = a[minj], a[i]
        if i != minj:
            count += 1
    return count


def main():
    n = int(input())
    a = [int(x) for x in input().split(' ')]
    count = selectionSort(a, n)
    print(' '.join([str(x) for x in a]))
    print(count)


if __name__ == '__main__':
    main() def selectionSort(a, n):
    count = 0
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if a[j] < a[minj]:
                minj = j
        a[i], a[minj] = a[minj], a[i]
        if i != minj:
            count += 1
    return count selectionSort count = 0 count 0 for i in range(0, n):
        minj = i
        for j in range(i, n):
            if a[j] < a[minj]:
                minj = j
        a[i], a[minj] = a[minj], a[i]
        if i != minj:
            count += 1
     i range(0, n) range 0 n minj = i minj i for j in range(i, n):
            if a[j] < a[minj]:
                minj = j
         j range(i, n) range i n if a[j] < a[minj]:
                minj = j
         a[j] < a[minj] a[j] a j a[minj] a minj 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 i != minj:
            count += 1
     i != minj i minj count += 1 count 1 return count count a a n n def main():
    n = int(input())
    a = [int(x) for x in input().split(' ')]
    count = selectionSort(a, n)
    print(' '.join([str(x) for x in a]))
    print(count) main n = int(input()) n int(input()) int input() input int(x) for x in input().split(' ') for x in input().split(' ') x input().split(' ') ().split () input split ' ' for x in input().split(' ') int(x) int x a = [int(x) for x in input().split(' ')] a [int(x) for x in input().split(' ')] count = selectionSort(a, n) count selectionSort(a, n) selectionSort a n str(x) for x in a for x in a x a for x in a str(x) str x print(' '.join([str(x) for x in a])) print ' '.join([str(x) for x in a]) ' '.join ' ' join [str(x) for x in a] print(count) print count if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def selectionSort(a, n):
    count = 0
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if a[j] < a[minj]:
                minj = j
        a[i], a[minj] = a[minj], a[i]
        if i != minj:
            count += 1
    return count def selectionSort(a, n):
    count = 0
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if a[j] < a[minj]:
                minj = j
        a[i], a[minj] = a[minj], a[i]
        if i != minj:
            count += 1
    return count selectionSort def main():
    n = int(input())
    a = [int(x) for x in input().split(' ')]
    count = selectionSort(a, n)
    print(' '.join([str(x) for x in a]))
    print(count) def main():
    n = int(input())
    a = [int(x) for x in input().split(' ')]
    count = selectionSort(a, n)
    print(' '.join([str(x) for x in a]))
    print(count) main
def selectionSort(a, n):
    count = 0
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if a[j] < a[minj]:
                minj = j
        a[i], a[minj] = a[minj], a[i]
        if i != minj:
            count += 1
    return count


def main():
    n = int(input())
    a = [int(x) for x in input().split(' ')]
    count = selectionSort(a, n)
    print(' '.join([str(x) for x in a]))
    print(count)


if __name__ == '__main__':
    main()