package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func SelectionSort(buf []int) int {
	count := 0

	for i := 0; i < len(buf)-1; i++ {
		min := buf[i]
		index := i
		for j := i + 1; j < len(buf); j++ {
			if min > buf[j] {
				min = buf[j]
				index = j
			}
			if i != index {
				buf[i], buf[j] = buf[j], buf[i]
				count++
			}
		}
	}
	return count
}

func main() {

	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	buf := make([]int, n)

	sc.Scan()
	line := sc.Text()
	words := strings.Split(line, " ")
	for i, word := range words {
		buf[i], _ = strconv.Atoi(word)
	}

	count := SelectionSort(buf)

	for i, val := range buf {
		if i == len(buf)-1 {
			fmt.Printf("%d\n", val)
		} else {
			fmt.Printf("%d ", val)
		}
	}
	fmt.Println(count)
}

