#include <bits/stdc++.h>
using namespace std;
const long long N = (long long)2e5 + 10;
const long long oo = 1e10;
long long n, m, xl[N], xr[N], ptr = 2, last[N];
long long a[N];
vector<long long> vec;
struct query {
  long long p, d, l, r, typ;
} qs[N];
struct data {
  long long res, sum;
  long long cnt;
  data() { res = sum = cnt = 0; }
} seg[N << 2], null;
data merge(data lc, data rc) {
  data ret;
  ret.cnt = lc.cnt + rc.cnt;
  ret.sum = lc.sum + rc.sum;
  long long add = rc.sum * lc.cnt - lc.sum * rc.cnt;
  ret.res = lc.res + rc.res + add;
  return ret;
}
void rebuild(long long pos, long long ch, long long id = 1, long long l = 0,
             long long r = (long long)vec.size()) {
  if (r - l < 2) {
    if (~ch)
      seg[id].sum = vec[pos], seg[id].cnt = 1;
    else
      seg[id].sum = seg[id].cnt = 0;
    return;
  }
  long long mid = r + l >> 1, lc = id << 1, rc = lc | 1;
  if (pos < mid)
    rebuild(pos, ch, lc, l, mid);
  else
    rebuild(pos, ch, rc, mid, r);
  seg[id] = merge(seg[lc], seg[rc]);
}
data get(long long x, long long y, long long id = 1, long long l = 0,
         long long r = (long long)vec.size()) {
  if (r <= x || l >= y) return null;
  if (l >= x && r <= y) return seg[id];
  long long mid = r + l >> 1, lc = id << 1, rc = lc | 1;
  return merge(get(x, y, lc, l, mid), get(x, y, rc, mid, r));
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long j = 0; j < n; ++j) {
    cin >> a[j];
    last[j] = a[j];
    vec.push_back(a[j]);
  }
  cin >> m;
  for (long long j = 0; j < m; ++j) {
    cin >> qs[j].typ;
    if (qs[j].typ == 1) {
      cin >> qs[j].p >> qs[j].d;
      --qs[j].p;
      last[qs[j].p] += qs[j].d;
      vec.push_back(last[qs[j].p]);
    } else
      cin >> qs[j].l >> qs[j].r;
  }
  sort(vec.begin(), vec.end());
  for (long long j = 0; j < n; ++j) {
    long long pos = lower_bound(vec.begin(), vec.end(), a[j]) - vec.begin();
    rebuild(pos, +1);
  }
  for (long long j = 0; j < m; ++j) {
    if (qs[j].typ == 1) {
      long long p = qs[j].p, d = qs[j].d;
      long long pos = lower_bound(vec.begin(), vec.end(), a[p]) - vec.begin();
      rebuild(pos, -1);
      a[p] += d;
      pos = lower_bound(vec.begin(), vec.end(), a[p]) - vec.begin();
      rebuild(pos, +1);
    } else {
      long long l = qs[j].l, r = qs[j].r;
      l = lower_bound(vec.begin(), vec.end(), l) - vec.begin();
      r = upper_bound(vec.begin(), vec.end(), r) - vec.begin();
      cout << get(l, r).res << endl;
    }
  }
}
