#include <bits/stdc++.h>
using namespace std;
static const int INF = 500000000;
template <class T>
void debug(T a, T b) {
  for (; a != b; ++a) cerr << *a << ' ';
  cerr << endl;
}
struct rbst {
  struct node_t {
    int val;
    node_t *lch, *rch;
    int cnt;
    long long int cost;
    int left, right;
    long long int toL, toR;
    void init(int v) {
      val = v;
      lch = rch = NULL;
      cnt = 1;
      cost = toL = toR = 0;
      left = right = v;
    }
  };
  node_t *update(node_t *a) {
    a->cnt = 1;
    a->left = a->right = a->val;
    a->cost = a->toL = a->toR = 0;
    if (a->lch) {
      a->toL = a->lch->toL;
      a->toR += a->lch->toR;
      a->cnt += a->lch->cnt;
      a->left = a->lch->left;
      a->cost += a->lch->cost +
                 (a->val - a->lch->right) * (long long int)(a->lch->cnt) +
                 a->lch->toR;
    }
    if (a->rch) {
      a->toL += a->rch->toL;
      a->toR += a->rch->toR;
      a->cnt += a->rch->cnt;
      a->right = a->rch->right;
      a->cost += a->rch->cost +
                 (a->rch->left - a->val) * (long long int)(a->rch->cnt) +
                 a->rch->toL;
    }
    if (a->lch) {
      a->toR += (a->right - a->lch->right) * (long long int)(a->lch->cnt);
    }
    if (a->rch) {
      a->toL += (a->rch->left - a->left) * (long long int)(a->rch->cnt);
    }
    a->toL += a->val - a->left;
    a->toR += a->right - a->val;
    if (a->lch && a->rch) {
      a->cost += a->lch->cnt * (long long int)a->rch->cnt *
                     (a->rch->left - a->lch->right) +
                 a->lch->toR * (long long int)(a->rch->cnt) +
                 a->rch->toL * (long long int)(a->lch->cnt);
    }
    return a;
  }
  node_t *merge(node_t *l, node_t *r) {
    if (!l || !r) return !l ? r : l;
    if (rand() % (l->cnt + r->cnt) < l->cnt) {
      l->rch = merge(l->rch, r);
      return update(l);
    } else {
      r->lch = merge(l, r->lch);
      return update(r);
    }
  };
  int count(node_t *a) {
    if (!a) return 0;
    return a->cnt;
  }
  pair<node_t *, node_t *> split(node_t *t, int k) {
    if (!t) return make_pair((node_t *)NULL, (node_t *)NULL);
    if (t->val >= k) {
      pair<node_t *, node_t *> s = split(t->lch, k);
      t->lch = s.second;
      return make_pair(s.first, update(t));
    } else {
      pair<node_t *, node_t *> s = split(t->rch, k);
      t->rch = s.first;
      return make_pair(update(t), s.second);
    }
  }
  node_t pool[300000];
  node_t *root;
  int cnt;
  rbst() {
    cnt = 0;
    root = NULL;
  }
  void insert(int v) {
    node_t *ins = &pool[cnt];
    pool[cnt++].init(v);
    pair<node_t *, node_t *> s = split(root, v);
    root = merge(merge(s.first, ins), s.second);
  }
  void erase(int v) {
    pair<node_t *, node_t *> s = split(root, v), s2;
    s2 = split(s.second, v + 1);
    root = merge(s.first, s2.second);
  }
  void debug(node_t *t) {
    if (t->lch) debug(t->lch);
    if (t->rch) debug(t->rch);
  }
  long long int query(int l, int r) {
    pair<node_t *, node_t *> s = split(root, l), s2;
    s2 = split(s.second, r);
    long long int ans = (!s2.first ? 0 : s2.first->cost);
    root = merge(merge(s.first, s2.first), s2.second);
    return ans;
  }
};
int n, m;
int pos[100005];
rbst tree;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &pos[i]);
  for (int i = 0; i < n; ++i) {
    tree.insert(pos[i]);
  }
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) {
    int t, a, b;
    scanf("%d%d%d", &t, &a, &b);
    if (t == 1) {
      --a;
      tree.erase(pos[a]);
      pos[a] += b;
      tree.insert(pos[a]);
    } else {
      ++b;
      cout << tree.query(a, b) << endl;
    }
  }
  return 0;
}
