#include <bits/stdc++.h>
using namespace std;
struct Node {
  int st, ed, left, right, cnt;
  long long lsum, rsum, sum;
  Node(){};
  Node(int s, int e) {
    st = s;
    ed = e;
    left = right = -1;
    cnt = 0;
    lsum = rsum = sum = 0;
  }
};
int K, a[200010], x[200010], l[200010], r[200010], t[200010], vst[200010],
    pos[200010];
Node nodes[3 * 200010];
void update(int u, int st, int dir) {
  if (nodes[u].ed < st) return;
  if (nodes[u].st > st) return;
  if (nodes[u].st == st && nodes[u].ed == st) {
    nodes[u].cnt += dir;
    return;
  }
  int lt = nodes[u].left;
  int rt = nodes[u].right;
  update(lt, st, dir);
  update(rt, st, dir);
  nodes[u].cnt = nodes[lt].cnt + nodes[rt].cnt;
  nodes[u].lsum =
      nodes[lt].lsum + nodes[rt].lsum +
      (long long)(x[nodes[rt].st] - x[nodes[lt].st]) * nodes[rt].cnt;
  nodes[u].rsum =
      nodes[lt].rsum + nodes[rt].rsum +
      (long long)(x[nodes[rt].ed] - x[nodes[lt].ed]) * nodes[lt].cnt;
  nodes[u].sum = nodes[lt].sum + nodes[rt].sum +
                 (long long)(x[nodes[rt].st] - x[nodes[lt].ed]) *
                     nodes[lt].cnt * nodes[rt].cnt +
                 nodes[lt].rsum * nodes[rt].cnt +
                 nodes[rt].lsum * nodes[lt].cnt;
}
void calc(int u, int &st, int &ed, int &ct, long long &ls, long long &rs,
          long long &s) {
  int i, lt, rt;
  ct = ls = rs = s = 0;
  st = max(st, nodes[u].st);
  ed = min(ed, nodes[u].ed);
  if (st > ed) return;
  if (nodes[u].st == st && nodes[u].ed == ed) {
    ct = nodes[u].cnt;
    ls = nodes[u].lsum;
    rs = nodes[u].rsum;
    s = nodes[u].sum;
    return;
  }
  int st1, st2, ed1, ed2, ct1, ct2;
  long long ls1, ls2, rs1, rs2, s1, s2;
  st1 = st2 = st;
  ed1 = ed2 = ed;
  calc(nodes[u].left, st1, ed1, ct1, ls1, rs1, s1);
  calc(nodes[u].right, st2, ed2, ct2, ls2, rs2, s2);
  ct = ct1 + ct2;
  ls = ls1 + ls2 + (long long)(x[st2] - x[st1]) * ct2;
  rs = rs1 + rs2 + (long long)(x[ed2] - x[ed1]) * ct1;
  s = s1 + s2 + (long long)(x[st2] - x[ed1]) * ct1 * ct2 + rs1 * ct2 +
      ls2 * ct1;
}
int build(int st, int ed) {
  int md, i, lt, rt, cur = K++;
  long long tmp;
  nodes[cur] = Node(st, ed);
  if (st == ed) {
    if (vst[st]) nodes[cur].cnt = 1;
    return cur;
  }
  md = (st + ed) / 2;
  lt = nodes[cur].left = build(st, md);
  rt = nodes[cur].right = build(md + 1, ed);
  nodes[cur].cnt = nodes[lt].cnt + nodes[rt].cnt;
  nodes[cur].lsum =
      nodes[lt].lsum + nodes[rt].lsum +
      (long long)(x[nodes[rt].st] - x[nodes[lt].st]) * nodes[rt].cnt;
  nodes[cur].rsum =
      nodes[lt].rsum + nodes[rt].rsum +
      (long long)(x[nodes[rt].ed] - x[nodes[lt].ed]) * nodes[lt].cnt;
  nodes[cur].sum = nodes[lt].sum + nodes[rt].sum +
                   (long long)(x[nodes[rt].st] - x[nodes[lt].ed]) *
                       nodes[lt].cnt * nodes[rt].cnt +
                   nodes[lt].rsum * nodes[rt].cnt +
                   nodes[rt].lsum * nodes[lt].cnt;
  return cur;
}
int main() {
  int i, u, v, Q, N, n, cnt;
  long long lsum, rsum, sum;
  scanf("%d ", &N);
  n = 0;
  for (i = 0; i < N; i++) scanf("%d ", &a[i]), x[n++] = pos[i] = a[i];
  scanf("%d ", &Q);
  for (i = 0; i < Q; i++) {
    scanf("%d %d %d ", &t[i], &l[i], &r[i]);
    if (t[i] == 1) {
      u = l[i] - 1;
      x[n++] = pos[u] = pos[u] + r[i];
    }
  }
  sort(x, x + n);
  n = unique(x, x + n) - x;
  memset(vst, 0, sizeof(vst));
  for (i = 0; i < N; i++) vst[a[i] = lower_bound(x, x + n, a[i]) - x] = 1;
  for (i = 0; i < Q; i++) {
    if (t[i] == 1) {
      u = l[i] - 1;
      l[i] = a[u];
      r[i] = a[u] = lower_bound(x, x + n, x[a[u]] + r[i]) - x;
    } else {
      l[i] = lower_bound(x, x + n, l[i]) - x;
      r[i] = upper_bound(x, x + n, r[i]) - x - 1;
    }
  }
  K = 0;
  build(0, n - 1);
  for (i = 0; i < Q; i++) {
    if (t[i] == 1)
      update(0, l[i], -1), update(0, r[i], 1);
    else {
      calc(0, l[i], r[i], cnt, lsum, rsum, sum);
      printf("%I64d\n", sum);
    }
  }
  return 0;
}
