#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 10;
int n, m, a[N], pos, val[N];
set<int> s;
map<int, int> h;
struct que {
  int op, x, y;
} qry[N];
long long seg[N << 2], vals[N << 2], cnts[N << 2];
void pushup(int rt) {
  seg[rt] = seg[rt << 1] + seg[rt << 1 | 1] -
            vals[rt << 1] * cnts[rt << 1 | 1] +
            cnts[rt << 1] * vals[rt << 1 | 1];
  vals[rt] = vals[rt << 1] + vals[rt << 1 | 1];
  cnts[rt] = cnts[rt << 1] + cnts[rt << 1 | 1];
}
void motify(int rt, int l, int r, int k, int d) {
  if (l == r) {
    seg[rt] = 0;
    vals[rt] += (long long)d * val[l];
    cnts[rt] += (long long)d;
    return;
  }
  int mid = l + r >> 1;
  if (mid >= k)
    motify(rt << 1, l, mid, k, d);
  else
    motify(rt << 1 | 1, mid + 1, r, k, d);
  pushup(rt);
}
struct T {
  long long sg, vs, cs;
};
T query(int rt, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return (T){seg[rt], vals[rt], cnts[rt]};
  int mid = l + r >> 1;
  if (mid >= ql && !(mid + 1 <= qr)) return query(rt << 1, l, mid, ql, qr);
  if (!(mid >= ql) && mid + 1 <= qr)
    return query(rt << 1 | 1, mid + 1, r, ql, qr);
  T t1, t2;
  t1 = query(rt << 1, l, mid, ql, qr);
  t2 = query(rt << 1 | 1, mid + 1, r, ql, qr);
  return (T){t1.sg + t2.sg - t1.vs * t2.cs + t1.cs * t2.vs, t1.vs + t2.vs,
             t1.cs + t2.cs};
}
int aa[N];
int main() {
  scanf("%d", &n);
  int i;
  for (i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    s.insert(a[i]);
    aa[i] = a[i];
  }
  scanf("%d", &m);
  for (i = 1; i <= m; ++i) {
    scanf("%d%d%d", &qry[i].op, &qry[i].x, &qry[i].y);
    if (qry[i].op == 2)
      s.insert(qry[i].x), s.insert(qry[i].y);
    else {
      aa[qry[i].x] += qry[i].y;
      qry[i].y = aa[qry[i].x];
      s.insert(aa[qry[i].x]);
    }
  }
  set<int>::iterator it;
  for (it = s.begin(); it != s.end(); ++it) h[*it] = ++pos, val[pos] = *it;
  for (i = 1; i <= n; ++i) motify(1, 1, pos, h[a[i]], 1);
  for (i = 1; i <= m; ++i) {
    if (qry[i].op == 1) {
      motify(1, 1, pos, h[a[qry[i].x]], -1);
      a[qry[i].x] = qry[i].y;
      motify(1, 1, pos, h[qry[i].y], 1);
    } else {
      T tmp = query(1, 1, pos, h[qry[i].x], h[qry[i].y]);
      printf("%lld\n", tmp.sg);
    }
  }
}
