#include <bits/stdc++.h>
int main() {
  int a[100];
  int i, j, n, cout = 1, minj;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &n);
  for (i = 0; i < n; i++) {
    minj = i;
    for (j = i; j < n; j++) {
      if (a[j] < a[minj]) {
        minj = j;
      }
      a[i] = a[minj];
      cout++;
    }
  }
  for (i = 0; i < n; i++) {
    printf(" %d", a[i]);
  }
  printf("\n");
  printf("%d\n", cout);
  return 0;
}
