The package for this problem was not updated by the problem writer or Codeforces administration after we've upgraded the judging servers. To adjust the time limit constraint, a solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then the value 800 ms will be displayed and used to determine the verdict.

Codeforces Round 179 (Div. 1) |
---|

Finished |

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

data structures

*2500

No tag edit access

The problem statement has recently been changed. View the changes.

×
E. Yaroslav and Points

time limit per test

5 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYaroslav has *n* points that lie on the *Ox* axis. The coordinate of the first point is *x*_{1}, the coordinate of the second point is *x*_{2}, ..., the coordinate of the *n*-th point is — *x*_{n}. Now Yaroslav wants to execute *m* queries, each of them is of one of the two following types:

- Move the
*p*_{j}-th point from position*x*_{pj}to position*x*_{pj}+*d*_{j}. At that, it is guaranteed that after executing such query all coordinates of the points will be distinct. - Count the sum of distances between all pairs of points that lie on the segment [
*l*_{j},*r*_{j}] (*l*_{j}≤*r*_{j}). In other words, you should count the sum of: .

Help Yaroslav.

Input

The first line contains integer *n* — the number of points (1 ≤ *n* ≤ 10^{5}). The second line contains distinct integers *x*_{1}, *x*_{2}, ..., *x*_{n} — the coordinates of points (|*x*_{i}| ≤ 10^{9}).

The third line contains integer *m* — the number of queries (1 ≤ *m* ≤ 10^{5}). The next *m* lines contain the queries. The *j*-th line first contains integer *t*_{j} (1 ≤ *t*_{j} ≤ 2) — the query type. If *t*_{j} = 1, then it is followed by two integers *p*_{j} and *d*_{j} (1 ≤ *p*_{j} ≤ *n*, |*d*_{j}| ≤ 1000). If *t*_{j} = 2, then it is followed by two integers *l*_{j} and *r*_{j} ( - 10^{9} ≤ *l*_{j} ≤ *r*_{j} ≤ 10^{9}).

It is guaranteed that at any moment all the points have distinct coordinates.

Output

For each type 2 query print the answer on a single line. Print the answers in the order, in which the queries follow in the input.

Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.

Examples

Input

8

36 50 28 -75 40 -60 -95 -48

20

2 -61 29

1 5 -53

1 1 429

1 5 130

2 -101 -71

2 -69 53

1 1 404

1 5 518

2 -101 53

2 50 872

1 1 -207

2 -99 -40

1 7 -389

1 6 -171

1 2 464

1 7 -707

1 1 -730

1 1 560

2 635 644

1 7 -677

Output

176

20

406

1046

1638

156

0

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Apr/12/2024 21:36:30 (l2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|