#include <bits/stdc++.h>
const int maxn = 100000 + 10;
int x[maxn], px[maxn << 1], tot;
int t[maxn], p[maxn], d[maxn];
using namespace std;
struct node {
  int l, r;
  long long cnt, sum, ans;
  node(long long _cnt = 0, long long _sum = 0, long long _ans = 0)
      : cnt(_cnt), sum(_sum), ans(_ans) {}
  node operator+(node &a) {
    return node(cnt + a.cnt, sum + a.sum,
                ans + a.ans - sum * a.cnt + a.sum * cnt);
  }
};
struct node2 {
  int l, r;
};
struct segtree {
  node2 seg[maxn << 3];
  node seg2[maxn << 3];
  void build(int o, int l, int r) {
    seg[o].l = l, seg[o].r = r;
    if (l == r) return;
    int m = (l + r) >> 1;
    build(o << 1, l, m);
    build(o << 1 | 1, m + 1, r);
  }
  void update(int o, int sgn, int v, int k) {
    if (seg[o].l == seg[o].r) {
      seg2[o].cnt += sgn;
      seg2[o].sum += sgn * v;
      return;
    }
    int m = (seg[o].l + seg[o].r) >> 1;
    if (k <= m)
      update(o << 1, sgn, v, k);
    else
      update(o << 1 | 1, sgn, v, k);
    seg2[o] = seg2[o << 1] + seg2[o << 1 | 1];
  }
  node query(int o, int l, int r) {
    if (l > r) return node(0, 0, 0);
    if (l <= seg[o].l && seg[o].r <= r) return seg2[o];
    int m = (seg[o].l + seg[o].r) >> 1;
    if (r <= m) return query(o << 1, l, r);
    if (l > m) return query(o << 1 | 1, l, r);
    node A = query(o << 1, l, r), B = query(o << 1 | 1, l, r);
    return A + B;
  }
} tree;
int main() {
  int n, m;
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%d", &x[i]);
      px[tot++] = x[i];
    }
    scanf("%d", &m);
    for (int i = 0; i < m; i++) {
      scanf("%d%d%d", &t[i], &p[i], &d[i]);
      if (t[i] == 1) px[tot++] = (x[--p[i]] += d[i]);
    }
    for (int i = 0; i < m; i++)
      if (t[i] == 1) x[p[i]] -= d[i];
    sort(px, px + tot);
    tot = unique(px, px + tot) - px;
    tree.build(1, 0, tot - 1);
    for (int i = 0; i < n; i++) {
      tree.update(1, 1, x[i], (lower_bound(px, px + tot, (x[i])) - px));
    }
    for (int i = 0; i < m; i++) {
      if (t[i] == 1) {
        tree.update(1, -1, x[p[i]],
                    (lower_bound(px, px + tot, (x[p[i]])) - px));
        x[p[i]] += d[i];
        tree.update(1, 1, x[p[i]], (lower_bound(px, px + tot, (x[p[i]])) - px));
      } else {
        node temp = tree.query(1, (lower_bound(px, px + tot, (p[i])) - px),
                               (upper_bound(px, px + tot, (d[i])) - px) - 1);
        printf("%I64d\n", temp.ans);
      }
    }
  }
}
