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