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;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
const int N = 2e5 + 10;
struct node {
  long long dl = 0, dr = 0, di = 0, left = -1, right = -1;
  int num;
};
node seg[4 * N], def;
long long pos[N], arr[N];
bool type[N];
int n, q, first[N], second[N], sz;
vector<long long> cord;
node uqd(node x, node y) {
  node ret;
  if (x.num == 0 && y.num == 0) return ret;
  if (x.num == 0) return y;
  if (y.num == 0) return x;
  ret.num = x.num + y.num;
  ret.left = x.left;
  ret.right = y.right;
  ret.di = x.di + y.di;
  ret.di += y.dl * x.num + (y.left - x.right) * y.num * x.num + x.dr * y.num;
  ret.dl = x.dl + y.dl + y.num * (y.left - x.left);
  ret.dr = y.dr + x.dr + x.num * (y.right - x.right);
  return ret;
}
void upd(int pos, int l = 0, int r = sz, int idx = 1) {
  if (pos < l || r <= pos) return;
  if (r - l < 2) {
    seg[idx].left = cord[pos];
    seg[idx].right = cord[pos];
    seg[idx].num = 1;
    return;
  }
  int mid = (l + r) >> 1;
  upd(pos, l, mid, idx * 2 + 0);
  upd(pos, mid, r, idx * 2 + 1);
  seg[idx] = uqd(seg[idx * 2], seg[idx * 2 + 1]);
}
void clear(int pos, int l = 0, int r = sz, int idx = 1) {
  if (pos < l || r <= pos) return;
  if (r - l < 2) {
    seg[idx] = def;
    return;
  }
  int mid = (l + r) >> 1;
  clear(pos, l, mid, idx * 2 + 0);
  clear(pos, mid, r, idx * 2 + 1);
  seg[idx] = uqd(seg[idx * 2], seg[idx * 2 + 1]);
}
node get(int ql, int qr, int l = 0, int r = sz, int idx = 1) {
  if (r <= ql || qr <= l) return def;
  if (ql <= l && r <= qr) {
    return seg[idx];
  }
  int mid = (l + r) >> 1;
  node ret1 = get(ql, qr, l, mid, idx * 2 + 0);
  node ret2 = get(ql, qr, mid, r, idx * 2 + 1);
  node ret = uqd(ret1, ret2);
  return ret;
}
int MAP(long long x) {
  return int(lower_bound(cord.begin(), cord.end(), x) - cord.begin());
}
int MP(long long x) {
  return int(upper_bound(cord.begin(), cord.end(), x) - cord.begin());
}
void print(int l = 0, int r = sz, int idx = 1) {
  cout << "---" << idx << "---" << endl;
  cout << "lOr : " << l << " " << r << endl;
  cout << "num : " << seg[idx].num << endl;
  cout << "Left : " << seg[idx].left << endl;
  cout << "Right : " << seg[idx].right << endl;
  cout << "DL : " << seg[idx].dl << endl;
  cout << "DR : " << seg[idx].dr << endl;
  cout << "DII : " << seg[idx].di << endl;
  if (r - l < 2) return;
  int mid = (l + r) / 2;
  print(l, mid, idx * 2 + 0);
  print(mid, r, idx * 2 + 1);
}
int main() {
  n = in();
  for (int i = 0; i < n; i++) {
    arr[i] = in();
    pos[i] = arr[i];
    cord.push_back(arr[i]);
  }
  q = in();
  for (int i = 0; i < q; i++) {
    int kind = in();
    kind--;
    type[i] = kind;
    kind = in();
    first[i] = kind;
    kind = in();
    second[i] = kind;
    if (!type[i]) {
      first[i]--;
      pos[first[i]] += second[i];
      cord.push_back(pos[first[i]]);
    }
  }
  sort(cord.begin(), cord.end());
  cord.resize(unique(cord.begin(), cord.end()) - cord.begin());
  sz = (int)cord.size();
  for (int i = 0; i < n; i++) upd(MAP(arr[i]));
  for (int i = 0; i < q; i++) {
    if (type[i]) {
      node gt = get(MAP(first[i]), MP(second[i]));
      cout << gt.di << endl;
      continue;
    }
    clear(MAP(arr[first[i]]));
    arr[first[i]] += second[i];
    upd(MAP(arr[first[i]]));
  }
  return 0;
}
