#include <bits/stdc++.h>
const int oo = 1073741819;
using namespace std;
long long a[2000000], size[2000000], cnt[2000000], b[2000000];
long long sum[2000000], tot[2000000];
int ss, n, m, l[2000000], r[2000000], ls[2000000], rs[2000000], ll, rr, lr, rl,
    mid;
void updata(int mid) {
  sum[mid] = sum[l[mid]] + sum[r[mid]] + tot[r[mid]] * cnt[l[mid]] -
             tot[l[mid]] * cnt[r[mid]] +
             (tot[r[mid]] - a[mid] * cnt[r[mid]] + a[mid] * cnt[l[mid]] -
              tot[l[mid]]) *
                 size[mid];
  tot[mid] = a[mid] * size[mid] + tot[l[mid]] + tot[r[mid]];
  cnt[mid] = size[mid] + cnt[l[mid]] + cnt[r[mid]];
}
void ori(int mid, int w, int e) { a[mid] = w, size[mid] += e; }
int build(int L, int R) {
  int mid = (L + R) >> 1;
  if (L <= mid - 1) l[mid] = build(L, mid - 1);
  if (mid + 1 <= R) r[mid] = build(mid + 1, R);
  ori(mid, a[mid], 1), updata(mid);
  return mid;
}
int left(int x, int y) {
  r[y] = l[x], l[x] = y;
  updata(y);
  return x;
}
int right(int x, int y) {
  l[y] = r[x], r[x] = y;
  updata(y);
  return x;
}
void lconnect(int x) {
  if (!ll)
    ll = lr = ls[++ls[0]] = x;
  else
    r[lr] = ls[++ls[0]] = x, lr = x;
}
void rconnect(int x) {
  if (!rr)
    rr = rl = rs[++rs[0]] = x;
  else
    l[rl] = rs[++rs[0]] = x, rl = x;
}
void splay(int &mid, int x) {
  ll = rr = lr = rl = ls[0] = rs[0] = 0;
  for (int y; mid && a[mid] != x;) {
    if (a[mid] < x) {
      if (r[mid] && a[r[mid]] < x) mid = left(r[mid], mid);
      lconnect(mid);
      y = r[mid], r[mid] = 0, mid = y;
    } else if (x < a[mid]) {
      if (l[mid] && x < a[l[mid]]) mid = right(l[mid], mid);
      rconnect(mid);
      y = l[mid], l[mid] = 0, mid = y;
    }
  }
  if (!mid) mid = ++ss;
  ori(mid, x, 1);
  if (l[mid]) lconnect(l[mid]);
  if (r[mid]) rconnect(r[mid]);
  for (int i = ls[0]; i >= 1; i--) updata(ls[i]);
  for (int i = rs[0]; i >= 1; i--) updata(rs[i]);
  l[mid] = ll, r[mid] = rr, updata(mid);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    b[i] = a[i];
  }
  a[n + 1] = -oo, a[n + 2] = oo;
  sort(a + 1, a + n + 2 + 1);
  mid = build(1, n + 2);
  ss = n + 2;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int t, x, y;
    scanf("%d%d%d\n", &t, &x, &y);
    if (1 == t) {
      splay(mid, b[x]);
      size[mid] -= 2, updata(mid);
      b[x] += y;
      splay(mid, b[x]);
    } else {
      splay(mid, y + 1);
      size[mid]--, updata(mid);
      splay(l[mid], x - 1);
      size[l[mid]]--, updata(l[mid]);
      long long ans = sum[r[l[mid]]];
      printf("%I64d\n", ans);
    }
  }
  return 0;
}
