#include <bits/stdc++.h>
void SelectionSort(int n, int A[]);
int count = 0;
int main() {
  int n, i, j, A[1000];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  SelectionSort(n, &A[0]);
  for (i = 0; i < n; i++) {
    if (i != 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d", count);
  printf("\n");
  return 0;
}
void SelectionSort(int n, int A[]) {
  int i, j;
  int mini, key;
  for (i = 0; i < n - 1; i++) {
    mini = i;
    for (j = i; j < n - 1; j++) {
      if (A[j] < A[mini]) {
        key = A[j];
        A[j] = A[mini];
        A[mini] = key;
        ++count;
      }
    }
  }
}
