Given an array of positive integers, define one quicksort operation as the following:
For example, if we have the array $$$\{5, 4, 6, 5, 3, 1, 4, 2\}$$$ and we choose the pivot to be $$$4$$$, the new array becomes $$$\{3, 1, 2, 4, 4, 5, 6, 5\}$$$.
Given an array of $$$n$$$ integers and $$$q$$$ modification queries in the form $$$a_i = v$$$, find the minimum number of quicksort operations required to sort the array into ascending order after each operation. The updates are permanent.
The first line contains $$$n$$$ ($$$1 \le n \le 10^5$$$).
The second line contains $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^9$$$).
The third line contains $$$q$$$ ($$$1 \le q \le 10^5$$$).
Each of the next $$$q$$$ lines contains $$$i$$$ and $$$v$$$ ($$$1 \le i \le n$$$, $$$1 \le v \le 10^9$$$), indicating a modification query in the form $$$a_i = v$$$.
After each modification query, print the minimum number of quicksort operations required to sort the array.
88 5 4 6 1 7 3 587 87 46 64 14 72 85 45 7
3 3 2 2 3 3 2 2