#include <bits/stdc++.h>
int main() {
  int N;
  scanf("%d", &N);
  int A[101], element;
  for (element = 0; element <= N - 1; element++) {
    scanf("%d ", &A[element]);
  }
  int i, minj, j, count = 0;
  for (i = 0; i <= N - 1; i++) {
    minj = i;
    for (j = i; j <= N - 1; j++) {
      if (A[minj] > A[j]) {
        int k;
        k = A[minj];
        A[minj] = A[j];
        A[j] = k;
        minj = j;
        count++;
      }
    }
  }
  for (i = 0; i <= N - 2; i++) {
    printf("%d ", A[i]);
  }
  printf("%d\n", A[N - 1]);
  printf("%d\n", count);
}
