#include <bits/stdc++.h>
const int MAXN = 110000;
const int INF = 1E9 + 233;
struct Node {
  int c[2], fa;
  int siz;
  long long val, sum, ret;
  Node() {}
  Node(int k) {
    c[0] = c[1] = fa = 0;
    siz = 1;
    sum = val = k;
    ret = 0;
  }
} tr[MAXN];
struct Splay {
  int root;
  void pushup(int x) {
    tr[x].siz = tr[tr[x].c[0]].siz + tr[tr[x].c[1]].siz + 1;
    tr[x].sum = tr[tr[x].c[0]].sum + tr[tr[x].c[1]].sum + tr[x].val;
    tr[x].ret = tr[tr[x].c[0]].ret + tr[tr[x].c[1]].ret +
                (tr[tr[x].c[1]].sum + tr[x].val) * (tr[tr[x].c[0]].siz + 1) -
                (tr[tr[x].c[0]].sum + tr[x].val) * (tr[tr[x].c[1]].siz + 1);
  }
  bool getlr(int x) { return tr[tr[x].fa].c[1] == x; }
  void rotate(int x) {
    int y = tr[x].fa, z = tr[y].fa;
    bool k = getlr(x);
    int w = tr[x].c[k ^ 1];
    if (z) tr[z].c[getlr(y)] = x;
    tr[x].fa = z;
    tr[y].c[k] = w;
    if (w) tr[w].fa = y;
    tr[x].c[k ^ 1] = y;
    tr[y].fa = x;
    pushup(y);
  }
  void splay(int x, int y) {
    while (tr[x].fa != y) {
      if (tr[tr[x].fa].fa != y)
        rotate(getlr(x) ^ getlr(tr[x].fa) ? x : tr[x].fa);
      rotate(x);
    }
    pushup(x);
    if (!y) root = x;
  }
  int find(int k) {
    int x = root, y = 0;
    while (x)
      if (tr[x].val >= k)
        y = x, x = tr[x].c[0];
      else
        x = tr[x].c[1];
    return y;
  }
  void insert(int y) {
    if (!root) {
      root = y;
      return;
    }
    int x = find(tr[y].val);
    if (!x) {
      x = root;
      while (tr[x].c[1]) x = tr[x].c[1];
      tr[x].c[1] = y;
      tr[tr[x].c[1]].fa = x;
      splay(tr[x].c[1], 0);
      return;
    }
    splay(x, 0);
    if (!tr[x].c[0])
      tr[x].c[0] = y, tr[tr[x].c[0]].fa = x, pushup(x);
    else {
      x = tr[x].c[0];
      while (tr[x].c[1]) x = tr[x].c[1];
      tr[x].c[1] = y;
      tr[tr[x].c[1]].fa = x;
      splay(tr[x].c[1], 0);
    }
  }
  void erase(int x) {
    splay(x, 0);
    if (!tr[x].c[0])
      tr[tr[x].c[1]].fa = 0, root = tr[x].c[1];
    else {
      int y = tr[x].c[0];
      while (tr[y].c[1]) y = tr[y].c[1];
      splay(y, x);
      tr[y].c[1] = tr[x].c[1];
      tr[tr[x].c[1]].fa = y;
      tr[y].fa = 0;
      root = y;
      pushup(y);
    }
  }
  int pre(int x) {
    splay(x, 0);
    if (!x) {
      x = root;
      while (tr[x].c[1]) x = tr[x].c[1];
      splay(x, 0);
      return tr[x].val;
    }
    x = tr[x].c[0];
    while (tr[x].c[1]) x = tr[x].c[1];
    return x;
  }
  long long query(int l, int r) {
    int x = find(l), y = find(r + 1);
    if (!x) return 0;
    x = pre(x);
    if (x) {
      splay(x, 0);
      if (y) {
        splay(y, x);
        return tr[tr[y].c[0]].ret;
      } else
        return tr[tr[x].c[1]].ret;
    } else if (y) {
      splay(y, 0);
      return tr[tr[y].c[0]].ret;
    } else
      return tr[root].ret;
  }
} splay;
int a[MAXN];
void print(int x) {
  if (!x) return;
  print(tr[x].c[0]);
  printf("%d %d %d\n", x, tr[x].val, tr[x].ret);
  print(tr[x].c[1]);
  splay.pushup(x);
}
int main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    tr[i] = Node(x);
    splay.insert(i);
  }
  scanf("%d", &m);
  while (m--) {
    int opt, x, y;
    scanf("%d%d%d", &opt, &x, &y);
    if (opt == 1) {
      splay.erase(x);
      tr[x] = Node(tr[x].val + y);
      splay.insert(x);
    } else
      printf("%lld\n", splay.query(x, y));
  }
  return 0;
}
