#include <bits/stdc++.h>
using namespace std;
long long BASE = 1LL << 32;
struct Triple {
  long long c, s, x;
  Triple(long long _c, long long _s, long long _x) { c = _c, s = _s, x = _x; }
};
Triple ZERO = Triple(0, 0, 0);
struct Node {
  long long l, r, m, c, s, x;
  Node *pl, *pr;
  Node(long long _l, long long _r) {
    l = _l, r = _r;
    m = (l + r) >> 1;
    c = s = x = 0;
    pr = pl = 0;
  }
  ~Node() {
    delete pl;
    delete pr;
  }
  bool isLeaf() { return r - l == 1; }
  void add(long long i, long long d) {
    c += d;
    s += d * i;
    if (!isLeaf()) {
      if (i < m) {
        if (!pl) pl = new Node(l, m);
        pl->add(i, d);
      } else {
        if (!pr) pr = new Node(m, r);
        pr->add(i, d);
      }
    }
    x = (pl ? pl->x : 0) + (pr ? pr->x : 0);
    if (pl && pr) {
      x += (pl->c * pr->s) - (pr->c * pl->s);
    }
  }
  Triple query(long long l, long long r) {
    l = ((l) > (this->l) ? (l) : (this->l));
    r = ((r) < (this->r) ? (r) : (this->r));
    if (l >= r || c == 0)
      return ZERO;
    else if (l == this->l && r == this->r) {
      return Triple(c, s, x);
    } else {
      Triple tl = pl ? pl->query(l, r) : ZERO;
      Triple tr = pr ? pr->query(l, r) : ZERO;
      return Triple(tl.c + tr.c, tl.s + tr.s,
                    tl.x + tr.x + tl.c * tr.s - tr.c * tl.s);
    }
  }
};
int main() {
  long long n, m, i;
  long long t, l, r;
  vector<long long> x;
  Node *p;
  cin >> n;
  p = new Node(0, BASE + BASE);
  for (i = 0; i < (n); i++) {
    cin >> t;
    t += BASE;
    p->add(t, 1);
    x.push_back(t);
  }
  cin >> m;
  for (i = 0; i < (m); i++) {
    cin >> t >> l >> r;
    if (t == 1) {
      --l;
      p->add(x[l], -1);
      x[l] += r;
      p->add(x[l], +1);
    } else {
      l += BASE;
      r += BASE;
      r++;
      Triple T = p->query(l, r);
      cout << T.x << endl;
    }
  }
  return 0;
}
