#include <bits/stdc++.h>
using namespace std;
struct seg {
  long long msum;
  long long sum;
  int has;
} S[100005 * 12];
int n, q, hass;
int lazy[100005 * 12], a[100005], t[100005], x[100005], y[100005], add[100005];
vector<int> v;
void push(int node) {
  S[node * 2].msum += 1ll * lazy[node] * S[node * 2].sum;
  S[node * 2 + 1].msum += 1ll * lazy[node] * S[node * 2 + 1].sum;
  lazy[node * 2] += lazy[node];
  lazy[node * 2 + 1] += lazy[node];
  lazy[node] = 0;
}
void merge(seg& a, seg b, seg c) {
  a.msum = b.msum + c.msum;
  a.sum = b.sum + c.sum;
  a.has = b.has + c.has;
}
int getind(int node, int bas, int son, int x, int orr) {
  if (bas == x && son == x) return (S[node].has | orr);
  if (((bas + son) >> 1) >= x)
    return getind(node * 2, bas, ((bas + son) >> 1), x, orr);
  return getind(node * 2 + 1, ((bas + son) >> 1) + 1, son, x, orr) +
         S[node * 2].has;
}
seg get(int node, int bas, int son, int x, int y) {
  if (bas >= x && son <= y) return S[node];
  push(node);
  bool le = (((bas + son) >> 1) >= x);
  bool ri = (((bas + son) >> 1) + 1 <= y);
  seg ret;
  if (le && ri) {
    merge(ret, get(node * 2, bas, ((bas + son) >> 1), x, y),
          get(node * 2 + 1, ((bas + son) >> 1) + 1, son, x, y));
    return ret;
  }
  if (le) return get(node * 2, bas, ((bas + son) >> 1), x, y);
  return get(node * 2 + 1, ((bas + son) >> 1) + 1, son, x, y);
}
void up2(int node, int bas, int son, int x, int y, int val) {
  if (x > y) return;
  if (bas > y || son < x) return;
  if (bas >= x && son <= y) {
    S[node].msum += 1ll * val * S[node].sum;
    lazy[node] += val;
    return;
  }
  push(node);
  up2(node * 2, bas, ((bas + son) >> 1), x, y, val);
  up2(node * 2 + 1, ((bas + son) >> 1) + 1, son, x, y, val);
  merge(S[node], S[node * 2], S[node * 2 + 1]);
}
void up1(int node, int bas, int son, int x, int val) {
  if (bas > x || son < x) return;
  if (bas == x && son == x) {
    hass += val;
    S[node].has = val;
    S[node].sum = v[bas] * val;
    S[node].msum = 1ll * val * hass * v[bas];
    return;
  }
  push(node);
  up1(node * 2, bas, ((bas + son) >> 1), x, val);
  hass += S[node * 2].has;
  up1(node * 2 + 1, ((bas + son) >> 1) + 1, son, x, val);
  merge(S[node], S[node * 2], S[node * 2 + 1]);
}
int main() {
  scanf("%d", &n);
  v.push_back(-2004000000);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    v.push_back(a[i]);
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d %d %d", &t[i], &x[i], &y[i]);
    if (t[i] == 1) {
      add[x[i]] += y[i];
      v.push_back(a[x[i]] + add[x[i]]);
    } else {
      v.push_back(x[i]);
      v.push_back(y[i]);
    }
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  int tot = ((int)v.size()) - 1;
  for (int i = 1; i <= n; i++) {
    int pos = lower_bound(v.begin(), v.end(), a[i]) - v.begin();
    hass = 0;
    up1(1, 1, tot, pos, 1);
    up2(1, 1, tot, pos + 1, tot, 1);
  }
  for (int i = 1; i <= q; i++) {
    if (t[i] == 1) {
      int pos1 = lower_bound(v.begin(), v.end(), a[x[i]]) - v.begin();
      a[x[i]] += y[i];
      int pos2 = lower_bound(v.begin(), v.end(), a[x[i]]) - v.begin();
      hass = 0;
      up1(1, 1, tot, pos1, 0);
      up2(1, 1, tot, pos1 + 1, tot, -1);
      hass = 0;
      up1(1, 1, tot, pos2, 1);
      up2(1, 1, tot, pos2 + 1, tot, 1);
    } else {
      int l = lower_bound(v.begin(), v.end(), x[i]) - v.begin();
      int r = lower_bound(v.begin(), v.end(), y[i]) - v.begin();
      int indl = getind(1, 1, tot, l, 1);
      int indr = getind(1, 1, tot, r, 0);
      seg res = get(1, 1, tot, l, r);
      printf("%lld\n", 2ll * res.msum - res.sum * (indl + indr));
    }
  }
}
