#include <bits/stdc++.h>
using namespace std;
const int N = 200000;
struct node {
  long long ans, sum;
  int cnt;
} tree[2 * N - 1];
int inline getidx(int s, int t) { return s + t | s != t; }
void Operate(int l, int r, int idx, int v, int sign) {
  int nowidx = getidx(l, r);
  if (l == r) {
    tree[nowidx].cnt += sign;
    tree[nowidx].sum += v * sign;
    return;
  }
  int mid = l + r >> 1;
  int lch = getidx(l, mid), rch = getidx(mid + 1, r);
  if (idx <= mid)
    Operate(l, mid, idx, v, sign);
  else
    Operate(mid + 1, r, idx, v, sign);
  tree[nowidx].sum = tree[lch].sum + tree[rch].sum;
  tree[nowidx].cnt = tree[lch].cnt + tree[rch].cnt;
  tree[nowidx].ans = tree[lch].ans + tree[rch].ans -
                     tree[lch].sum * tree[rch].cnt +
                     tree[rch].sum * tree[lch].cnt;
}
void Build(int l, int r) {
  if (l == r) return;
  int nowidx = getidx(l, r);
  int mid = l + r >> 1;
  int lch = getidx(l, mid), rch = getidx(mid + 1, r);
  Build(l, mid);
  Build(mid + 1, r);
  tree[nowidx].sum = tree[lch].sum + tree[rch].sum;
  tree[nowidx].cnt = tree[lch].cnt + tree[rch].cnt;
  tree[nowidx].ans = tree[lch].ans + tree[rch].ans -
                     tree[lch].sum * tree[rch].cnt +
                     tree[rch].sum * tree[lch].cnt;
}
node Query(int l, int r, int s, int t) {
  int nowidx = getidx(l, r);
  if (l == s && r == t) return tree[nowidx];
  int mid = l + r >> 1;
  int lch = getidx(l, mid), rch = getidx(mid + 1, r);
  if (s <= mid) {
    if (t <= mid) return Query(l, mid, s, t);
    node res1 = Query(l, mid, s, mid);
    node res2 = Query(mid + 1, r, mid + 1, t);
    res1.ans += res2.ans - res1.sum * res2.cnt + res2.sum * res1.cnt;
    res1.sum += res2.sum;
    res1.cnt += res2.cnt;
    return res1;
  }
  return Query(mid + 1, r, s, t);
}
set<int> S;
int x[100000], xx[100000];
struct Q {
  int t, l, r;
} q[100000];
int main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", x + i);
    S.insert(x[i]);
    xx[i] = x[i];
  }
  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 id = q[i].l - 1;
      q[i].l = x[id];
      x[id] += q[i].r;
      q[i].r = x[id];
      S.insert(q[i].r);
    }
  }
  int _n = n;
  n = S.size();
  vector<int> SS(S.begin(), S.end());
  for (int i = 0; i < _n; i++) {
    int idx = lower_bound(SS.begin(), SS.end(), xx[i]) - SS.begin();
    int nowidx = getidx(idx, idx);
    tree[nowidx].ans = 0;
    tree[nowidx].cnt = 1;
    tree[nowidx].sum = xx[i];
  }
  Build(0, n - 1);
  for (int i = 0; i < m; i++) {
    if (q[i].t == 1) {
      int lid = lower_bound(SS.begin(), SS.end(), q[i].l) - SS.begin();
      int rid = lower_bound(SS.begin(), SS.end(), q[i].r) - SS.begin();
      Operate(0, n - 1, lid, q[i].l, -1);
      Operate(0, n - 1, rid, q[i].r, 1);
    } else {
      int lid = lower_bound(SS.begin(), SS.end(), q[i].l) - SS.begin();
      int rid = upper_bound(SS.begin(), SS.end(), q[i].r) - SS.begin() - 1;
      if (lid > rid) {
        puts("0");
        continue;
      }
      printf("%I64d\n", Query(0, n - 1, lid, rid).ans);
    }
  }
}
