#include <bits/stdc++.h>
using namespace std;
vector<long long> s1, s2, v;
vector<long long> bld(vector<long long> a) {
  int n = a.size();
  vector<long long> s(n + 1);
  for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i];
  return s;
}
int main() {
  int n;
  cin >> n;
  v.resize(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  s1 = bld(v);
  sort(v.begin(), v.end());
  s2 = bld(v);
  int m;
  cin >> m;
  while (m-- > 0) {
    int t, l, r;
    cin >> t >> l >> r;
    if (t == 1)
      cout << s1[r] - s1[l - 1] << endl;
    else
      cout << s2[r] - s2[l - 1] << endl;
  }
  return 0;
}
