#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 A1,A2,…,ANA_1,A_2,\ldots,A_N. Process two kinds of operations:

  • U i x: assign Ai=xA_i=x.
  • Q x y: for 1≤x<y≤N1\le x<y\le N, find the maximum possible sum of two elements at distinct positions inside [x,y][x,y].

Print the answer for every Q operation.

Input

The first line contains NN.

The second line contains A1,A2,…,ANA_1,A_2,\ldots,A_N.

The third line contains QQ, the number of operations.

Each of the next QQ 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%: 2≤N,Q≤502\le N,Q\le 50, 0≤Ai,x≤1040\le A_i,x\le 10^4.
  • Subtask 2 — 30%: 2≤N,Q≤50002\le N,Q\le 5000, 0≤Ai,x≤1080\le A_i,x\le 10^8.
  • Subtask 3 — 50%: 2≤N≤1052\le N\le 10^5, 1≤Q≤1051\le Q\le 10^5, 0≤Ai,x≤1080\le A_i,x\le 10^8.

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.