#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int num;
  cin >> num;
  long long int array[num], array1[num];
  for (long long int i = 0; i < num; i++) {
    cin >> array[i];
    array1[i] = array[i];
  }
  sort(array1, array1 + num);
  for (int i = 1; i < num; i++) {
    array[i] += array[i - 1];
    array1[i] += array1[i - 1];
  }
  long long int que;
  cin >> que;
  while (que--) {
    long long int ind;
    cin >> ind;
    if (ind == 1) {
      long long int l, r;
      cin >> l >> r;
      if (l == 1) {
        cout << array[r - 1] << endl;
      } else {
        cout << array[r - 1] - array[l - 2] << endl;
      }
    } else {
      long long int l, r;
      cin >> l >> r;
      if (l == 1) {
        cout << array1[r - 1] << endl;
      } else {
        cout << array1[r - 1] - array1[l - 2] << endl;
      }
    }
  }
}
