#include <bits/stdc++.h>
using namespace std;
struct item {
  long long x, y;
  item *l, *r;
  long long sz;
  long long f_l, f_r, f;
  int l1, r1;
  item(long long X) {
    x = X;
    y = rand();
    l = r = 0;
    sz = 1;
    f_l = f_r = f = 0;
    l1 = r1 = X;
  }
};
int get_left(item* t) {
  if (!t) return 0;
  return t->l1;
}
int get_right(item* t) {
  if (!t) return 0;
  return t->r1;
}
inline void upd(item* t) {
  if (!t) return;
  int sz = 1;
  if (t->l) sz += t->l->sz;
  if (t->r) sz += t->r->sz;
  t->l1 = t->x;
  t->r1 = t->x;
  if (t->l) t->l1 = t->l->l1;
  if (t->r) t->r1 = t->r->r1;
  t->sz = sz;
  if (!t->l && !t->r) {
    t->f_l = t->f_r = t->f = 0;
    return;
  }
  if (!t->l) {
    long long l1 = get_left(t->r), r1 = get_right(t->r);
    t->f_l = t->r->f_l + 1ll * t->r->sz * (abs(t->x - l1));
    t->f_r = t->r->f_r + abs(t->x - r1);
    t->f = t->r->f + t->r->f_l + 1ll * t->r->sz * abs(t->x - l1);
    return;
  }
  if (!t->r) {
    long long l1 = get_left(t->l), r1 = get_right(t->l);
    t->f_l = t->l->f_l + abs(t->x - l1);
    t->f_r = t->l->f_r + 1ll * abs(t->x - r1) * (t->l->sz);
    t->f = t->l->f + t->l->f_r + 1ll * t->l->sz * abs(t->x - r1);
    return;
  }
  long long tll = get_left(t->l), tlr = get_right(t->l), trl = get_left(t->r),
            trr = get_right(t->r);
  t->f_l =
      t->l->f_l + t->r->f_l + 1ll * t->r->sz * abs(tll - trl) + abs(t->x - tll);
  t->f_r =
      t->r->f_r + t->l->f_r + 1ll * t->l->sz * abs(trr - tlr) + abs(t->x - trr);
  t->f = t->l->f + t->r->f + 1ll * t->l->sz * t->r->sz * abs(tlr - trl) +
         1ll * t->l->f_r * t->r->sz + t->r->f_l * t->l->sz + t->l->f_r +
         t->l->sz * abs(t->x - tlr) + t->r->f_l + t->r->sz * abs(t->x - trl);
}
void split(item* t, item*& l, item*& r, int k) {
  if (!t) {
    l = r = 0;
    return;
  }
  upd(t);
  if (t->x < k) {
    split(t->r, t->r, r, k);
    l = t;
    upd(l);
  } else {
    split(t->l, l, t->l, k);
    r = t;
    upd(r);
  }
}
item* merge(item* l, item* r) {
  upd(l);
  upd(r);
  if (!l) {
    return r;
  }
  if (!r) {
    return l;
  }
  if (l->y < r->y) {
    l->r = merge(l->r, r);
    upd(l);
    return l;
  } else {
    r->l = merge(l, r->l);
    upd(r);
    return r;
  }
}
item* t;
item* p[100100];
pair<int, int> a[100100];
int n;
inline long long get(long long l, long long r) {
  item *t1, *t2;
  split(t, t1, t, l);
  split(t, t, t2, r + 1);
  long long k = 0;
  if (t) k = t->f;
  t = merge(t, t2);
  t = merge(t1, t);
  return k;
}
inline void upd(int i, int d) {
  int x = p[i]->x;
  item *t1, *t2, *t3;
  split(t, t, t1, x);
  split(t1, t1, t2, x + 1);
  if (d > 0) {
    split(t2, t2, t3, x + d);
    p[i]->x += d;
    t = merge(t, t2);
    t = merge(t, t1);
    t = merge(t, t3);
  } else {
    split(t, t, t3, x + d);
    p[i]->x += d;
    t = merge(t, t1);
    t = merge(t, t3);
    t = merge(t, t2);
  }
}
void build() {
  cin >> n;
  for (int i = 0; i < int(n); i++) {
    scanf("%d", &a[i].first);
    a[i].second = i;
  }
  sort(a, a + n);
  for (int i = 0; i < int(n); i++) {
    p[a[i].second] = new item(a[i].first);
    t = merge(t, p[a[i].second]);
  }
  int m;
  cin >> m;
  for (int i = 0; i < int(m); i++) {
    int t1, t2, t3;
    scanf("%d %d %d", &t1, &t2, &t3);
    if (t1 == 1) {
      t2--;
      if (t3 != 0) upd(t2, t3);
    } else {
      cout << get(t2, t3) << endl;
    }
  }
}
int main() {
  build();
  return 0;
}
