#include <bits/stdc++.h>
using namespace std;
long long cnt;
struct SSS {
  string str;
  int val;
  SSS(string s = "", int v = 0) : str(s), val(v){};
};
void print(vector<SSS> &data) {
  for (int i = 0; i < data.size(); ++i) {
    cout << data[i].str << " " << data[i].val << endl;
  }
}
void print(vector<int> &data) {
  for (int i = 0; i < data.size(); ++i) {
    cout << data[i];
    if (i == data.size() - 1)
      cout << endl;
    else
      cout << " ";
  }
}
void insS(vector<int> &data) {
  for (int i = 0; i < data.size(); ++i) {
    int v = data[i];
    int j = i - 1;
    while (j >= 0 && data[j] > v) {
      data[j + 1] = data[j];
      j--;
    }
    data[j + 1] = v;
    print(data);
  }
}
void bubS(vector<int> &data) {
  for (int i = 0; i < data.size(); ++i) {
    int j = data.size() - 1;
    for (; j > i; --j) {
      if (data[j] < data[j - 1]) {
        swap(data[j], data[j - 1]);
        cnt++;
      }
    }
  }
  print(data);
  cout << cnt << endl;
}
void selS(vector<int> &data) {
  for (int i = 0; i < data.size(); ++i) {
    int idx = i;
    for (int j = i; j < data.size(); ++j) {
      if (data[j] < data[idx]) idx = j;
    }
    swap(data[idx], data[i]);
    cnt += (i != idx);
  }
  print(data);
  cout << cnt << endl;
}
int main() {
  int n;
  cin >> n;
  vector<int> data(n);
  for (int i = 0; i < n; ++i) cin >> data[i];
  selS(data);
  return 0;
}
