#include <bits/stdc++.h>
using namespace std;
int main() {
  int length = 0;
  cin >> length;
  int* data = new int[length];
  for (int i = 0; i < length; ++i) {
    cin >> data[i];
  }
  int swap_times = 0;
  for (int i = length - 1; i > 0; --i) {
    int max = data[i];
    int max_index = i;
    for (int j = 0; j <= i; ++j) {
      if (data[j] > max) {
        max = data[j];
        max_index = j;
      }
    }
    if (max > data[i]) {
      swap(data[max_index], data[i]);
      ++swap_times;
    }
  }
  for (int i = 0; i < length; ++i) {
    if (i < length - 1) {
      cout << data[i] << " ";
    } else {
      cout << data[i] << endl;
    }
  }
  cout << swap_times << endl;
}
