#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a[n], b[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
    if (i >= 1) a[i] += a[i - 1];
  }
  sort(b, b + n);
  for (long long i = 1; i < n; i++) {
    b[i] += b[i - 1];
  }
  long long m;
  cin >> m;
  for (long long i = 0; i < m; i++) {
    long long aa, bb, c;
    cin >> aa >> bb >> c;
    if (aa == 1) {
      if (bb == 1)
        cout << a[c - 1] << endl;
      else {
        cout << a[c - 1] - a[bb - 2] << endl;
      }
    } else {
      if (bb == 1)
        cout << b[c - 1] << endl;
      else {
        cout << b[c - 1] - b[bb - 2] << endl;
      }
    }
  }
}
