#include <bits/stdc++.h>
const int N = 1e5 + 9;
using namespace std;
int main() {
  int n, m;
  long long int a[N], aa[N] = {0};
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    aa[i] = a[i];
  }
  sort(aa, aa + n);
  for (int i = 1; i < n; i++) {
    a[i] = a[i - 1] + a[i];
    aa[i] = aa[i - 1] + aa[i];
  }
  cin >> m;
  while (m--) {
    int type, l, r;
    cin >> type >> l >> r;
    if (type == 1) {
      if (l == 1) {
        cout << a[r - 1] << endl;
      } else {
        cout << a[r - 1] - a[l - 2] << endl;
      }
    } else {
      if (l == 1) {
        cout << aa[r - 1] << endl;
      } else {
        cout << aa[r - 1] - aa[l - 2] << endl;
      }
    }
  }
  return 0;
}
