#include <bits/stdc++.h>
using namespace std;
const int NMAX = 200010;
int N, M, T[NMAX], A[NMAX], B[NMAX], P[NMAX], AuxP[NMAX];
set<int> Val;
map<int, int> ToNorm;
struct SegTree {
  int Cnt;
  long long Sum, SumDif;
} Aint[4 * NMAX];
vector<int> I;
void Update(int Node, int Left, int Right, int Pos, int Sign, int Coord) {
  if (Left == Right) {
    Aint[Node].Cnt += Sign;
    Aint[Node].Sum += 1LL * Sign * Coord;
    Aint[Node].SumDif = 0;
    return;
  }
  int Mid = (Left + Right) / 2;
  if (Pos <= Mid)
    Update((2 * Node), Left, Mid, Pos, Sign, Coord);
  else
    Update((2 * Node + 1), Mid + 1, Right, Pos, Sign, Coord);
  Aint[Node].Cnt = Aint[(2 * Node)].Cnt + Aint[(2 * Node + 1)].Cnt;
  Aint[Node].Sum = Aint[(2 * Node)].Sum + Aint[(2 * Node + 1)].Sum;
  Aint[Node].SumDif = Aint[(2 * Node)].SumDif + Aint[(2 * Node + 1)].SumDif +
                      1LL * Aint[(2 * Node)].Cnt * Aint[(2 * Node + 1)].Sum -
                      1LL * Aint[(2 * Node + 1)].Cnt * Aint[(2 * Node)].Sum;
}
void GetQuery(int Node, int Left, int Right, int LeftB, int RightB) {
  if (LeftB <= Left && Right <= RightB) {
    I.push_back(Node);
    return;
  }
  int Mid = (Left + Right) / 2;
  if (LeftB <= Mid) GetQuery((2 * Node), Left, Mid, LeftB, RightB);
  if (Mid < RightB) GetQuery((2 * Node + 1), Mid + 1, Right, LeftB, RightB);
}
int main() {
  scanf("%i", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%i", &P[i]);
    AuxP[i] = P[i];
    Val.insert(P[i]);
  }
  scanf("%i", &M);
  for (int i = 1; i <= M; ++i) {
    scanf("%i %i %i", &T[i], &A[i], &B[i]);
    if (T[i] == 1) {
      AuxP[A[i]] += B[i];
      Val.insert(AuxP[A[i]]);
    }
  }
  int Cnt = 1;
  for (set<int>::iterator it = Val.begin(); it != Val.end(); ++it) {
    ToNorm[*it] = Cnt;
    Cnt++;
  }
  for (int i = 1; i <= N; ++i) Update(1, 1, Cnt, ToNorm[P[i]], 1, P[i]);
  for (int i = 1; i <= M; ++i)
    if (T[i] == 1) {
      Update(1, 1, Cnt, ToNorm[P[A[i]]], -1, P[A[i]]);
      P[A[i]] += B[i];
      Update(1, 1, Cnt, ToNorm[P[A[i]]], 1, P[A[i]]);
    } else {
      set<int>::iterator itLeft = Val.lower_bound(A[i]);
      set<int>::iterator itRight = Val.upper_bound(B[i]);
      if (itLeft == Val.end() || itRight == Val.begin()) {
        printf("0\n");
        continue;
      }
      --itRight;
      int LeftC = *itLeft, RightC = *itRight;
      if (LeftC > RightC || !(A[i] <= LeftC && LeftC <= B[i]) ||
          !(A[i] <= RightC && RightC <= B[i])) {
        printf("0\n");
        continue;
      }
      I.clear();
      GetQuery(1, 1, Cnt, ToNorm[LeftC], ToNorm[RightC]);
      int TotalCnt = 0;
      long long Ans = 0;
      for (int j = 0; j < I.size(); ++j) {
        Ans += 1LL * Aint[I[j]].SumDif;
        Ans += 1LL * Aint[I[j]].Sum * TotalCnt;
        TotalCnt += Aint[I[j]].Cnt;
      }
      TotalCnt = 0;
      for (int j = int(I.size()) - 1; j >= 0; --j) {
        Ans -= 1LL * Aint[I[j]].Sum * TotalCnt;
        TotalCnt += Aint[I[j]].Cnt;
      }
      printf("%I64d\n", Ans);
    }
}
