#include #include #include using namespace std; int main() { freopen("outofplace.in", "r", stdin); size_t n; cin >> n; vector heights(n); for (int &height : heights) { cin >> height; } vector sortedHeights(heights); sort(sortedHeights.begin(), sortedHeights.end()); int bad = 0; for (int i = 0; i < n; i++) { if (sortedHeights[i] != heights[i]) { bad++; } } freopen("outofplace.out", "w", stdout); cout << bad - 1; return 0; }