P17642 [HackerEarth] You are given a list of elements of size N ( index starts from 1), each element is "a[k]" , k ranges from 1 to N. You have to perform C number of operations on them . An operation is
普及
题目描述

You are given a list of elements of size N ( index starts from 1), each element is "a[k]" , k ranges from 1 to N. You have to perform C number of operations on them . An operation is either Update(U) or Query(Q). Update operations have syntax "U i j" , it means the " ith" element a[i] of the list has to be replaced with the value "j" . Query operations have syntax "Q i j" , it means you have to find out the maximum sum of the pair of elements in the range "i" to "j" (both inclusive). i.e maximum sum of pair a[k] and a[l], where i ≤ k < j and i < l ≤ J.

You have to print all the outputs of the queries "Q i j" in each line.

Input Format:
First line consist of N, the size of the number of elements. Second line consists of N elements separated by a space.
Next line consists of the number of queries C to be performed.
Next C lines consists of queries of the form: "U i j" or "Q i j".

Output Format:
Output for all the queries of the form "Q i j" separated by a line.

Constraints:
Elements of list can be fitted in a 4 byte integer : a[i] ≥ 0

1 ≤ N ≤ 1000000

1 ≤ C ≤ 1000000

1 ≤ i < j ≤N

SAMPLE INPUT
10
4 1 0 4 5 5 0 2 2 6
5
Q 1 8
Q 3 9
U 6 10
U 1 6
Q 4 6

SAMPLE OUTPUT
10
10
15

Explanation

Given list is 1-based index as mentioned in problem statement, for the first query "Q 1 8" we have to find maximum sum of the pair of elements 1 to 8(both inclusive) , answer is 10 for the as it can be seen in the list.

3rd query "U 6 10" modifies the 6th element to 10.
5th query "Q 4 6" ,finds the maximum sum of the pair of element from the index 4 to 6 both inclusive and 15 is the right answer

输入格式

见题面

输出格式

见题面

样例输入
10 831025734 136108068 176372216 635774760 579136888 881243160 444002413 668506376 584719302 571496405 100 U 5 7 U 1 3 U 2 4 Q 1 10 U 1 4 Q 6 9 U 5 6 U 1 4 U 1 7 Q 2 10 U 1 6 U 2 5 Q 2 8 U 5 10 U 1 8 U 1 10 U 1 8 U 2 8 U 1 8 U 1 5 Q 2 10 Q 3 6 U 1 2 Q 9 10 U 8 9 U 2 5 U 2 5 U 5 7 U 5 7 U 1 7 Q 4 9 Q 3 9 U 3 4 U 3 7 U 7 9 Q 4 5 Q 7 9 Q 1 3 U 2 7 Q 2 9 Q 7 9 Q 4 10 U 1 9 Q 2 8 U 4 7 U 1 9 U 2 6 U 6 10 U 1 5 U 3 7 Q 1 9 U 1 4 Q 8 10 U 1 6 U 3 6 U 1 7 U 1 5 Q 2 7 U 6 7 U 3 7 U 3 7 Q 9 10 U 1 8 Q 2 3 U 6 8 Q 6 8 Q 2 8 Q 7 9 Q 3 7 Q 1 3 Q 1 10 U 4 8 Q 1 4 U 4 6 Q 1 7 Q 6 8 Q 6 10 Q 1 3 U 4 9 U 1 6 Q 1 6 Q 5 8 Q 2 6 U 7 9 U 1 4 U 3 6 U 1 5 U 2 5 U 2 7 Q 1 4 U 6 9 Q 1 9 Q 3 8 U 1 4 U 3 4 Q 1 2 U 1 5 Q 1 5 U 7 8 Q 1 3
样例输出
1549749536 1549749536 1549749536 1549749536 1549749536 1517017920 1156215707 1517017920 1517017920 635774767 584719311 14 1517017920 584719311 1517017920 1517017920 584719312 1156215707 19 1156215707 13 18 18 584719311 17 15 1156215707 16 17 18 1156215707 15 17 18 17 16 584719311 18 11 16 12