#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;
const int MAGIC = 450;
set<ll> cur[N / MAGIC + 10];
ll ans[N / MAGIC + 10];
ll sum[N / MAGIC + 10];
set<int> active;
void remove(int block, ll x) {
  for (auto y : cur[block]) ans[block] -= abs(y - x);
  cur[block].erase(x);
  sum[block] -= x;
  if (cur[block].empty()) active.erase(block);
}
void insert(int block, ll x) {
  for (auto y : cur[block]) ans[block] += abs(y - x);
  cur[block].insert(x);
  sum[block] += x;
  active.insert(block);
}
int getblock(ll a) { return a / MAGIC; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  map<ll, int> xc;
  vector<ll> pts;
  ll x[n], y[n];
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
    y[i] = x[i];
    xc[x[i]] = 0;
  }
  int q;
  cin >> q;
  vector<array<ll, 3>> query;
  for (int i = 0; i < q; ++i) {
    int type;
    cin >> type;
    int a, b;
    cin >> a >> b;
    if (type == 1) {
      --a;
      y[a] += b;
      xc[y[a]] = 0;
    }
    query.push_back({type, a, b});
  }
  int id = 0;
  for (auto &it : xc) {
    it.second = id++;
    pts.push_back(it.first);
  }
  for (int i = 0; i < n; ++i) insert(getblock(xc[x[i]]), x[i]);
  for (auto [t, l, r] : query) {
    if (t == 1) {
      remove(getblock(xc[x[l]]), x[l]);
      x[l] += r;
      insert(getblock(xc[x[l]]), x[l]);
    } else {
      if (r < *cur[*active.begin()].begin()) {
        cout << 0 << '\n';
        continue;
      }
      if (l > *cur[*active.rbegin()].rbegin()) {
        cout << 0 << '\n';
        continue;
      }
      int left = getblock(lower_bound(begin(pts), end(pts), l) - pts.begin());
      int right =
          getblock(upper_bound(begin(pts), end(pts), r) - pts.begin() - 1);
      if (left > right) {
        cout << 0 << '\n';
        continue;
      }
      ll out = 0, pref = 0, ct = 0;
      if (left == right) {
        for (auto x : cur[left]) {
          if (x < l) continue;
          if (x > r) break;
          out += ct * x - pref;
          pref += x;
          ++ct;
        }
        cout << out << '\n';
        continue;
      }
      for (auto x : cur[left]) {
        if (x < l) continue;
        out += ct * x - pref;
        pref += x;
        ++ct;
      }
      for (int block = left + 1; block < right; ++block) {
        out += ans[block];
        out += ct * sum[block] - 1LL * cur[block].size() * pref;
        pref += sum[block];
        ct += cur[block].size();
      }
      for (auto x : cur[right]) {
        if (x > r) break;
        out += ct * x - pref;
        pref += x;
        ++ct;
      }
      cout << out << '\n';
    }
  }
}
