#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> arr(n);
  vector<long long int> a;
  long long int pre[n + 1], pre2[n + 1];
  pre[0] = 0, pre2[0] = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  a = arr;
  sort(a.begin(), a.end());
  for (long long int i = 1; i < n + 1; i++) {
    pre[i] = pre[i - 1] + arr[i - 1];
    pre2[i] = pre2[i - 1] + a[i - 1];
  }
  long long int q;
  cin >> q;
  while (q--) {
    long long int type, l, r;
    cin >> type >> l >> r;
    if (type == 1) {
      cout << pre[r] - pre[l - 1] << "\n";
    } else {
      cout << pre2[r] - pre2[l - 1] << "\n";
    }
  }
}
signed main() {
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
