#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int maxn = 400010;
int ch[maxn][2], fa[maxn], num[maxn], root;
long long key[maxn], s[maxn];
unsigned long long ss[maxn];
void flow(int n) {
  int l = ch[n][0], r = ch[n][1];
  num[n] = num[l] + num[r] + 1;
  s[n] = s[l] + s[r] + key[n];
  ss[n] = ss[l] + ss[r];
  if (r) {
    unsigned long long tmp = s[r] - key[n] * num[r];
    ss[n] += tmp;
  }
  if (l) {
    unsigned long long tmp = key[n] * num[l] - s[l];
    ss[n] += tmp;
  }
  if (l && r) {
    unsigned long long tmp = s[r] * num[l] - s[l] * num[r];
    ss[n] += tmp;
  }
}
void rot(int n) {
  int t = fa[n], isr = (ch[t][1] == n);
  ch[t][isr] = ch[n][!isr], fa[ch[t][isr]] = t;
  fa[n] = fa[t], ch[n][!isr] = t, fa[t] = n;
  ch[fa[n]][ch[fa[n]][1] == t] = n;
  flow(t);
}
void splay(int n, int goal) {
  int f, ff;
  while (fa[n] - goal) {
    f = fa[n], ff = fa[f];
    if (ff == goal)
      rot(n);
    else if ((ch[f][1] == n) == (ch[ff][1] == f))
      rot(f), rot(n);
    else
      rot(n), rot(n);
  }
  flow(n);
  if (!goal) root = n;
}
int getk(int n, int k) {
  while (1) {
    if (num[ch[n][0]] == k - 1) return n;
    if (num[ch[n][0]] >= k)
      n = ch[n][0];
    else
      k -= num[ch[n][0]] + 1, n = ch[n][1];
  }
}
int getxy(int x, int y) {
  splay(getk(root, x), 0);
  splay(getk(ch[root][1], y - x + 2), root);
  return ch[ch[root][1]][0];
}
int get(int t, int k) {
  while (key[t] - k) {
    if (key[t] < k)
      t = ch[t][1];
    else
      t = ch[t][0];
  }
  return t;
}
int get1(int t, int k) {
  int ans = 0;
  while (t) {
    if (key[t] <= k) {
      ans = t;
      t = ch[t][1];
    } else
      t = ch[t][0];
  }
  return ans;
}
int get2(int t, int k) {
  int ans = 0;
  while (t) {
    if (key[t] >= k) {
      ans = t;
      t = ch[t][0];
    } else
      t = ch[t][1];
  }
  return ans;
}
int cnt;
int a[maxn], b[maxn];
int build(int l, int r, int f) {
  if (l > r) return 0;
  int n = ++cnt, mid = (l + r) / 2;
  key[n] = b[mid];
  ch[n][0] = build(l, mid - 1, n);
  ch[n][1] = build(mid + 1, r, n);
  fa[n] = f;
  flow(n);
  return n;
}
void del(int pos, int tot) {
  int t = getxy(pos, pos + tot - 1);
  ch[fa[t]][0] = 0;
  flow(fa[t]), flow(root);
}
int main() {
  int n, m, i, j, k;
  cin >> n;
  for (i = 1; i <= n; i++) scanf("%d", &a[i + 1]);
  a[1] = -2100000000;
  a[n + 2] = 2100000000;
  for (i = 1; i <= n + 2; i++) b[i] = a[i];
  sort(b + 1, b + 1 + n + 2);
  root = build(1, n + 2, 0);
  cin >> m;
  int t;
  while (m--) {
    scanf("%d", &i);
    if (i == 1) {
      scanf("%d%d", &j, &k);
      t = j;
      j = a[j + 1];
      k += j;
      a[t + 1] = k;
      j = get(root, j);
      splay(j, 0);
      j = num[ch[j][0]];
      del(j, 1);
      t = root;
      ++cnt;
      key[cnt] = k;
      while (1) {
        if (k < key[t]) {
          if (ch[t][0])
            t = ch[t][0];
          else {
            ch[t][0] = cnt;
            fa[cnt] = t;
            splay(cnt, 0);
            break;
          }
        } else {
          if (ch[t][1])
            t = ch[t][1];
          else {
            ch[t][1] = cnt;
            fa[cnt] = t;
            splay(cnt, 0);
            break;
          }
        }
      }
    } else {
      scanf("%d%d", &i, &j);
      splay(get1(root, i - 1), 0);
      splay(get2(ch[root][1], j + 1), root);
      i = ch[ch[root][1]][0];
      cout << ss[i] << endl;
    }
  }
}
