#include <bits/stdc++.h>
using namespace std;
const long long int M = 3e5 + 5, LG = 48, inf = 1e9, mod = 95542721;
long long int n;
long long int seg[3 * M];
long long int sum[3 * M];
long long int ted[3 * M];
long long int pos[M];
long long int x[M];
bool ex[M];
long long int pt = 0;
long long int qt[M], ql[M], qr[M];
long long int q;
void build(long long int l = 0, long long int r = pt, long long int id = 1) {
  if (l + 1 == r) {
    ted[id] = ex[l];
    sum[id] = ex[l] * pos[l];
    seg[id] = 0;
    return;
  }
  long long int mid = (l + r) >> 1;
  long long int d = 2 * id, f = 2 * id + 1;
  build(l, mid, d);
  build(mid, r, f);
  ted[id] = ted[d] + ted[f];
  sum[id] = sum[d] + sum[f];
  seg[id] = seg[d] + seg[f] + sum[f] * ted[d] - sum[d] * ted[f];
}
void upd(long long int p, long long int l = 0, long long int r = pt,
         long long int id = 1) {
  if (l + 1 == r) {
    ted[id] = ex[l];
    sum[id] = ex[l] * pos[l];
    seg[id] = 0;
    return;
  }
  long long int mid = (l + r) >> 1;
  long long int d = 2 * id, f = 2 * id + 1;
  if (mid > p)
    upd(p, l, mid, d);
  else
    upd(p, mid, r, f);
  ted[id] = ted[d] + ted[f];
  sum[id] = sum[d] + sum[f];
  seg[id] = seg[d] + seg[f] + sum[f] * ted[d] - sum[d] * ted[f];
}
pair<long long int, pair<long long int, long long int> > get(
    long long int x, long long int y, long long int l = 0, long long int r = pt,
    long long int id = 1) {
  if (x <= l && r <= y) {
    return {seg[id], {ted[id], sum[id]}};
  }
  if (y <= l || r <= x) return {0, {0, 0}};
  long long int mid = (l + r) >> 1;
  pair<long long int, pair<long long int, long long int> > res;
  pair<long long int, pair<long long int, long long int> > d =
      get(x, y, l, mid, 2 * id);
  pair<long long int, pair<long long int, long long int> > f =
      get(x, y, mid, r, 2 * id + 1);
  res.second.first = f.second.first + d.second.first;
  res.second.second = f.second.second + d.second.second;
  res.first = f.first + d.first + f.second.second * d.second.first -
              f.second.first * d.second.second;
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    pos[pt++] = x[i];
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> qt[i] >> ql[i] >> qr[i];
    if (qt[i] == 1) {
      ql[i]--;
      x[ql[i]] += qr[i];
      pos[pt++] = x[ql[i]];
    }
  }
  sort(pos, pos + pt);
  pt = unique(pos, pos + pt) - pos;
  for (int i = 0; i < q; i++)
    if (qt[i] == 1) x[ql[i]] -= qr[i];
  for (int i = 0; i < n; i++) {
    ex[(lower_bound(pos, (pos) + (pt), x[i]) - (pos))] = 1;
  }
  build();
  for (int i = 0; i < q; i++) {
    if (qt[i] == 2) {
      ql[i] = (lower_bound(pos, (pos) + (pt), ql[i]) - (pos));
      qr[i] = (lower_bound(pos, (pos) + (pt), qr[i] + 1) - (pos));
      cout << get(ql[i], qr[i]).first << '\n';
    } else {
      long long int f = (lower_bound(pos, (pos) + (pt), x[ql[i]]) - (pos));
      ex[f] = 0;
      upd(f);
      x[ql[i]] += qr[i];
      f = (lower_bound(pos, (pos) + (pt), x[ql[i]]) - (pos));
      ex[f] = 1;
      upd(f);
    }
  }
}
