eolymp
bolt
Try our new interface for solving problems
Problems

Signs alternating

Signs alternating

Implement the data structure from n elements a1, a2, ..., an that supports the next operations:

  • assign to element ai the value j;
  • find the alternating sum of segment from l to r inclusively, it est (al - al+1 + al+2 - ... ar).

Input

The first line contains positive integer n (1n105) - the length of array. Second line contains initial values of array - nonnegative integers, not greater than 104.

Third line contains positive integer m (1m105) - the number of operations. In the next m lines the operations are given:

  • operation of the first type is given with three integers 0 i j (1in, 1j104);
  • operation of the second type is given with three integers 1 l r (1lrn).

Output

For each operation of the second type print in a separate line the corresponding alternating sum.

Time limit 1 second
Memory limit 122.17 MiB
Input example #1
3
1 2 3
5
1 1 2
1 1 3
1 2 3
0 2 1
1 1 3
Output example #1
-1
2
-1
3