#include <bits/stdc++.h>
using namespace std;
int selectionSort(int A[], int N) {
  int i, j, minj, sw;
  sw = 0;
  bool flag = 1;
  for (int i = 0; flag; i++) {
    minj = i;
    flag = 0;
    for (int j = N - 1; j > i; j--) {
      if (A[minj] > A[j]) {
        swap(A[minj], A[j]);
        sw++;
        flag = 1;
      }
    }
  }
  return sw;
}
int main() {
  int N, A[100], sw;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sw = selectionSort(A, N);
  for (int i = 0; i < N; i++) {
    if (i) {
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;
}
