#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, m, k;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
long long ln, lk, lm;
int a[100005], b[100005], cnt, M;
map<int, int> id;
vector<int> av;
struct query {
  int t, o1, o2;
};
query q[100005];
long long tree[1 << 19], num[1 << 19], sum[1 << 19];
void update(int rt, int l, int r, int L, int R, int v) {
  if (r <= L || R <= l) return;
  if (L <= l && r <= R) {
    if (v == 1) {
      num[rt] = 1;
      sum[rt] = av[R - 1];
      tree[rt] = 0;
    } else {
      num[rt] = 0;
      sum[rt] = 0;
      tree[rt] = 0;
    }
    return;
  }
  int mid = (l + r) / 2;
  update(rt << 1, l, mid, L, R, v);
  update(rt << 1 | 1, mid, r, L, R, v);
  num[rt] = num[rt << 1] + num[rt << 1 | 1];
  sum[rt] = sum[rt << 1] + sum[rt << 1 | 1];
  tree[rt] = tree[rt << 1] + tree[rt << 1 | 1] +
             sum[rt << 1 | 1] * num[rt << 1] - sum[rt << 1] * num[rt << 1 | 1];
}
pair<pair<long long, long long>, long long> qy(int rt, int l, int r, int L,
                                               int R) {
  if (r <= L || R <= l) return {{0, 0}, 0};
  if (L <= l && r <= R) return {{num[rt], sum[rt]}, tree[rt]};
  int mid = (l + r) / 2;
  auto x = qy(rt << 1, l, mid, L, R);
  auto y = qy(rt << 1 | 1, mid, r, L, R);
  long long tt = x.second + y.second + y.first.second * x.first.first -
                 y.first.first * x.first.second;
  return {{x.first.first + y.first.first, x.first.second + y.first.second}, tt};
}
int main() {
  scanf("%d", &n);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    scanf("%d", a + i);
    id[a[i]];
    b[i] = a[i];
  }
  scanf("%d", &m);
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    scanf("%d%d%d", &q[i].t, &q[i].o1, &q[i].o2);
    if (q[i].t == 1) {
      b[q[i].o1] += q[i].o2;
      id[b[q[i].o1]];
    }
  }
  for (auto &p : id) {
    p.second = ++cnt;
    av.push_back(p.first);
  }
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    update(1, 0, cnt, id[a[i]] - 1, id[a[i]], 1);
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    if (q[i].t == 1) {
      int x = a[q[i].o1];
      update(1, 0, cnt, id[x] - 1, id[x], 0);
      a[q[i].o1] += q[i].o2;
      update(1, 0, cnt, id[a[q[i].o1]] - 1, id[a[q[i].o1]], 1);
    } else {
      int x = lower_bound(av.begin(), av.end(), q[i].o1) - av.begin();
      int y = upper_bound(av.begin(), av.end(), q[i].o2) - av.begin();
      printf("%lld\n", qy(1, 0, cnt, x, y).second);
    }
  }
  return 0;
}
