#include <bits/stdc++.h>
using namespace std;
long long arr[100000 + 5];
long long s[100000 + 5];
long long n, m;
int main(int argc, const char* argv[]) {
  cin >> n;
  cin >> arr[1];
  s[0] = arr[1];
  arr[0] = 0;
  for (int i = 2; i <= n; ++i) {
    long long x;
    cin >> x;
    arr[i] = arr[i - 1] + x;
    s[i - 1] = x;
  }
  cin >> m;
  std::sort(s, s + n);
  for (int i = 1; i < n; ++i) {
    s[i] += s[i - 1];
  }
  for (int i = 0; i < m; ++i) {
    int x, l, r;
    cin >> x >> l >> r;
    if (x == 1) {
      cout << arr[r] - arr[l - 1] << endl;
    } else {
      cout << s[r - 1] - s[l - 2] << endl;
    }
  }
  return 0;
}
