#include <bits/stdc++.h>
using namespace std;
int n;
long long inf = 199912310;
int root;
struct node {
  int lc, rc;
  long long val;
  long long sum;
  long long res;
  int sz;
} a[200005];
int b[200005];
int tot;
int L, R;
void update(int x) {
  a[x].sz = a[a[x].lc].sz + a[a[x].rc].sz + 1;
  a[x].sum = a[a[x].lc].sum + a[a[x].rc].sum + a[x].val;
  a[x].sz = a[x].sz;
  a[x].res = a[a[x].lc].res + a[a[x].rc].res +
             1ll * a[a[x].lc].sz * a[a[x].rc].sum -
             1ll * a[a[x].rc].sz * a[a[x].lc].sum;
  a[x].res += 1ll * a[x].val * a[a[x].lc].sz - a[a[x].lc].sum;
  a[x].res += a[a[x].rc].sum - 1ll * a[x].val * a[a[x].rc].sz;
}
int merge(int x, int y) {
  if (!x || !y) return x + y;
  int t = rand() % (a[x].sz + a[y].sz);
  if (t < a[x].sz) {
    a[x].rc = merge(a[x].rc, y);
    update(x);
    return x;
  } else {
    a[y].lc = merge(x, a[y].lc);
    update(y);
    return y;
  }
}
void split(int x, int ge) {
  if (!x) {
    L = 0;
    R = 0;
    return;
  }
  if (a[a[x].lc].sz >= ge) {
    split(a[x].lc, ge);
    a[x].lc = R;
    R = x;
  } else {
    split(a[x].rc, ge - a[a[x].lc].sz - 1);
    a[x].rc = L;
    L = x;
  }
  update(x);
}
int getrank(int x, int val) {
  if (!x) return 0;
  if (a[x].val > val) return getrank(a[x].lc, val);
  if (a[x].val == val) return a[a[x].lc].sz + 1;
  if (a[x].val < val) return a[a[x].lc].sz + 1 + getrank(a[x].rc, val);
}
void print(int x) {
  if (!x) return;
  print(a[x].lc);
  print(a[x].rc);
}
int main() {
  inf *= inf;
  srand(233);
  scanf("%d", &n);
  a[++tot].val = -inf;
  a[++tot].val = inf;
  a[1].val = -inf;
  a[1].sz = 1;
  a[2].val = inf;
  a[2].sz = 1;
  a[1].sz = 1;
  a[2].sz = 1;
  root = merge(1, 2);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    b[i] = x;
    a[++tot].val = x;
    a[tot].sz = x;
    a[tot].sum = x;
    a[tot].sz = 1;
    int p = getrank(root, x);
    L = 0;
    R = 0;
    split(root, p);
    root = merge(L, tot);
    root = merge(root, R);
  }
  int Q;
  scanf("%d", &Q);
  while (Q--) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      int p, val;
      scanf("%d%d", &p, &val);
      int t = getrank(root, b[p]);
      L = 0;
      R = 0;
      split(root, t);
      int rr = R;
      split(L, t - 1);
      int ll = L;
      L = 0;
      R = 0;
      root = merge(ll, rr);
      b[p] += val;
      t = getrank(root, b[p]);
      p += 2;
      a[p].lc = a[p].rc = 0;
      a[p].sz = 1;
      a[p].res = 0;
      a[p].sz = 1;
      a[p].val = b[p - 2];
      a[p].sz = 1;
      a[p].sum = a[p].val;
      L = 0;
      R = 0;
      split(root, t);
      root = merge(L, p);
      root = merge(root, R);
    } else {
      int l, r;
      scanf("%d%d", &l, &r);
      int p = getrank(root, l - 1) + 1, q = getrank(root, r);
      split(root, q);
      int rr = R;
      split(L, p - 1);
      printf("%I64d\n", a[R].res);
      root = merge(L, R);
      root = merge(root, rr);
    }
  }
  return 0;
}
