#SGM0000007. Tổng hai phần tử lớn nhất (Maximum Sum)
Tổng hai phần tử lớn nhất (Maximum Sum)
Maximum Sum
Source: SPOJ
Version: Phuoc Hung OJ Extended
You are given an array . Process two kinds of operations:
U i x: assign .Q x y: for , find the maximum possible sum of two elements at distinct positions inside .
Print the answer for every Q operation.
Input
The first line contains .
The second line contains .
The third line contains , the number of operations.
Each of the next lines is either U i x or Q x y.
Output
For every Q operation, print the required maximum sum on its own line.
Subtasks
- Subtask 1 — 20%: , .
- Subtask 2 — 30%: , .
- Subtask 3 — 50%: , , .
Examples
Input
5
1 2 3 4 5
6
Q 2 4
Q 2 5
U 1 6
Q 1 5
U 1 7
Q 1 5
Output
7
9
11
12
Explanation
The sample follows the operations exactly; each printed line corresponds to a query that requires output.