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