#include <bits/stdc++.h>
using namespace std;
const long long N = 10e5;
long long arr[N];
long long cs[N];
long long cs2[N];
long long n, q;
long long tc[3];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  for (int i = 1; i <= n; i++) {
    cs[i] = arr[i] + cs[i - 1];
  }
  sort(arr + 1, arr + n + 1);
  for (int i = 1; i <= n; i++) {
    cs2[i] = arr[i] + cs2[i - 1];
  }
  cin >> q;
  while (q--) {
    cin >> tc[0] >> tc[1] >> tc[2];
    long long l = tc[1], r = tc[2];
    if (tc[0] == 1) {
      cout << cs[r] - cs[l - 1] << endl;
    } else {
      cout << cs2[r] - cs2[l - 1] << endl;
    }
  }
  return 0;
}
