Klimi and Nikol have an integer array $A$ with $N$ cells numbered from $0$ to $N - 1$ and containing different integer values. The girls are playing a game played with a single piece that is moved around the array. Initially, the piece is located in the some cell. One move of the game proceeds as follows:
The moves alternate between the two girls and Klimi plays first. The game ends in exactly $10^{100}$ turns, at which point the girl whose total score is higher wins. If their score is equal, then Klimi wins.
The girls aren’t quite happy with the time it takes to finish even a single game, so they ask you to just figure out the optimal play results in different scenarios.
Formally, you will be given the initial array $A$ and the value $D$, and then you will have to process $Q$ queries of two types:
The updates persist across queries, so each question must be answered considering all updates that have happened so far.
The implementation details section describes the interfaces you should support in more detail.
index, startIndex$ < N$newValue$ ≤ 10^9$