#include <bits/stdc++.h>
using namespace std;
long double PI = acosl(-1);
bool compare_int(int a, int b) { return (a > b); }
bool compare_string(string a, string b) { return a.size() < b.size(); }
bool compare_pair(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
long long int fact(long long int n) {
  if (n == 0 || n == 1)
    return 1;
  else
    return n * fact(n - 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, m, t, l, r, x, ans;
  vector<long long int> a, b, v, ans1, ans2;
  cin >> n;
  for (long long int i = 0; i < n; i++)
    cin >> x, a.push_back(x), b.push_back(x);
  sort(b.begin(), b.end());
  ans1.push_back(0);
  ans2.push_back(0);
  for (long long int i = 1; i <= n; i++) {
    ans1.push_back(ans1[i - 1] + a[i - 1]);
    ans2.push_back(ans2[i - 1] + b[i - 1]);
  }
  cin >> m;
  for (long long int i = 0; i < m; i++) {
    ans = 0;
    cin >> t >> l >> r;
    if (t == 1) {
      cout << ans1[r] - ans1[l - 1] << endl;
    } else {
      cout << ans2[r] - ans2[l - 1] << endl;
    }
  }
  return 0;
}
