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 N = 2e5 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-6;
const double PI = acos(-1);
vector<int> oo;
int getPos(int x) {
  return lower_bound(oo.begin(), oo.end(), x) - oo.begin() + 1;
}
int getPosL(int x) {
  return lower_bound(oo.begin(), oo.end(), x) - oo.begin() + 1;
}
int getPosR(int x) { return upper_bound(oo.begin(), oo.end(), x) - oo.begin(); }
namespace SGT {
long long sum[N << 2], cnt[N << 2];
long long lazya[N << 2], lazyb[N << 2], all[N << 2];
inline void push(int rt) {
  if (lazya[rt]) {
    lazya[rt << 1] += lazya[rt];
    lazya[rt << 1 | 1] += lazya[rt];
    all[rt << 1] += cnt[rt << 1] * lazya[rt];
    all[rt << 1 | 1] += cnt[rt << 1 | 1] * lazya[rt];
    lazya[rt] = 0;
  }
  if (lazyb[rt]) {
    lazyb[rt << 1] += lazyb[rt];
    lazyb[rt << 1 | 1] += lazyb[rt];
    all[rt << 1] += sum[rt << 1] * lazyb[rt];
    all[rt << 1 | 1] += sum[rt << 1 | 1] * lazyb[rt];
    lazyb[rt] = 0;
  }
}
inline void pull(int rt) {
  sum[rt] = sum[rt << 1] + sum[rt << 1 | 1];
  cnt[rt] = cnt[rt << 1] + cnt[rt << 1 | 1];
  all[rt] = all[rt << 1] + all[rt << 1 | 1];
}
void modify1(int p, long long val, int l, int r, int rt) {
  if (l == r) {
    cnt[rt] += val;
    sum[rt] += oo[l - 1] * val;
    if (!cnt[rt]) all[rt] = 0;
    return;
  }
  push(rt);
  int mid = l + r >> 1;
  if (p <= mid)
    modify1(p, val, l, mid, rt << 1);
  else
    modify1(p, val, mid + 1, r, rt << 1 | 1);
  pull(rt);
}
void modify2(int L, int R, long long val, int l, int r, int rt) {
  if (L > R) return;
  if (l >= L && r <= R) {
    lazya[rt] += val;
    all[rt] += val * cnt[rt];
    return;
  }
  push(rt);
  int mid = l + r >> 1;
  if (L <= mid) modify2(L, R, val, l, mid, rt << 1);
  if (R > mid) modify2(L, R, val, mid + 1, r, rt << 1 | 1);
  pull(rt);
}
void modify3(int L, int R, long long val, int l, int r, int rt) {
  if (L > R) return;
  if (l >= L && r <= R) {
    lazyb[rt] += val;
    all[rt] += val * sum[rt];
    return;
  }
  push(rt);
  int mid = l + r >> 1;
  if (L <= mid) modify3(L, R, val, l, mid, rt << 1);
  if (R > mid) modify3(L, R, val, mid + 1, r, rt << 1 | 1);
  pull(rt);
}
pair<long long, long long> query1(int L, int R, int l, int r, int rt) {
  if (L > R) return make_pair(0, 0);
  if (l >= L && r <= R) return make_pair(sum[rt], cnt[rt]);
  push(rt);
  int mid = l + r >> 1;
  pair<long long, long long> ans = make_pair(0, 0), tmp = make_pair(0, 0);
  if (L <= mid) {
    tmp = query1(L, R, l, mid, rt << 1);
    ans.first += tmp.first;
    ans.second += tmp.second;
  }
  if (R > mid) {
    tmp = query1(L, R, mid + 1, r, rt << 1 | 1);
    ans.first += tmp.first;
    ans.second += tmp.second;
  }
  return ans;
}
long long query2(int L, int R, int l, int r, int rt) {
  if (L > R) return 0;
  if (l >= L && r <= R) return all[rt];
  push(rt);
  int mid = l + r >> 1;
  long long ans = 0;
  if (L <= mid) ans += query2(L, R, l, mid, rt << 1);
  if (R > mid) ans += query2(L, R, mid + 1, r, rt << 1 | 1);
  return ans;
}
}  // namespace SGT
int n, m, x[N], c[N];
pair<pair<int, int>, int> qus[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x[i]);
    c[i] = x[i];
    oo.push_back(x[i]);
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &qus[i].second, &qus[i].first.first, &qus[i].first.second);
    if (qus[i].second == 1) {
      c[qus[i].first.first] += qus[i].first.second;
      oo.push_back(c[qus[i].first.first]);
    }
  }
  sort(oo.begin(), oo.end());
  oo.erase(unique(oo.begin(), oo.end()), oo.end());
  for (int i = 1; i <= n; i++)
    SGT::modify1(getPos(x[i]), 1, 1, ((int)oo.size()), 1);
  for (int i = 1; i <= n; i++) {
    pair<long long, long long> add =
        SGT::query1(getPos(x[i]), ((int)oo.size()), 1, ((int)oo.size()), 1);
    SGT::modify2(getPos(x[i]), getPos(x[i]), add.first, 1, ((int)oo.size()), 1);
    SGT::modify3(getPos(x[i]), getPos(x[i]), -add.second, 1, ((int)oo.size()),
                 1);
  }
  for (int i = 1; i <= m; i++) {
    if (qus[i].second == 1) {
      int p = qus[i].first.first, d = qus[i].first.second;
      if (d > 0) {
        SGT::modify1(getPos(x[p]), -1, 1, ((int)oo.size()), 1);
        SGT::modify2(1, getPos(x[p]) - 1, d, 1, ((int)oo.size()), 1);
        SGT::modify2(getPos(x[p]) + 1, getPos(x[p] + d) - 1, x[p] + d, 1,
                     ((int)oo.size()), 1);
        SGT::modify3(getPos(x[p]) + 1, getPos(x[p] + d) - 1, -1, 1,
                     ((int)oo.size()), 1);
        x[p] += d;
        SGT::modify1(getPos(x[p]), 1, 1, ((int)oo.size()), 1);
        pair<long long, long long> add =
            SGT::query1(getPos(x[p]), ((int)oo.size()), 1, ((int)oo.size()), 1);
        SGT::modify2(getPos(x[p]), getPos(x[p]), add.first, 1, ((int)oo.size()),
                     1);
        SGT::modify3(getPos(x[p]), getPos(x[p]), -add.second, 1,
                     ((int)oo.size()), 1);
      } else if (d < 0) {
        d = -d;
        SGT::modify1(getPos(x[p]), -1, 1, ((int)oo.size()), 1);
        SGT::modify2(1, getPos(x[p] - d) - 1, -d, 1, ((int)oo.size()), 1);
        SGT::modify2(getPos(x[p] - d) + 1, getPos(x[p]) - 1, -x[p], 1,
                     ((int)oo.size()), 1);
        SGT::modify3(getPos(x[p] - d) + 1, getPos(x[p]) - 1, 1, 1,
                     ((int)oo.size()), 1);
        x[p] -= d;
        SGT::modify1(getPos(x[p]), 1, 1, ((int)oo.size()), 1);
        pair<long long, long long> add =
            SGT::query1(getPos(x[p]), ((int)oo.size()), 1, ((int)oo.size()), 1);
        SGT::modify2(getPos(x[p]), getPos(x[p]), add.first, 1, ((int)oo.size()),
                     1);
        SGT::modify3(getPos(x[p]), getPos(x[p]), -add.second, 1,
                     ((int)oo.size()), 1);
      }
    } else {
      int L = qus[i].first.first, R = qus[i].first.second;
      L = getPosL(L);
      R = getPosR(R);
      long long ans = SGT::query2(L, R, 1, ((int)oo.size()), 1);
      pair<long long, long long> tmpL =
          SGT::query1(L, R, 1, ((int)oo.size()), 1);
      pair<long long, long long> tmpR =
          SGT::query1(R + 1, ((int)oo.size()), 1, ((int)oo.size()), 1);
      ans -= tmpL.second * tmpR.first;
      ans += tmpL.first * tmpR.second;
      printf("%lld\n", ans);
    }
  }
  return 0;
}
