#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, type, l, r;
  long long int price[100001], sum[100001] = {0}, sum2[100001] = {0};
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> price[i];
    sum[i + 1] = sum[i] + price[i];
  }
  sort(price, price + n);
  for (int i = 0; i < n; ++i) sum2[i + 1] = sum2[i] + price[i];
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> type >> l >> r;
    cout << (type == 1 ? sum[r] - sum[l - 1] : sum2[r] - sum2[l - 1]) << endl;
  }
  return 0;
}
