#include <bits/stdc++.h>
using namespace std;
class S {
 public:
  long long qtd;
  long long sumd, sume, sum;
  S(long long a = 0, long long b = 0, long long c = 0, long long d = 0)
      : qtd(a), sume(b), sumd(c), sum(d) {}
};
long long ar[200100];
int ti[200100], v1[200100], v2[200100];
long long x[200100], x2[200100];
long long qtd[800100];
long long sum[800100], sumd[800100], sume[800100];
void add(int no, int l1, int l2, int p, int v) {
  if (l1 == l2) {
    qtd[no] = v;
  } else {
    int lim = (l1 + l2) / 2, f1 = no << 1, f2 = (no << 1) + 1;
    if (p <= lim)
      add(f1, l1, lim, p, v);
    else
      add(f2, lim + 1, l2, p, v);
    qtd[no] = qtd[f1] + qtd[f2];
    sume[no] = sume[f1] + sume[f2] + qtd[f2] * (ar[lim + 1] - ar[l1]);
    sumd[no] = sumd[f1] + sumd[f2] + qtd[f1] * (ar[l2] - ar[lim]);
    sum[no] = sum[f1] + sum[f2] + sumd[f1] * qtd[f2] + sume[f2] * qtd[f1] +
              qtd[f1] * qtd[f2] * (ar[lim + 1] - ar[lim]);
  }
}
S get(int no, int l1, int l2, int a, int b) {
  S s;
  if (b < l1 || a > l2) return s;
  if (a <= l1 && b >= l2) {
    s = S(qtd[no], sume[no], sumd[no], sum[no]);
  } else {
    int lim = (l1 + l2) / 2, f1 = no << 1, f2 = (no << 1) + 1;
    S s1, s2;
    if (a <= lim) s1 = get(f1, l1, lim, a, b);
    if (b >= lim + 1) s2 = get(f2, lim + 1, l2, a, b);
    s.qtd = s1.qtd + s2.qtd;
    s.sume = s1.sume + s2.sume + s2.qtd * (ar[lim + 1] - ar[l1]);
    s.sumd = s1.sumd + s2.sumd + s1.qtd * (ar[l2] - ar[lim]);
    s.sum = s1.sum + s2.sum + s1.sumd * s2.qtd + s2.sume * s1.qtd +
            s1.qtd * s2.qtd * (ar[lim + 1] - ar[lim]);
  }
  return s;
}
int main() {
  int n;
  int cnt = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i], ar[cnt++] = x[i], x2[i] = x[i];
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> ti[i] >> v1[i] >> v2[i];
    if (ti[i] == 1) {
      v1[i]--;
      x2[v1[i]] += v2[i];
      ar[cnt++] = x2[v1[i]];
    }
  }
  sort(ar, ar + cnt);
  cnt = unique(ar, ar + cnt) - ar;
  int root = 1, l1 = 0, l2 = cnt - 1;
  for (int i = 0; i < n; i++) {
    add(root, l1, l2, lower_bound(ar, ar + cnt, x[i]) - ar, 1);
  }
  for (int i = 0; i < q; i++) {
    if (ti[i] == 1) {
      long long a = x[v1[i]];
      x[v1[i]] += v2[i];
      long long b = x[v1[i]];
      add(root, l1, l2, lower_bound(ar, ar + cnt, a) - ar, 0);
      add(root, l1, l2, lower_bound(ar, ar + cnt, b) - ar, 1);
    } else {
      int a = lower_bound(ar, ar + cnt, v1[i]) - ar;
      int b = upper_bound(ar, ar + cnt, v2[i]) - ar - 1;
      if (a <= b)
        cout << get(root, l1, l2, a, b).sum;
      else
        cout << 0;
      cout << endl;
    }
  }
  return 0;
}
