#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long arr[n + 5];
  for (int i = 0; i < n; i++) cin >> arr[i];
  long long pre[n + 5];
  pre[0] = 0;
  for (int i = 1; i <= n; i++) {
    pre[i] = pre[i - 1] + arr[i - 1];
  }
  sort(arr, arr + n);
  long long pre2[n + 5];
  pre2[0] = 0;
  for (int i = 1; i <= n; i++) {
    pre2[i] = pre2[i - 1] + arr[i - 1];
  }
  long long q, l, r, type;
  cin >> q;
  while (q--) {
    cin >> type >> l >> r;
    if (type == 1) {
      cout << pre[r] - pre[l - 1] << endl;
    } else if (type == 2) {
      cout << pre2[r] - pre2[l - 1] << endl;
    }
  }
  return 0;
}
