#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000, N = 100000;
struct node {
  int size, heap;
  long long val, sum, ans;
  node *left, *right;
  node() {}
  node(int x) {
    size = 1;
    sum = val = x;
    ans = 0;
    heap = rand() * rand();
    right = left = NULL;
  }
};
typedef node *Treap;
int size(Treap T) { return T != NULL ? T->size : 0; }
void update(Treap T) {
  if (T == NULL) return;
  T->size = size(T->left) + size(T->right) + 1;
  T->sum =
      (T->left ? T->left->sum : 0) + T->val + (T->right ? T->right->sum : 0);
  T->ans = (size(T->left) + 1) * (T->right ? T->right->sum : 0) -
           (size(T->right) + 1) * (T->left ? T->left->sum : 0) +
           (T->left ? T->left->ans : 0) + (T->right ? T->right->ans : 0) +
           T->val * (size(T->left) - size(T->right));
}
void merge(Treap &T, Treap L, Treap R) {
  if (L == NULL) {
    T = R;
    return;
  }
  if (R == NULL) {
    T = L;
    return;
  }
  if (L->heap < R->heap) {
    T = L;
    merge(T->right, T->right, R);
  } else {
    T = R;
    merge(T->left, L, T->left);
  }
  update(T);
}
void split(Treap T, Treap &L, Treap &R, int k) {
  if (T == NULL) {
    L = NULL;
    R = NULL;
    return;
  }
  if (size(T->left) >= k) {
    R = T;
    split(R->left, L, R->left, k);
  } else {
    L = T;
    split(L->right, L->right, R, k - size(T->left) - 1);
  }
  if (L) update(L);
  if (R) update(R);
}
int lowerbound(Treap T, int val) {
  if (T == NULL) return 1;
  if (T->val > val)
    return lowerbound(T->left, val);
  else if (T->val < val)
    return lowerbound(T->right, val) + size(T->left) + 1;
  else
    return size(T->left) + 1;
}
int upperbound(Treap T, int val) {
  if (T == NULL) return 1;
  if (T->val > val)
    return upperbound(T->left, val);
  else if (T->val < val)
    return upperbound(T->right, val) + size(T->left) + 1;
  else
    return size(T->left) + 2;
}
void print(Treap T, int d) {
  if (T == NULL)
    cout << "null" << endl;
  else
    cout << T->val << endl;
  if (T == NULL) return;
  cout << "solagit" << endl;
  print(T->left, d + 1);
  cout << "sagagit" << endl;
  print(T->right, d + 1);
}
int n, m, p[N + 5];
Treap T, L, R, LL, LR, RL, RR, nw;
int main() {
  int x, y, cmd;
  srand(time(0));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    p[i] = x;
    split(T, L, R, lowerbound(T, x) - 1);
    nw = new node(x);
    merge(L, L, nw);
    merge(T, L, R);
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d", &cmd, &x, &y);
    if (cmd == 1) {
      split(T, L, R, lowerbound(T, p[x]) - 1);
      split(R, RL, RR, 1);
      merge(T, L, RR);
      p[x] += y;
      nw = new node(p[x]);
      split(T, L, R, lowerbound(T, p[x]) - 1);
      merge(L, L, nw);
      merge(T, L, R);
    } else {
      int u, l;
      split(T, L, R, u = upperbound(T, y) - 1);
      split(L, LL, LR, l = lowerbound(L, x) - 1);
      printf("%lld\n", LR ? LR->ans : 0);
      merge(L, LL, LR);
      merge(T, L, R);
    }
  }
  return 0;
}
