#include <bits/stdc++.h>
using namespace std;
void a15hx() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<long long int> arr1(n), T(n + 1), S(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> arr1[i];
    T[i + 1] = T[i] + arr1[i];
  }
  sort(arr1.begin(), arr1.end());
  for (int i = 0; i < n; i++) {
    S[i + 1] = S[i] + arr1[i];
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int t, l, r;
    cin >> t >> l >> r;
    if (t == 1) {
      cout << T[r] - T[l - 1] << "\n";
    } else {
      cout << S[r] - S[l - 1] << "\n";
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  a15hx();
  return 0;
}
