#include <bits/stdc++.h>
using namespace std;
const int MOD = 95542721;
const int INF = 2e9;
const long long INF64 = 2e18;
const long double EPS = 1e-16;
const long double PI = acos(-1);
const long long MD = 1551513443;
const long long T = 2;
const int N = 100011;
const int M = 334;
const int DEBUG = 0;
const int MAGIC = 320;
int n, kk, color[N], k;
long long tl[N], tr[N], sum[N], d[N], ans[N];
vector<int> a, b, g[N];
bool comp(int i, int j) { return a[i] < a[j]; }
inline void erase(int ind) {
  int v = color[ind];
  for (int i = 0; i < int(int((g[v]).size())); i++)
    if (g[v][i] == ind) {
      g[v].erase(g[v].begin() + i, g[v].begin() + i + 1);
      sum[v] -= a[ind];
      d[v]--;
      break;
    }
  for (int i = 0; i < int(int((g[v]).size())); i++)
    ans[v] -= abs(a[g[v][i]] - a[ind]);
}
inline void push(int ind) {
  for (int v = 0; v < int(k); v++)
    if (tl[v] <= a[ind] && tr[v] >= a[ind]) {
      color[ind] = v;
      for (int i = 0; i < int(int((g[v]).size())); i++)
        ans[v] += abs(a[g[v][i]] - a[ind]);
      sum[v] += a[ind];
      d[v]++;
      for (int i = 0; i < int(int((g[v]).size())); i++)
        if (a[g[v][i]] >= a[ind]) {
          g[v].insert(g[v].begin() + i, ind);
          return;
        }
      g[v].push_back(ind);
      return;
    }
}
inline void build(bool f = 1) {
  if (f) {
    b.clear();
    for (int v = 0; v < int(k); v++)
      for (int i = 0; i < int(int((g[v]).size())); i++) b.push_back(g[v][i]);
  }
  k = 0;
  for (int i = 0; i < int(n); i++) {
    sum[k] = ans[k] = d[k] = 0;
    g[k].clear();
    for (int j = i; j < min(n, i + M); j++) {
      color[b[j]] = k;
      g[k].push_back(b[j]);
      ans[k] += a[b[j]] * d[k] - sum[k];
      sum[k] += a[b[j]];
      d[k]++;
    }
    tl[k] = -INF64;
    tr[k] = a[g[k].back()];
    if (k) tl[k] = tr[k - 1] + 1;
    k++;
    i = i + M - 1;
  }
  tr[k - 1] = INF64;
}
inline void update(int ind, long long val) {
  kk++;
  if (kk > M) {
    kk = 0;
    build();
  }
  erase(ind);
  a[ind] += val;
  push(ind);
}
inline long long solve(long long l, long long r) {
  long long aa = 0, ss = 0, kk = 0;
  for (int v = 0; v < int(k); v++) {
    if (tl[v] > r || tr[v] < l) continue;
    if (tl[v] >= l && tr[v] <= r) {
      aa += ans[v] + sum[v] * kk - ss * d[v];
      ss += sum[v];
      kk += d[v];
    } else {
      for (int i = 0; i < int(int((g[v]).size())); i++)
        if (a[g[v][i]] >= l && a[g[v][i]] <= r) {
          aa += a[g[v][i]] * kk - ss;
          ss += a[g[v][i]];
          kk++;
        }
    }
  }
  return aa;
}
int main() {
  cin >> n;
  for (int i = 0; i < int(n); i++) {
    int first;
    scanf("%d", &first);
    a.push_back(first);
    b.push_back(i);
  }
  sort((b).begin(), (b).end(), comp);
  build(0);
  int m;
  cin >> m;
  for (int u = 0; u < int(m); u++) {
    int t, l, r;
    scanf("%d %d %d", &t, &l, &r);
    if (t == 1)
      update(l - 1, r);
    else
      printf("%I64d\n", solve(l, r));
  }
  return 0;
}
