#include <bits/stdc++.h>
using namespace std;
int n, m;
int x[100001];
struct Treap {
  Treap *l, *r;
  int x, y, sz;
  long long f, sum;
  Treap(int x) {
    this->x = x;
    y = rand();
    sz = 1;
    sum = x;
    f = x;
    l = r = NULL;
  }
};
inline int getSize(Treap *t) { return t ? t->sz : 0; }
inline long long getSum(Treap *t) { return t ? t->sum : 0; }
inline long long getF(Treap *t) { return t ? t->f : 0; }
void update(Treap *&t) {
  if (t) {
    int lt = getSize(t->l) + 1;
    t->sz = lt + getSize(t->r);
    t->sum = getSum(t->l) + getSum(t->r) + t->x;
    t->f = getF(t->l) + lt * 1ll * t->x + getF(t->r) + lt * 1ll * getSum(t->r);
  }
}
void Merge(Treap *&t, Treap *l, Treap *r) {
  if (!l)
    t = r;
  else if (!r)
    t = l;
  else if (l->y < r->y) {
    Merge(l->r, l->r, r);
    t = l;
  } else {
    Merge(r->l, l, r->l);
    t = r;
  }
  update(t);
}
void Split(Treap *t, Treap *&l, Treap *&r, int k) {
  if (!t) {
    l = r = NULL;
    return;
  }
  if (t->x <= k) {
    Split(t->r, t->r, r, k);
    l = t;
  } else {
    Split(t->l, l, t->l, k);
    r = t;
  }
  update(t);
}
void erase(Treap *&t, int x) {
  if (t->x == x) return Merge(t, t->l, t->r);
  if (t->x > x)
    erase(t->l, x);
  else
    erase(t->r, x);
  update(t);
}
void insert(Treap *&t, int x) {
  Treap *A, *B;
  Split(t, A, B, x);
  Merge(t, A, new Treap(x));
  Merge(t, t, B);
}
Treap *t;
int T, l, r;
void dfs(Treap *t) {
  if (t) {
    dfs(t->l);
    cerr << t->x << '\n';
    dfs(t->r);
  }
}
int main() {
  srand(time(NULL));
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> x[i];
    insert(t, x[i]);
  }
  cin >> m;
  while (m-- > 0) {
    cin >> T >> l >> r;
    if (T == 1) {
      erase(t, x[l]);
      insert(t, x[l] += r);
    } else {
      Treap *A, *B, *C;
      Split(t, A, B, r);
      Split(A, A, C, l - 1);
      cout << 2ll * getF(C) - (getSize(C) + 1) * getSum(C) << '\n';
      Merge(t, A, C);
      Merge(t, t, B);
    }
  }
  return 0;
}
