#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long a[n + 1];
  a[0] = 0;
  long long sum = 0;
  vector<long long> sum1;
  sum1.push_back(sum);
  vector<long long> sum2;
  for (int i = 0; i < n; i++) {
    long long y;
    cin >> y;
    a[i + 1] = y;
    sum += y;
    sum1.push_back(sum);
  }
  sort(a, a + n + 1);
  sum = 0;
  for (int i = 0; i < n + 1; i++) {
    sum += a[i];
    sum2.push_back(sum);
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int type, l, r;
    cin >> type >> l >> r;
    if (type == 1) {
      cout << sum1.at(r) - sum1.at(l - 1) << "\n";
    } else {
      cout << sum2.at(r) - sum2.at(l - 1) << "\n";
    }
  }
}
