#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  long long a[n], sum[n], sorted_sum[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    if (i == 0)
      sum[0] = a[0];
    else {
      sum[i] = a[i] + sum[i - 1];
    }
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    if (i == 0)
      sorted_sum[0] = a[0];
    else {
      sorted_sum[i] = a[i] + sorted_sum[i - 1];
    }
  }
  long long m, type, l, r;
  cin >> m;
  vector<long long> v;
  for (int i = 0; i < m; i++) {
    cin >> type >> l >> r;
    if (type == 1) {
      if (l == 1)
        v.push_back(sum[r - 1]);
      else
        v.push_back(sum[r - 1] - sum[l - 2]);
    } else {
      if (l == 1)
        v.push_back(sorted_sum[r - 1]);
      else
        v.push_back(sorted_sum[r - 1] - sorted_sum[l - 2]);
    }
  }
  for (int i = 0; i < (int)v.size(); i++) cout << v[i] << endl;
  return 0;
}
