#include<stdio.h>
int main(void)
{
    int n,i,j,minj,a[],s,temp;

    scanf("%d",&n);
    
    for(i = 0; i < n; i++){
      scanf("%d",&a[i]);
    }
    
    for(i = 0; i < n-1; i++) {
      minj = i;
      for(j = i; j < n-1; j++) {
        minj = j;
        temp = a[i];
        a[i] = a[minj];
        a[minj] = temp;
        s++;
      }
    }

    for(i = 0; i < n; i++){
      printf("%d ",a[i]);
    }

    printf("\n");
    printf("%d",s);

    return 0;
}