Just before the tournament, player ratings keep getting updated live (injuries, form changes) right up until each team-selection query — Zayan needs the team-selection queries answered correctly even with ratings updating in between. Same as the full World T20 X Team problem (Set 15 Q3), but now ratings can be UPDATED between queries: process a mixed stream of "U i v" (update player i's rating to v) and "Q X" (query the max pairwise-difference sum for team size X) operations, answering each Q operation online (in the given order). Think carefully about whether a full offline batch precomputation still works when updates are interleaved, or whether you need a different data structure (e.g. a Fenwick tree over sorted rating buckets) to keep queries fast.
Input
Line1: N. Line2: N integers (initial ratings). Line3: Q. Next Q lines: "U i v" or "Q X".
Output
One line per Q operation: the requested maximum sum.
Constraints
1 ≤ N, Q ≤ 10^5
Sample Input
5 1 2 3 4 5 2 Q 2 U 1 100
Sample Output
4
Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.