#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5;
long long pref1[N + 5];
long long pref2[N + 5];
long long ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, type, l, r;
  cin >> n;
  n++;
  int arr[n];
  for (int i = 1; i < n; i++) {
    cin >> arr[i];
    pref1[i] = pref1[i - 1] + arr[i];
  }
  sort(arr + 1, arr + n);
  for (int i = 1; i < n; i++) pref2[i] = pref2[i - 1] + arr[i];
  cin >> m;
  while (m--) {
    cin >> type >> l >> r;
    if (type == 1)
      ans = pref1[r] - pref1[l - 1];
    else
      ans = pref2[r] - pref2[l - 1];
    cout << ans << endl;
  }
  return 0;
}
