#include <bits/stdc++.h>
using namespace std;
const int mx = 2e5 + 10;
vector<int> v;
vector<int>::iterator it;
long long cnt[4 * mx], ltor[4 * mx], rtol[4 * mx], fen[mx], remain, cntnow,
    a[mx], b[mx], q[mx], ps[mx], val[mx], l[mx], r[mx];
int pos(int x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); }
void updsum(int x, int ty) {
  int p = pos(x) + 1;
  for (; p < mx; p += p & -p) fen[p] += x * ty;
}
long long get(int p) {
  p++;
  long long ans = 0;
  for (; p > 0; p -= p & -p) ans += fen[p];
  return ans;
}
void upd(int p, int ty, int l = 0, int r = v.size(), int id = 1) {
  if (r - l < 2) {
    cnt[id] += ty;
    return;
  }
  int mid = (l + r) >> 1;
  if (p < mid)
    upd(p, ty, l, mid, id << 1);
  else
    upd(p, ty, mid, r, id << 1 | 1);
  cnt[id] = cnt[id << 1] + cnt[id << 1 | 1];
  long long suml = get(mid - 1) - get(l - 1), sumr = get(r - 1) - get(mid - 1);
  ltor[id] = ltor[id << 1] + ltor[id << 1 | 1] + cnt[id << 1] * sumr;
  rtol[id] = rtol[id << 1] + rtol[id << 1 | 1] + cnt[id << 1 | 1] * suml;
}
long long cntseg(int lq, int rq, int l = 0, int r = v.size(), int id = 1) {
  if (l >= rq || r <= lq) return 0;
  if (lq <= l && r <= rq) {
    return cnt[id];
  }
  int mid = (l + r) >> 1;
  return cntseg(lq, rq, l, mid, id << 1) + cntseg(lq, rq, mid, r, id << 1 | 1);
}
long long getseg(int lq, int rq, int l = 0, int r = v.size(), int id = 1) {
  if (l >= rq || r <= lq) return 0;
  if (lq <= l && r <= rq) {
    long long sumlr = get(r - 1) - get(l - 1);
    remain -= cnt[id];
    long long ans = ltor[id] + sumlr * cntnow - rtol[id] - sumlr * remain;
    cntnow += cnt[id];
    return ans;
  }
  int mid = (l + r) >> 1;
  return getseg(lq, rq, l, mid, id << 1) + getseg(lq, rq, mid, r, id << 1 | 1);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
    v.push_back(a[i]);
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> q[i] >> ps[i] >> val[i];
    int pn = ps[i] - 1;
    if (q[i] == 1) {
      ps[i]--;
      b[pn] += val[i];
      v.push_back(b[pn]);
    } else
      l[i] = ps[i], r[i] = val[i];
  }
  sort(v.begin(), v.end());
  it = unique(v.begin(), v.end());
  v.resize(distance(v.begin(), it));
  for (int i = 0; i < n; i++) {
    updsum(a[i], 1);
    upd(pos(a[i]), 1);
  }
  for (int i = 0; i < m; i++) {
    if (q[i] == 1) {
      int pn = ps[i];
      updsum(a[pn], -1), upd(pos(a[pn]), -1);
      a[pn] += val[i];
      updsum(a[pn], 1), upd(pos(a[pn]), 1);
    } else {
      int p1 = pos(l[i]), p2 = pos(r[i]);
      p2 -= (r[i] < v[p2]);
      cntnow = 0, remain = cntseg(p1, p2 + 1);
      cout << getseg(p1, p2 + 1) << endl;
    }
  }
}
