#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 19;
int x[N], y[N], t[N], u[N], v[N], chk[N], a[N];
int cnt[N];
long long ans[N], sum[N];
void push_up(int u) {
  cnt[u] = cnt[u + u] + cnt[u + u + 1];
  sum[u] = sum[u + u] + sum[u + u + 1];
  ans[u] = ans[u + u] + ans[u + u + 1] + 1LL * sum[u + u + 1] * cnt[u + u] -
           1LL * sum[u + u] * cnt[u + u + 1];
}
void build(int u, int l, int r) {
  if (l == r) {
    ans[u] = 0;
    sum[u] = 1LL * chk[l] * a[l];
    cnt[u] = chk[l];
    return;
  }
  int m = l + r >> 1;
  build(u + u, l, m);
  build(u + u + 1, m + 1, r);
  push_up(u);
}
void update(int u, int l, int r, int p, int d) {
  if (l == r) {
    chk[l] += d;
    sum[u] = 1LL * chk[l] * a[l];
    cnt[u] = chk[l];
    return;
  }
  int m = l + r >> 1;
  if (p <= m)
    update(u + u, l, m, p, d);
  else
    update(u + u + 1, m + 1, r, p, d);
  push_up(u);
}
int _cnt;
long long _sum, _ans;
void query(int u, int l, int r, int ll, int rr) {
  if (ll <= l && r <= rr) {
    _ans += ans[u] + 1LL * sum[u] * _cnt - 1LL * _sum * cnt[u];
    _cnt += cnt[u];
    _sum += sum[u];
    return;
  }
  int m = l + r >> 1;
  if (ll <= m) query(u + u, l, m, ll, rr);
  if (m < rr) query(u + u + 1, m + 1, r, ll, rr);
}
int main() {
  int n;
  scanf("%d", &n);
  int an = 0;
  for (int i = 1; i <= n; i++) scanf("%d", &x[i]), y[i] = x[i], a[an++] = x[i];
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &t[i], &u[i], &v[i]);
    if (t[i] == 1) {
      y[u[i]] += v[i];
      a[an++] = y[u[i]];
    }
  }
  sort(a, a + an);
  an = unique(a, a + an) - a;
  for (int i = 1; i <= n; i++)
    x[i] = lower_bound(a, a + an, x[i]) - a, y[i] = a[x[i]], chk[x[i]]++;
  build(1, 0, an - 1);
  for (int i = 1; i <= m; i++) {
    if (t[i] == 1) {
      update(1, 0, an - 1, lower_bound(a, a + an, y[u[i]]) - a, -1);
      y[u[i]] += v[i];
      update(1, 0, an - 1, lower_bound(a, a + an, y[u[i]]) - a, 1);
    } else {
      int L = lower_bound(a, a + an, u[i]) - a;
      int R = upper_bound(a, a + an, v[i]) - a - 1;
      if (L > R) {
        puts("0");
        continue;
      }
      _cnt = _sum = _ans = 0;
      query(1, 0, an - 1, L, R);
      printf("%lld\n", _ans);
    }
  }
  return 0;
}
