#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, q;
  cin >> n;
  vector<long long> v(n + 1);
  v[0] = 0;
  for (long long i = 1; i <= n; i++) cin >> v[i];
  vector<long long> u(n + 1);
  u = v;
  sort(u.begin(), u.end());
  for (long long i = 1; i <= n; i++) {
    v[i] = v[i] + v[i - 1];
    u[i] = u[i] + u[i - 1];
  }
  cin >> q;
  for (long long i = 0; i < q; i++) {
    long long type, l, r;
    cin >> type >> l >> r;
    long long sum = 0;
    if (type == 1)
      sum = v[r] - v[l - 1];
    else
      sum = u[r] - u[l - 1];
    cout << sum << endl;
  }
  return 0;
}
