#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ii = pair<int, int>;
using ld = long double;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<int> prio;
using Key = long long;
struct Node {
  int y;
  Node *l, *r;
  Key x;
  int size;
  long long sum;
  long long ans;
  Node(const Key& k) : y(prio(rng)), l(nullptr), r(nullptr), x(k) { fix(); }
  void fix() {
    size = 1;
    sum = x;
    ans = 0;
    if (l) {
      size += l->size;
      sum += l->sum;
      ans += l->ans;
      ans += x * l->size - l->sum;
    }
    if (r) {
      ans += r->sum * size - sum * r->size;
      size += r->size;
      sum += r->sum;
      ans += r->ans;
    }
  }
};
void split(Node* v, const Key& sx, Node*& sl, Node*& sr) {
  if (v) {
    if (sx <= v->x) {
      split(v->l, sx, sl, v->l);
      sr = v;
    } else {
      split(v->r, sx, v->r, sr);
      sl = v;
    }
    v->fix();
  } else {
    sl = sr = nullptr;
  }
}
void merge(Node*& v, Node* ml, Node* mr) {
  if (ml || mr) {
    if (!ml) {
      v = mr;
    } else if (!mr) {
      v = ml;
    } else {
      if (ml->y < mr->y) {
        merge(mr->l, ml, mr->l);
        v = mr;
      } else {
        merge(ml->r, ml->r, mr);
        v = ml;
      }
    }
    v->fix();
  } else {
    v = nullptr;
  }
}
struct Set {
  Node* root;
  Set() : root(nullptr) {}
  void move(long long x, int d) {
    Node *head, *body, *tail, *head2, *tail2;
    split(root, x, head, tail);
    split(tail, x + 1, body, tail);
    body->x = x + d;
    body->fix();
    if (d < 0) {
      split(head, x + d, head2, tail2);
      merge(tail2, body, tail2);
      merge(head, head2, tail2);
    } else {
      split(tail, x + d, head2, tail2);
      merge(tail2, body, tail2);
      merge(tail, head2, tail2);
    }
    merge(root, head, tail);
  }
  void insert(long long x) {
    Node *head, *tail;
    split(root, x, head, tail);
    merge(tail, new Node(x), tail);
    merge(root, head, tail);
  }
  long long query(long long l, long long r) {
    Node *head, *body, *tail;
    split(root, l, head, tail);
    split(tail, r + 1, body, tail);
    long long ans = body == nullptr ? 0 : body->ans;
    merge(tail, body, tail);
    merge(root, head, tail);
    return ans;
  }
};
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  Set s;
  int n;
  cin >> n;
  vector<long long> p(n);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    p[i] = x;
    s.insert(x);
  }
  int m;
  cin >> m;
  while (m--) {
    int o;
    cin >> o;
    switch (o) {
      case 1: {
        int i, d;
        cin >> i >> d;
        --i;
        s.move(p[i], d);
        p[i] += d;
      } break;
      case 2: {
        int l, r;
        cin >> l >> r;
        cout << s.query(l, r) << '\n';
      } break;
    }
  }
}
