#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
const int N = 200007;
int n, m, x[N], curx[N], type[N], delta[N], pos[N], L[N], R[N];
map<int, int> id;
struct segTree {
  long long T[4 * N], sum[4 * N];
  int cnt[4 * N];
  void fix(int v) {
    sum[v] = sum[2 * v] + sum[2 * v + 1];
    cnt[v] = cnt[2 * v] + cnt[2 * v + 1];
    T[v] = T[2 * v] + T[2 * v + 1];
    if (cnt[2 * v] && cnt[2 * v + 1]) {
      long long d = cnt[2 * v] * sum[2 * v + 1] - cnt[2 * v + 1] * sum[2 * v];
      assert(d >= 0);
      T[v] += d;
    }
  }
  void add(int v, int tl, int tr, int pos, int x) {
    if (tl == tr) {
      T[v] = 0;
      cnt[v] = 1;
      sum[v] = x;
      return;
    }
    int tm = (tl + tr) >> 1;
    if (pos <= tm) {
      add(2 * v, tl, tm, pos, x);
    } else {
      add(2 * v + 1, tm + 1, tr, pos, x);
    }
    fix(v);
  }
  void erase(int v, int tl, int tr, int pos) {
    if (tl == tr) {
      T[v] = 0;
      cnt[v] = 0;
      sum[v] = 0;
      return;
    }
    int tm = (tl + tr) >> 1;
    if (pos <= tm) {
      erase(2 * v, tl, tm, pos);
    } else {
      erase(2 * v + 1, tm + 1, tr, pos);
    }
    fix(v);
  }
  void query(int v, int tl, int tr, int l, int r, long long &curAns,
             long long &curSum, int &curCnt) {
    if (tl == l && tr == r) {
      curAns += T[v];
      if (curCnt) {
        long long d = curCnt * sum[v] - cnt[v] * curSum;
        assert(d >= 0 && true);
        curAns += d;
      }
      curSum += sum[v];
      curCnt += cnt[v];
      return;
    }
    int tm = (tl + tr) >> 1;
    if (r <= tm) {
      query(2 * v, tl, tm, l, r, curAns, curSum, curCnt);
    } else if (l > tm) {
      query(2 * v + 1, tm + 1, tr, l, r, curAns, curSum, curCnt);
    } else {
      query(2 * v, tl, tm, l, tm, curAns, curSum, curCnt);
      query(2 * v + 1, tm + 1, tr, tm + 1, r, curAns, curSum, curCnt);
    }
  }
} tree;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", x + i);
    curx[i] = x[i];
  }
  scanf("%d", &m);
  vector<int> xx(x, x + n);
  for (int i = 0; i < m; ++i) {
    scanf("%d", type + i);
    if (type[i] == 1) {
      scanf("%d%d", pos + i, delta + i);
      --pos[i];
      curx[pos[i]] += delta[i];
      xx.push_back(curx[pos[i]]);
    } else {
      scanf("%d%d", L + i, R + i);
    }
  }
  sort((xx).begin(), (xx).end());
  xx.resize(unique((xx).begin(), (xx).end()) - xx.begin());
  int szt = (int)(xx).size();
  for (int i = 0; i < szt; ++i) {
    id[xx[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    tree.add(1, 0, szt - 1, id[x[i]], x[i]);
  }
  for (int i = 0; i < m; ++i) {
    if (type[i] == 1) {
      tree.erase(1, 0, szt - 1, id[x[pos[i]]]);
      x[pos[i]] += delta[i];
      tree.add(1, 0, szt - 1, id[x[pos[i]]], x[pos[i]]);
    } else {
      int l = L[i];
      int r = R[i];
      int lid = lower_bound((xx).begin(), (xx).end(), l) - xx.begin();
      int rid;
      if (id.count(r)) {
        rid = id[r];
      } else {
        rid = lower_bound((xx).begin(), (xx).end(), r) - xx.begin() - 1;
      }
      if (lid > rid) {
        puts("0");
      } else {
        long long curAns = 0;
        long long curSum = 0;
        int curCnt = 0;
        tree.query(1, 0, szt - 1, lid, rid, curAns, curSum, curCnt);
        printf("%I64d\n", curAns);
      }
    }
  }
  return 0;
}
