#include <bits/stdc++.h>
using namespace std;
const int INF = 1E9 + 7;
template <class C>
void mini(C& a4, C b4) {
  a4 = min(a4, b4);
}
template <class C>
void maxi(C& a4, C b4) {
  a4 = max(a4, b4);
}
long long n, xx[(1 << 18)], act[(1 << 18)], m, t[(1 << 18)];
vector<long long> wsp;
pair<long long, pair<long long, long long> > join(
    pair<long long, pair<long long, long long> > A,
    pair<long long, pair<long long, long long> > B) {
  return pair<long long, pair<long long, long long> >(
      A.first + B.first,
      pair<long long, long long>(A.second.first + B.second.first,
                                 A.second.second + B.second.second +
                                     B.second.first * A.first -
                                     A.second.first * B.first));
}
struct Tree {
  long long is[2 * (1 << 18)];
  pair<long long, pair<long long, long long> > dp[2 * (1 << 18)];
  void add(int a, int val, int x = 1, int ll = 1, int rr = (1 << 18)) {
    if (a < ll || rr < a) return;
    if (ll == rr) {
      is[x] += val;
      dp[x] = (is[x] ? pair<long long, pair<long long, long long> >(
                           1, pair<long long, long long>(wsp[ll - 1], 0))
                     : pair<long long, pair<long long, long long> >(
                           0, pair<long long, long long>(0, 0)));
      return;
    }
    add(a, val, 2 * x, ll, (ll + rr) / 2);
    add(a, val, 2 * x + 1, (ll + rr + 1) / 2, rr);
    dp[x] = join(dp[2 * x], dp[2 * x + 1]);
  }
  pair<long long, pair<long long, long long> > get(int l, int r, int x = 1,
                                                   int ll = 1,
                                                   int rr = (1 << 18)) {
    if (r < ll || rr < l)
      return pair<long long, pair<long long, long long> >(
          0, pair<long long, long long>(0, 0));
    if (l <= ll && rr <= r) return dp[x];
    return join(get(l, r, 2 * x, ll, (ll + rr) / 2),
                get(l, r, 2 * x + 1, (ll + rr + 1) / 2, rr));
  }
};
Tree tree;
long long l[(1 << 18)], r[(1 << 18)];
long long nr(long long x) {
  return lower_bound((wsp).begin(), (wsp).end(), x) - wsp.begin() + 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  cin >> n;
  for (int i = (1); i <= (n); ++i) cin >> xx[i];
  cin >> m;
  for (int i = (1); i <= (m); ++i) cin >> t[i] >> l[i] >> r[i];
  wsp.push_back(2E9);
  wsp.push_back(-2E9);
  for (int i = (1); i <= (n); ++i) {
    act[i] = xx[i];
    wsp.push_back(act[i]);
  }
  for (int i = (1); i <= (m); ++i)
    if (t[i] == 1) wsp.push_back(act[l[i]] += r[i]);
  sort((wsp).begin(), (wsp).end());
  wsp.erase(unique((wsp).begin(), (wsp).end()), wsp.end());
  for (int i = (1); i <= (n); ++i) {
    act[i] = xx[i];
    tree.add(nr(xx[i]), 1);
  }
  for (int i = (1); i <= (m); ++i)
    if (t[i] == 1) {
      int old = nr(act[l[i]]);
      act[l[i]] += r[i];
      int next = nr(act[l[i]]);
      tree.add(old, -1);
      tree.add(next, 1);
    } else {
      int a = nr(l[i]);
      int b = nr(r[i]);
      if (wsp[b - 1] > r[i]) b--;
      long long res = 0;
      if (a <= b) {
        res = tree.get(a, b).second.second;
      }
      cout << res << endl;
    }
  return 0;
}
