#include #include #include struct Block { int length; int number; }; int main(int argc, char const* argv[]) { int n; std::cin >> n; std::vector blocks(n); for (int i = 0; i < n; i++) { blocks[i].number = i + 1; std::cin >> blocks[i].length; } std::sort(blocks.begin(), blocks.end(), [](Block x, Block y) { return x.length > y.length; }); int ans = 0; for (int i = 0; i < n; i++) { if (blocks[i].number < blocks[i+1].number) { ans = n - (i + 1); break; } } std::cout << ans << std::endl; return 0; }