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>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
using namespace std;
namespace ywy {
inline int get() {
  int n = 0;
  char c;
  while ((c = getchar()) || 23333) {
    if (c >= '0' && c <= '9') break;
    if (c == '-') goto s;
  }
  n = c - '0';
  while ((c = getchar()) || 23333) {
    if (c >= '0' && c <= '9')
      n = n * 10 + c - '0';
    else
      return (n);
  }
s:
  while ((c = getchar()) || 23333) {
    if (c >= '0' && c <= '9')
      n = n * 10 - c + '0';
    else
      return (n);
  }
}
void print(long long num) {
  if (num >= 10) print(num / 10);
  putchar(num % 10 + '0');
}
typedef struct _n {
  long long lsum, lsum2, sigl;
  _n() {
    lsum = 0;
    lsum2 = 0;
    sigl = 0;
  }
  friend _n operator+(const _n &a, const _n &b) {
    _n c;
    c.sigl = a.sigl + b.sigl;
    c.lsum = a.lsum + b.lsum;
    c.lsum2 = a.lsum2 + b.lsum2;
    return (c);
  }
  inline void add(long long k) {
    lsum2 = lsum2 + k * k * sigl + 2 * k * lsum;
    lsum += sigl * k;
  }
} node;
node data[2000001];
int adds[2000001];
long long lsh[500001];
inline void down(int tree) {
  if (!adds[tree]) return;
  adds[(tree << 1)] += adds[tree];
  adds[((tree << 1) | 1)] += adds[tree];
  data[(tree << 1)].add(adds[tree]);
  data[((tree << 1) | 1)].add(adds[tree]);
  adds[tree] = 0;
}
node query(int rl, int rr, int l, int r, int tree) {
  if (rl > rr) return (_n());
  if (rl == l && rr == r) return (data[tree]);
  int mid = (l + r) >> 1;
  down(tree);
  if (rl > mid) return (query(rl, rr, mid + 1, r, ((tree << 1) | 1)));
  if (rr <= mid) return (query(rl, rr, l, mid, (tree << 1)));
  return (query(rl, mid, l, mid, (tree << 1)) +
          query(mid + 1, rr, mid + 1, r, ((tree << 1) | 1)));
}
void add(int rl, int rr, int l, int r, int tree, int x) {
  if (rl > rr) return;
  if (rl == l && rr == r) {
    adds[tree] += x;
    data[tree].add(x);
    return;
  }
  int mid = (l + r) >> 1;
  down(tree);
  if (rl > mid)
    add(rl, rr, mid + 1, r, ((tree << 1) | 1), x);
  else {
    if (rr <= mid)
      add(rl, rr, l, mid, (tree << 1), x);
    else {
      add(rl, mid, l, mid, (tree << 1), x);
      add(mid + 1, rr, mid + 1, r, ((tree << 1) | 1), x);
    }
  }
  data[tree] = data[(tree << 1)] + data[((tree << 1) | 1)];
}
int op[200001], a[200001], b[200001], pos[200001], sums[500001];
long long tpos[200001];
void build(int l, int r, int tree) {
  if (l == r) {
    data[tree].sigl = lsh[l + 1] - lsh[l];
    data[tree].lsum = sums[l] * (lsh[l + 1] - lsh[l]);
    data[tree].lsum2 = sums[l] * (long long)sums[l] * (lsh[l + 1] - lsh[l]);
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, (tree << 1));
  build(mid + 1, r, ((tree << 1) | 1));
  data[tree] = data[(tree << 1)] + data[((tree << 1) | 1)];
}
void ywymain() {
  int n = get(), ptr = 1;
  for (register int i = 1; i <= n; i++)
    pos[i] = tpos[i] = lsh[ptr] = get(), ptr++;
  int q = get();
  for (register int i = 1; i <= q; i++) {
    op[i] = get();
    a[i] = get();
    b[i] = get();
    if (op[i] == 1) {
      tpos[a[i]] += b[i];
      lsh[ptr] = tpos[a[i]];
      ptr++;
    } else {
      lsh[ptr] = a[i];
      ptr++;
      lsh[ptr] = b[i];
      ptr++;
    }
  }
  lsh[ptr] = -12345678900;
  ptr++;
  lsh[ptr] = 12345678900;
  sort(lsh + 1, lsh + 1 + ptr);
  ptr = unique(lsh + 1, lsh + 1 + ptr) - lsh - 1;
  for (register int i = 1; i <= n; i++)
    pos[i] = lower_bound(lsh + 1, lsh + 1 + ptr, pos[i]) - lsh, sums[pos[i]]++;
  for (register int i = 1; i <= ptr; i++) sums[i] += sums[i - 1];
  build(1, ptr, 1);
  for (register int i = 1; i <= q; i++) {
    if (op[i] == 1) {
      add(pos[a[i]], ptr, 1, ptr, 1, -1);
      pos[a[i]] =
          lower_bound(lsh + 1, lsh + 1 + ptr, lsh[pos[a[i]]] + b[i]) - lsh;
      add(pos[a[i]], ptr, 1, ptr, 1, 1);
    } else {
      if (a[i] == b[i]) {
        cout << 0 << endl;
        continue;
      }
      int l = lower_bound(lsh + 1, lsh + 1 + ptr, a[i]) - lsh,
          r = lower_bound(lsh + 1, lsh + 1 + ptr, b[i]) - lsh - 1;
      node cjr = query(l, r, 1, ptr, 1), dl = query(l - 1, l - 1, 1, ptr, 1),
           dr = query(r + 1, r + 1, 1, ptr, 1);
      long long ans = n * cjr.lsum - cjr.lsum2;
      long long lgdt = 0, rgdt = n;
      if (dl.sigl && dl.lsum) lgdt = dl.lsum / dl.sigl;
      if (dr.sigl && r + 1 != ptr) rgdt = n - dr.lsum / dr.sigl;
      ans -= lgdt * rgdt * (b[i] - a[i]);
      ans -= cjr.lsum * rgdt;
      ans -= n * lgdt * cjr.sigl;
      ans += lgdt * rgdt * cjr.sigl * 2;
      ans += cjr.lsum * lgdt;
      print(ans);
      putchar('\n');
    }
  }
}
}  // namespace ywy
int main() {
  ywy::ywymain();
  return (0);
}
