#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int i, n, m, l, r, t;
  long long int x;
  vector<long long int> v, s, va, sa;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
    s.push_back(x);
    va.push_back(0);
    sa.push_back(0);
  }
  sort(s.begin(), s.end());
  va[0] = v[0];
  sa[0] = s[0];
  for (i = 1; i < n; i++) {
    va[i] = v[i] + va[i - 1];
    sa[i] = s[i] + sa[i - 1];
  }
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> t >> l >> r;
    if (t == 1) {
      if (l - 2 >= 0) {
        cout << va[r - 1] - va[l - 2] << endl;
      } else {
        cout << va[r - 1] << endl;
      }
    } else {
      if (l - 2 >= 0) {
        cout << sa[r - 1] - sa[l - 2] << endl;
      } else {
        cout << sa[r - 1] << endl;
      }
    }
  }
  return 0;
}
