#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
struct node {
  long long uk, cnt, cntl, cntr, val, suml, sumr;
  int hval;
  node *l, *r;
};
typedef node *pnode;
int n;
long long a[maxn + 10];
pnode root;
mt19937 gen(10);
long long get_cntl(pnode &x) {
  if (x == NULL)
    return 0;
  else
    return x->cntl;
}
long long get_cnt(pnode &x) {
  if (x == NULL)
    return 0;
  else
    return x->cnt;
}
long long get_cntr(pnode &x) {
  if (x == NULL)
    return 0;
  else
    return x->cntr;
}
long long get_suml(pnode &x) {
  if (x == NULL)
    return 0;
  else
    return x->suml;
}
long long get_sumr(pnode &x) {
  if (x == NULL)
    return 0;
  else
    return x->sumr;
}
long long get_val(pnode &x) {
  if (x == NULL)
    return 0;
  else
    return x->val;
}
long long get_uk(pnode &x) {
  if (x == NULL)
    return 0;
  else
    return x->uk;
}
void get_node(pnode &pom, long long key) {
  pom->uk = 0;
  pom->suml = 0;
  pom->sumr = 0;
  pom->cnt = 1;
  pom->cntr = 0;
  pom->cntl = 0;
  pom->val = key;
  pom->hval = gen() % 100000;
  pom->l = NULL;
  pom->r = NULL;
}
void refresh(pnode &x) {
  x->cnt = get_cnt(x->l) + get_cnt(x->r) + 1;
  x->cntl = get_cnt(x->l);
  x->cntr = get_cnt(x->r);
  x->suml = get_suml(x->l) +
            (get_cntl(x->l) + 1) * (x->val - get_val(x->l)) * (x->l != NULL) +
            get_cntr(x->l) * (x->val - get_val(x->l)) * (x->l != NULL) -
            get_sumr(x->l);
  x->sumr = get_sumr(x->r) +
            (get_cntr(x->r) + 1) * (get_val(x->r) - x->val) * (x->r != NULL) +
            get_cntl(x->r) * (get_val(x->r) - x->val) * (x->r != NULL) -
            get_suml(x->r);
  x->uk = get_uk(x->l) + get_uk(x->r) + x->suml + x->sumr + x->suml * x->cntr +
          x->sumr * x->cntl;
}
void mrg(pnode l, pnode r, pnode &x) {
  if (l == NULL || r == NULL) {
    x = (l == NULL) ? r : l;
    return;
  }
  if (l->hval >= r->hval) {
    mrg(l->r, r, l->r);
    x = l;
  } else {
    mrg(l, r->l, r->l);
    x = r;
  }
  refresh(x);
}
void split(pnode x, pnode &l, pnode &r, long long key) {
  if (x == NULL) {
    l = NULL;
    r = NULL;
    return;
  }
  if (x->val < key) {
    split(x->r, x->r, r, key);
    l = x;
    refresh(l);
  } else {
    split(x->l, l, x->l, key);
    r = x;
    refresh(r);
  }
}
void check(pnode x) {
  if (x == NULL) return;
  check(x->l);
  printf("%lld %lld %lld %lld %lld   | ", x->val, x->uk, x->suml, x->sumr,
         x->cnt);
  check(x->r);
}
void ubaci(long long x) {
  pnode pom = new node();
  get_node(pom, x);
  pnode t1, t2;
  split(root, t1, t2, x);
  mrg(t1, pom, t1);
  mrg(t1, t2, root);
}
void izbaci(pnode &x, long long val) {
  if (x->val == val) {
    mrg(x->l, x->r, x);
    return;
  }
  if (x->val < val)
    izbaci(x->r, val);
  else
    izbaci(x->l, val);
  refresh(x);
}
void query(int l, int r) {
  pnode t1, t2, t3;
  split(root, t1, t2, l);
  split(t2, t2, t3, r + 1);
  printf("%lld\n", get_uk(t2));
  mrg(t1, t2, t1);
  mrg(t1, t3, root);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    ubaci(a[i]);
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int tip, l, r;
    scanf("%d %d %d", &tip, &l, &r);
    if (tip == 1) {
      izbaci(root, a[l]);
      a[l] += r;
      ubaci(a[l]);
    } else
      query(l, r);
  }
  return 0;
}
