#include <bits/stdc++.h>
using namespace std;
using Key = int;
using ll = long long;
const int mxn = 100006;
const int mxv = mxn;
struct Val {
  ll l, r;
  ll c, S, L, R;
  Val operator+(Val b) {
    if (!c) return b;
    if (!b.c) return *this;
    return {l,
            b.r,
            c + b.c,
            S + b.S + R * b.c + b.L * c + (b.l - r) * c * b.c,
            L + b.L + (b.l - l) * b.c,
            b.R + R + (b.r - r) * c};
  }
};
struct Node {
  int fit;
  Node *l, *r;
  Key key;
  Val val, vals;
};
using ptr = Node *;
Node mem[mxv] = {{0, mem, mem, 0, 0}};
int sz;
ptr renew(ptr x) {
  x->vals = x->l->vals + x->val + x->r->vals;
  return x;
}
pair<ptr, ptr> split(ptr x, Key key) {
  if (x == mem) return {mem, mem};
  ptr t;
  if (x->key >= key)
    return tie(t, x->l) = split(x->l, key), make_pair(t, renew(x));
  else
    return tie(x->r, t) = split(x->r, key), make_pair(renew(x), t);
}
tuple<ptr, ptr, ptr> split(ptr x, Key l, Key r) {
  auto a = split(x, l);
  auto b = split(a.second, r + 1);
  return make_tuple(a.first, b.first, b.second);
}
ptr merge(ptr x, ptr y) {
  if (x == mem) return y;
  if (y == mem) return x;
  if (x->fit > y->fit)
    return x->r = merge(x->r, y), renew(x);
  else
    return y->l = merge(x, y->l), renew(y);
}
ptr merge(ptr x, ptr y, ptr z) { return merge(merge(x, y), z); }
ptr root = mem;
int n;
int key[mxn];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    ptr L, R;
    tie(L, R) = split(root, x);
    key[i] = x;
    root = merge(
        L, new (mem + ++sz) Node{rand(), mem, mem, x, {x, x, 1}, {x, x, 1}}, R);
  }
  int q;
  cin >> q;
  while (q--) {
    int op, l, r, &p = l, &d = r;
    scanf("%d%d%d", &op, &l, &r);
    if (op == 1) {
      ptr L, P, R;
      tie(L, P, R) = split(root, key[p], key[p]);
      root = merge(L, R);
      key[p] = P->key += d;
      P->val = P->vals = Val{P->key, P->key, 1};
      tie(L, R) = split(root, P->key);
      root = merge(L, P, R);
    } else {
      ptr L, M, R;
      tie(L, M, R) = split(root, l, r);
      printf("%lld\n", M->vals.S);
      root = merge(L, M, R);
    }
  }
  return 0;
}
