#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x, y, a, b, c;
  cin >> x;
  long long arr[100000], sum1[100001] = {0}, sum2[100001] = {0};
  for (long long i = 0; i < x; ++i) {
    cin >> arr[i];
    sum1[i + 1] = sum1[i] + arr[i];
  }
  sort(arr, arr + x);
  for (long long i = 0; i < x; ++i) {
    sum2[i + 1] = sum2[i] + arr[i];
  }
  cin >> y;
  for (long long i = 0; i < y; ++i) {
    cin >> c >> a >> b;
    if (c == 1)
      cout << sum1[b] - sum1[a - 1] << endl;
    else
      cout << sum2[b] - sum2[a - 1] << endl;
  }
}
