#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long int> k(n);
  vector<long long int> s;
  s.emplace_back(0);
  long long int sum = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> k[i];
    sum += k[i];
    s.emplace_back(sum);
  }
  sort((k).begin(), (k).end());
  sum = 0;
  vector<long long int> s1;
  s1.emplace_back(0);
  for (long long int i = 0; i < n; i++) {
    sum += k[i];
    s1.emplace_back(sum);
  }
  int m;
  cin >> m;
  while (m--) {
    int t, l, r;
    cin >> t >> l >> r;
    if (t == 1) {
      cout << s[r] - s[l - 1] << '\n';
    } else {
      cout << s1[r] - s1[l - 1] << '\n';
    }
  }
  return 0;
}
