#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x, y, z, i;
  cin >> n;
  vector<long long> v, u;
  v.push_back(0);
  while (n--) {
    cin >> x;
    v.push_back(x);
  }
  u = v;
  sort(v.begin(), v.end());
  for (i = 1; i < v.size(); i++) {
    u[i] += u[i - 1];
    v[i] += v[i - 1];
  }
  cin >> x;
  while (x--) {
    cin >> n >> y >> z;
    cout << (n == 1 ? u[z] - u[y - 1] : v[z] - v[y - 1]) << endl;
  }
  return 0;
}
