#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> psorted(n), par(n);
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    psorted[i] = x;
    par[i] = x;
  }
  sort(psorted.begin(), psorted.end());
  partial_sum(psorted.begin(), psorted.end(), psorted.begin());
  partial_sum(par.begin(), par.end(), par.begin());
  long long q;
  cin >> q;
  while (q--) {
    long long typ, l, r;
    cin >> typ >> l >> r;
    l--;
    r--;
    if (typ == 1) {
      if (l == 0)
        cout << par[r] << '\n';
      else
        cout << par[r] - par[l - 1] << '\n';
    } else {
      if (l == 0)
        cout << psorted[r] << '\n';
      else
        cout << psorted[r] - psorted[l - 1] << '\n';
    }
  }
  return 0;
}
