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 = 200010;
int dir[4][2] = {1, 0, 0, 1, -1, 0, 0, -1};
vector<int> allx;
struct Seg {
  long long sum[maxn << 2];
  long long ans[maxn << 2];
  int cnt[maxn << 2];
  void pushup(int rt) {
    sum[rt] = sum[rt << 1] + sum[rt << 1 | 1];
    ans[rt] = ans[rt << 1] + ans[rt << 1 | 1] -
              sum[rt << 1] * cnt[rt << 1 | 1] + sum[rt << 1 | 1] * cnt[rt << 1];
    cnt[rt] = cnt[rt << 1] + cnt[rt << 1 | 1];
  }
  void build(int l, int r, int rt) {
    sum[rt] = 0;
    ans[rt] = 0;
    cnt[rt] = 0;
    if (l == r) return;
    int m = l + r >> 1;
    build(l, m, rt << 1);
    build(m + 1, r, rt << 1 | 1);
  }
  void update(int p, int v, int l, int r, int rt) {
    if (l == r) {
      sum[rt] += (long long)allx[p] * v;
      cnt[rt] += v;
      ans[rt] = 0;
      return;
    }
    int m = l + r >> 1;
    if (p <= m)
      update(p, v, l, m, rt << 1);
    else
      update(p, v, m + 1, r, rt << 1 | 1);
    pushup(rt);
  }
  pair<pair<long long, long long>, long long> query(int L, int R, int l, int r,
                                                    int rt) {
    if (L <= l && r <= R) {
      return make_pair(make_pair(ans[rt], sum[rt]), cnt[rt]);
    }
    int m = l + r >> 1;
    long long ret = 0, lsum = 0, rsum = 0, lcnt = 0, rcnt = 0;
    if (L <= m) {
      pair<pair<long long, long long>, long long> pl =
          query(L, R, l, m, rt << 1);
      ret += pl.first.first;
      lsum += pl.first.second;
      lcnt += pl.second;
    }
    if (R > m) {
      pair<pair<long long, long long>, long long> pr =
          query(L, R, m + 1, r, rt << 1 | 1);
      ret += pr.first.first;
      rsum += pr.first.second;
      rcnt += pr.second;
    }
    return make_pair(make_pair(ret - lsum * rcnt + rsum * lcnt, lsum + rsum),
                     lcnt + rcnt);
  }
} seg;
struct query {
  int t, l, r;
} q[maxn];
int n, m, tot;
int num[maxn];
inline int getid(int num) {
  return lower_bound((allx).begin(), (allx).end(), num) - allx.begin();
}
int p[maxn], d[maxn];
int main() {
  int t, l, r, a;
  scanf("%d", &n);
  vector<int> tx, cx;
  for (int i = 0; i < n; i++) {
    scanf("%d", &num[i]);
    allx.push_back(num[i]);
    tx.push_back(num[i]);
  }
  cx = tx;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &q[i].t, &q[i].l, &q[i].r);
    if (q[i].t == 1) {
      int p = q[i].l, d = q[i].r;
      p--;
      tx[p] += d;
      allx.push_back(tx[p]);
    }
  }
  tx = cx;
  sort((allx).begin(), (allx).end());
  allx.erase(unique((allx).begin(), (allx).end()), allx.end());
  tot = allx.size();
  seg.build(0, tot, 1);
  for (int i = 0; i < n; i++) {
    int id = getid(num[i]);
    seg.update(id, 1, 0, tot, 1);
  }
  for (int i = 0; i < m; i++) {
    if (q[i].t == 1) {
      int p = q[i].l, d = q[i].r;
      p--;
      int val = tx[p];
      tx[p] += d;
      int id1 = getid(val);
      int id2 = getid(tx[p]);
      seg.update(id1, -1, 0, tot, 1);
      seg.update(id2, 1, 0, tot, 1);
    } else {
      int l = q[i].l, r = q[i].r;
      l = lower_bound(allx.begin(), allx.end(), q[i].l) - allx.begin();
      r = upper_bound(allx.begin(), allx.end(), q[i].r) - allx.begin();
      r--;
      if (l > r) {
        puts("0");
        continue;
      }
      pair<pair<long long, long long>, long long> ans =
          seg.query(l, r, 0, tot, 1);
      printf("%I64d\n", ans.first.first);
    }
  }
  return 0;
}
