#include <bits/stdc++.h>
using namespace std;
const long long M = 1e8;
int main() {
  long long n, i, j;
  cin >> n;
  vector<long long> ara;
  for (i = 0; i < n; i++) {
    cin >> j;
    ara.push_back(j);
  }
  long long pre1[n + 1];
  long long pre2[n + 1];
  pre1[0] = 0;
  pre2[0] = 0;
  for (i = 1; i <= n; i++) pre1[i] = pre1[i - 1] + ara[i - 1];
  sort(ara.begin(), ara.end());
  for (i = 1; i <= n; i++) pre2[i] = pre2[i - 1] + ara[i - 1];
  long long t;
  cin >> t;
  while (t--) {
    long long l, h, type, ans = 0;
    cin >> type >> l >> h;
    if (type == 1) {
      ans = pre1[h] - pre1[l - 1];
    } else
      ans = pre2[h] - pre2[l - 1];
    cout << ans << endl;
  }
  return 0;
}
