#include <bits/stdc++.h>
using namespace std;
namespace Splay {
struct node {
  long long val, size, sum, rsum;
  node *parent, *left, *right;
  node() {}
  node(long long val, node *parent)
      : val(val),
        size(1),
        sum(val),
        rsum(val),
        parent(parent),
        left(NULL),
        right(NULL) {}
};
struct Allocator {
  node a[5000000];
  int ptr;
  Allocator() { ptr = 0; }
  node *allocate(node x) {
    ptr++;
    a[ptr] = x;
    return &a[ptr];
  }
} pool;
node *root = NULL;
void update(node *x) {
  x->size = (x->left ? x->left->size : 0) + (x->right ? x->right->size : 0) + 1;
  x->sum =
      (x->left ? x->left->sum : 0) + (x->right ? x->right->sum : 0) + x->val;
  long long s = (x->left ? x->left->size : 0);
  x->rsum = (x->left ? x->left->rsum : 0) + (s + 1) * x->val +
            (s + 1) * (x->right ? x->right->sum : 0) +
            (x->right ? x->right->rsum : 0);
}
void tl(node *x) {
  node *y = x->parent;
  x->parent = y->parent;
  if (y->parent)
    if (y == y->parent->left)
      y->parent->left = x;
    else
      y->parent->right = x;
  y->right = x->left;
  if (x->left) x->left->parent = y;
  x->left = y;
  y->parent = x;
  update(y);
}
void tr(node *x) {
  node *y = x->parent;
  x->parent = y->parent;
  if (y->parent)
    if (y == y->parent->left)
      y->parent->left = x;
    else
      y->parent->right = x;
  y->left = x->right;
  if (x->right) x->right->parent = y;
  x->right = y;
  y->parent = x;
  update(y);
}
void splay(node *x, node *y) {
  while (x->parent != y)
    if (x->parent->parent == y)
      if (x == x->parent->left)
        tr(x);
      else
        tl(x);
    else if (x->parent == x->parent->parent->left)
      if (x == x->parent->left)
        tr(x->parent), tr(x);
      else
        tl(x), tr(x);
    else if (x == x->parent->right)
      tl(x->parent), tl(x);
    else
      tr(x), tl(x);
  update(x);
  if (!y) root = x;
}
void insert(int val) {
  if (!root) {
    root = pool.allocate(node(val, NULL));
    return;
  }
  node *cur = root;
  while (1)
    if (val < cur->val)
      if (cur->left)
        cur = cur->left;
      else {
        cur->left = pool.allocate(node(val, cur));
        splay(cur->left, NULL);
        break;
      }
    else if (cur->right)
      cur = cur->right;
    else {
      cur->right = pool.allocate(node(val, cur));
      splay(cur->right, NULL);
      break;
    }
}
void find(int val) {
  node *cur = root;
  while (1)
    if (val == cur->val) {
      splay(cur, NULL);
      return;
    } else if (val < cur->val)
      cur = cur->left;
    else
      cur = cur->right;
}
void remove(int val) {
  find(val);
  if (!root->left && !root->right) {
    root = NULL;
  } else if (!root->left) {
    node *succ = root->right;
    while (succ->left) succ = succ->left;
    splay(succ, NULL);
    root->left = NULL;
    update(root);
  } else if (!root->right) {
    node *prev = root->left;
    while (prev->right) prev = prev->right;
    splay(prev, NULL);
    root->right = NULL;
    update(root);
  } else {
    node *prev = root->left;
    while (prev->right) prev = prev->right;
    node *succ = root->right;
    while (succ->left) succ = succ->left;
    splay(prev, NULL);
    splay(succ, prev);
    root->right->left = NULL;
    update(root->right);
    update(root);
  }
}
long long query(long long x, long long y) {
  insert(x * 2 - 1);
  node *L = root;
  insert(y * 2 + 1);
  node *R = root;
  splay(L, NULL);
  splay(R, L);
  long long res = 0;
  if (root->right->left)
    res = (root->right->left->size + 1) * root->right->left->sum -
          root->right->left->rsum * 2;
  remove(x * 2 - 1);
  remove(y * 2 + 1);
  return res;
}
}  // namespace Splay
int d[100010];
void lemon() {
  int n;
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) {
    scanf("%d", &d[i]);
    Splay::insert(d[i] * 2);
  }
  int qa;
  scanf("%d", &qa);
  for (int cq = (1); cq <= (qa); cq++) {
    int ty, x, y;
    scanf("%d%d%d", &ty, &x, &y);
    if (ty == 1) {
      Splay::remove(d[x] * 2);
      d[x] += y;
      Splay::insert(d[x] * 2);
    } else
      printf("%I64d\n", -Splay::query(x, y) / 2);
  }
}
int main() {
  ios::sync_with_stdio(true);
  lemon();
  return 0;
}
