#include using namespace std; using ll = long long; void fast_io() { cin.tie(nullptr); ios_base::sync_with_stdio(false); } int main(void) { fast_io(); int n; cin >> n; vector p(n); for (int i = 0; i < n; i++) { cin >> p[i]; } int ans = 0; for (int i = 0; i < n - 1; i++) { int index = i + 1; for (int j = i + 1; j < n; j++) { if (p[j] < p[index]) { index = j; } } if (p[i] > p[index]) { swap(p[i], p[index]); ans++; } } cout << ans << endl; return 0; }