Given an integer sequence of length , define as follows:
- is the minimum number of operations required to make the following condition true:
- Operation: Choose one integer such that , and either increase by or decrease by .
- Condition: For all where , the condition should be satisfied.
You are given a sequence of length .
Process queries. For each query (where ):
- Given integers and , update to and then output .