Yaroslav has n points that lie on the Ox axis. The coordinate of the first point is x1, the coordinate of the second point is x2, ..., the coordinate of the n-th point is — xn. Now Yaroslav wants to execute m queries, each of them is of one of the two following types:

  1. Move the pj-th point from position xpj to position xpj + dj. At that, it is guaranteed that after executing such query all coordinates of the points will be distinct. 
  2. Count the sum of distances between all pairs of points that lie on the segment [lj, rj] (lj ≤ rj). In other words, you should count the sum of: <image>. 



Help Yaroslav.

Input

The first line contains integer n — the number of points (1 ≤ n ≤ 105). The second line contains distinct integers x1, x2, ..., xn — the coordinates of points (|xi| ≤ 109).

The third line contains integer m — the number of queries (1 ≤ m ≤ 105). The next m lines contain the queries. The j-th line first contains integer tj (1 ≤ tj ≤ 2) — the query type. If tj = 1, then it is followed by two integers pj and dj (1 ≤ pj ≤ n, |dj| ≤ 1000). If tj = 2, then it is followed by two integers lj and rj ( - 109 ≤ lj ≤ rj ≤ 109).

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
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
class Query {
 public:
  int t, x, y;
  void read() { scanf("%d%d%d", &t, &x, &y); }
};
vector<Query> Que;
vector<int> px, pp, np;
struct trnode {
  long long sum, num, ans;
  int x, y, l, r;
} tr[maxn * 2];
int tot, n, m;
void update(int t) {
  tr[t].sum = tr[tr[t].l].sum + tr[tr[t].r].sum;
  tr[t].num = tr[tr[t].l].num + tr[tr[t].r].num;
  tr[t].ans = tr[tr[t].l].ans + tr[tr[t].r].ans -
              tr[tr[t].r].num * tr[tr[t].l].sum +
              tr[tr[t].l].num * tr[tr[t].r].sum;
}
void build(int x, int y) {
  int t = ++tot;
  tr[t].x = x, tr[t].y = y;
  if (x == y) {
    tr[t].l = tr[t].r = 0;
    tr[t].sum = tr[t].num = tr[t].ans = 0;
  } else {
    tr[t].l = tot + 1;
    build(x, (x + y) / 2);
    tr[t].r = tot + 1;
    build((x + y) / 2 + 1, y);
    update(t);
  }
}
void change(int t, int x, int d) {
  if (tr[t].x == tr[t].y) {
    tr[t].num += d;
    tr[t].sum += d * pp[x - 1];
  } else {
    int mid = (tr[t].x + tr[t].y) / 2;
    if (x <= mid)
      change(tr[t].l, x, d);
    else if (x > mid)
      change(tr[t].r, x, d);
    update(t);
  }
}
pair<pair<long long, long long>, long long> tr_query(int t, int L, int R) {
  if (tr[t].x > R || tr[t].y < L) return make_pair(make_pair(0, 0), 0);
  if (L <= tr[t].x && tr[t].y <= R) {
    return make_pair(make_pair(tr[t].sum, tr[t].num), tr[t].ans);
  } else {
    pair<pair<long long, long long>, long long> left = tr_query(tr[t].l, L, R);
    pair<pair<long long, long long>, long long> right = tr_query(tr[t].r, L, R);
    long long Sum = (left.first).first + (right.first).first;
    long long Num = (left.first).second + (right.first).second;
    long long Ans = (left.second + right.second) +
                    (right.first).first * (left.first).second -
                    (left.first).first * (right.first).second;
    return make_pair(make_pair(Sum, Num), Ans);
  }
}
int getid(int x) {
  return lower_bound(pp.begin(), pp.end(), x) - pp.begin() + 1;
}
int main() {
  int x;
  Query q;
  while (scanf("%d", &n) != EOF) {
    px.clear();
    for (int i = 0; i != n; i++) {
      scanf("%d", &x);
      px.push_back(x);
    }
    pp = np = px;
    Que.clear();
    scanf("%d", &m);
    for (int i = 0; i != m; i++) {
      q.read();
      Que.push_back(q);
      if (q.t == 1) {
        np[q.x - 1] += q.y;
        pp.push_back(np[q.x - 1]);
      }
    }
    sort(pp.begin(), pp.end());
    pp.erase(unique(pp.begin(), pp.end()), pp.end());
    tot = 0;
    build(1, pp.size());
    for (int i = 0; i != n; i++) {
      change(1, getid(px[i]), 1);
    }
    np = px;
    int L, R;
    for (int i = 0; i != m; i++) {
      if (Que[i].t == 1) {
        change(1, getid(np[Que[i].x - 1]), -1);
        np[Que[i].x - 1] += Que[i].y;
        change(1, getid(np[Que[i].x - 1]), +1);
      } else {
        L = lower_bound(pp.begin(), pp.end(), Que[i].x) - pp.begin() + 1;
        R = upper_bound(pp.begin(), pp.end(), Que[i].y) - pp.begin();
        if (L > R)
          printf("0\n");
        else
          printf("%I64d\n", (tr_query(1, L, R)).second);
      }
    }
  }
  return 0;
}
