#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-6;
const double PI = acos(-1);
vector<int> oo;
int getPos(int x) {
  return lower_bound(oo.begin(), oo.end(), x) - oo.begin() + 1;
}
int getPosL(int x) {
  return lower_bound(oo.begin(), oo.end(), x) - oo.begin() + 1;
}
int getPosR(int x) { return upper_bound(oo.begin(), oo.end(), x) - oo.begin(); }
namespace SGT {
long long sum[N << 2], cnt[N << 2];
long long lazya[N << 2], lazyb[N << 2], all[N << 2];
inline void push(int rt) {
  if (lazya[rt]) {
    lazya[rt << 1] += lazya[rt];
    lazya[rt << 1 | 1] += lazya[rt];
    all[rt << 1] += cnt[rt << 1] * lazya[rt];
    all[rt << 1 | 1] += cnt[rt << 1 | 1] * lazya[rt];
    lazya[rt] = 0;
  }
  if (lazyb[rt]) {
    lazyb[rt << 1] += lazyb[rt];
    lazyb[rt << 1 | 1] += lazyb[rt];
    all[rt << 1] += sum[rt << 1] * lazyb[rt];
    all[rt << 1 | 1] += sum[rt << 1 | 1] * lazyb[rt];
    lazyb[rt] = 0;
  }
}
inline void pull(int rt) {
  sum[rt] = sum[rt << 1] + sum[rt << 1 | 1];
  cnt[rt] = cnt[rt << 1] + cnt[rt << 1 | 1];
  all[rt] = all[rt << 1] + all[rt << 1 | 1];
}
void modify1(int p, long long val, int l, int r, int rt) {
  if (l == r) {
    cnt[rt] += val;
    sum[rt] += oo[l - 1] * val;
    if (!cnt[rt]) all[rt] = 0;
    return;
  }
  push(rt);
  int mid = l + r >> 1;
  if (p <= mid)
    modify1(p, val, l, mid, rt << 1);
  else
    modify1(p, val, mid + 1, r, rt << 1 | 1);
  pull(rt);
}
void modify2(int L, int R, long long val, int l, int r, int rt) {
  if (L > R) return;
  if (l >= L && r <= R) {
    lazya[rt] += val;
    all[rt] += val * cnt[rt];
    return;
  }
  push(rt);
  int mid = l + r >> 1;
  if (L <= mid) modify2(L, R, val, l, mid, rt << 1);
  if (R > mid) modify2(L, R, val, mid + 1, r, rt << 1 | 1);
  pull(rt);
}
void modify3(int L, int R, long long val, int l, int r, int rt) {
  if (L > R) return;
  if (l >= L && r <= R) {
    lazyb[rt] += val;
    all[rt] += val * sum[rt];
    return;
  }
  push(rt);
  int mid = l + r >> 1;
  if (L <= mid) modify3(L, R, val, l, mid, rt << 1);
  if (R > mid) modify3(L, R, val, mid + 1, r, rt << 1 | 1);
  pull(rt);
}
pair<long long, long long> query1(int L, int R, int l, int r, int rt) {
  if (L > R) return make_pair(0, 0);
  if (l >= L && r <= R) return make_pair(sum[rt], cnt[rt]);
  push(rt);
  int mid = l + r >> 1;
  pair<long long, long long> ans = make_pair(0, 0), tmp = make_pair(0, 0);
  if (L <= mid) {
    tmp = query1(L, R, l, mid, rt << 1);
    ans.first += tmp.first;
    ans.second += tmp.second;
  }
  if (R > mid) {
    tmp = query1(L, R, mid + 1, r, rt << 1 | 1);
    ans.first += tmp.first;
    ans.second += tmp.second;
  }
  return ans;
}
long long query2(int L, int R, int l, int r, int rt) {
  if (L > R) return 0;
  if (l >= L && r <= R) return all[rt];
  push(rt);
  int mid = l + r >> 1;
  long long ans = 0;
  if (L <= mid) ans += query2(L, R, l, mid, rt << 1);
  if (R > mid) ans += query2(L, R, mid + 1, r, rt << 1 | 1);
  return ans;
}
}  // namespace SGT
int n, m, x[N], c[N];
pair<pair<int, int>, int> qus[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x[i]);
    c[i] = x[i];
    oo.push_back(x[i]);
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &qus[i].second, &qus[i].first.first, &qus[i].first.second);
    if (qus[i].second == 1) {
      c[qus[i].first.first] += qus[i].first.second;
      oo.push_back(c[qus[i].first.first]);
    }
  }
  sort(oo.begin(), oo.end());
  oo.erase(unique(oo.begin(), oo.end()), oo.end());
  for (int i = 1; i <= n; i++)
    SGT::modify1(getPos(x[i]), 1, 1, ((int)oo.size()), 1);
  for (int i = 1; i <= n; i++) {
    pair<long long, long long> add =
        SGT::query1(getPos(x[i]), ((int)oo.size()), 1, ((int)oo.size()), 1);
    SGT::modify2(getPos(x[i]), getPos(x[i]), add.first, 1, ((int)oo.size()), 1);
    SGT::modify3(getPos(x[i]), getPos(x[i]), -add.second, 1, ((int)oo.size()),
                 1);
  }
  for (int i = 1; i <= m; i++) {
    if (qus[i].second == 1) {
      int p = qus[i].first.first, d = qus[i].first.second;
      if (d > 0) {
        SGT::modify1(getPos(x[p]), -1, 1, ((int)oo.size()), 1);
        SGT::modify2(1, getPos(x[p]) - 1, d, 1, ((int)oo.size()), 1);
        SGT::modify2(getPos(x[p]) + 1, getPos(x[p] + d) - 1, x[p] + d, 1,
                     ((int)oo.size()), 1);
        SGT::modify3(getPos(x[p]) + 1, getPos(x[p] + d) - 1, -1, 1,
                     ((int)oo.size()), 1);
        x[p] += d;
        SGT::modify1(getPos(x[p]), 1, 1, ((int)oo.size()), 1);
        pair<long long, long long> add =
            SGT::query1(getPos(x[p]), ((int)oo.size()), 1, ((int)oo.size()), 1);
        SGT::modify2(getPos(x[p]), getPos(x[p]), add.first, 1, ((int)oo.size()),
                     1);
        SGT::modify3(getPos(x[p]), getPos(x[p]), -add.second, 1,
                     ((int)oo.size()), 1);
      } else if (d < 0) {
        d = -d;
        SGT::modify1(getPos(x[p]), -1, 1, ((int)oo.size()), 1);
        SGT::modify2(1, getPos(x[p] - d) - 1, -d, 1, ((int)oo.size()), 1);
        SGT::modify2(getPos(x[p] - d) + 1, getPos(x[p]) - 1, -x[p], 1,
                     ((int)oo.size()), 1);
        SGT::modify3(getPos(x[p] - d) + 1, getPos(x[p]) - 1, 1, 1,
                     ((int)oo.size()), 1);
        x[p] -= d;
        SGT::modify1(getPos(x[p]), 1, 1, ((int)oo.size()), 1);
        pair<long long, long long> add =
            SGT::query1(getPos(x[p]), ((int)oo.size()), 1, ((int)oo.size()), 1);
        SGT::modify2(getPos(x[p]), getPos(x[p]), add.first, 1, ((int)oo.size()),
                     1);
        SGT::modify3(getPos(x[p]), getPos(x[p]), -add.second, 1,
                     ((int)oo.size()), 1);
      }
    } else {
      int L = qus[i].first.first, R = qus[i].first.second;
      L = getPosL(L);
      R = getPosR(R);
      long long ans = SGT::query2(L, R, 1, ((int)oo.size()), 1);
      pair<long long, long long> tmpL =
          SGT::query1(L, R, 1, ((int)oo.size()), 1);
      pair<long long, long long> tmpR =
          SGT::query1(R + 1, ((int)oo.size()), 1, ((int)oo.size()), 1);
      ans -= tmpL.second * tmpR.first;
      ans += tmpL.first * tmpR.second;
      printf("%lld\n", ans);
    }
  }
  return 0;
}
