using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJSort1
{
    class Program
    {
        static int c = 0;
        static void Swap(ref int a,ref int b)
        {
            int c = b;
            b = a;
            a = c;
        }
        static int[] Sort(int []a,int count)
        {
            int min = a.Length - count;
            for (int i = a.Length - count; i < a.Length; i++)
            {
                if (a[i] < a[min])
                {
                    min = i;
                }
            }
            Swap(ref a[min], ref a[a.Length - count]);
            if (min != a.Length - count) { c++; }
            if (count >1) { Sort(a, --count); }
            return a;
        }
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            a = Sort(a,N);
            for(int i = 0; i < a.Length; i++)
            {
                Console.Write(a[i] + " ");
            }
            Console.WriteLine();
            Console.WriteLine(c);
        }
    }
}