#include <bits/stdc++.h>
using namespace std;
template <class T>
int toint(T t) {
  stringstream ss;
  ss << t;
  int r;
  ss >> r;
  return r;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n;
  cin >> n;
  int nums[n], copia[n], dif = 0;
  int sol = 0, curr = 0;
  for (int i = 0; i < n; i++) {
    cin >> nums[i];
    copia[i] = nums[i];
  }
  sort(copia, copia + n);
  long long copiaSum[n + 1], numSum[n + 1];
  copiaSum[0] = 0;
  numSum[0] = 0;
  for (int i = 1; i <= n; i++) {
    copiaSum[i] = copiaSum[i - 1] + copia[i - 1];
    numSum[i] = numSum[i - 1] + nums[i - 1];
  }
  int q;
  cin >> q;
  int o, l, r;
  for (int i = 0; i < q; i++) {
    cin >> o >> l >> r;
    if (o == 1) {
      cout << numSum[r] - numSum[l - 1] << "\n";
    } else {
      cout << copiaSum[r] - copiaSum[l - 1] << "\n";
    }
  }
}
