You are going to implement the most powerful editor for integer sequences. The sequence is empty when the editor is initialized. There are 5 types of instructions.
I x Insert x after the cursor. D Delete the element before the cursor. L Move the cursor left unless it has already been at the begin. R Move the cursor right unless it has already been at the end. Q k Suppose that the current sequence BEFORE the cursor is {a1,a2,...,an}.Find max1≤i≤k Si where Si=a1+a2+...+ai.
The input file consists of multiple test cases.For eache test case: The first line contains an integer Q,which is the number of instructions.The next Q lines contain an instruction as described above。 (1≤Q≤106,|x|≤103 for I instruction,1≤k≤n for Q instruction)
For eache Q instruction,output the desired value.
8 I 2 I -1 I 1 Q 3 L D R Q 2
2 3
For eache Q instruction,output the desired value.