#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  long long arr[100001], arr2[100001];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    arr2[i] = arr[i];
  }
  sort(arr2, arr2 + n);
  for (int i = 1; i < n; i++) {
    arr[i] = arr[i - 1] + arr[i];
    arr2[i] = arr2[i - 1] + arr2[i];
  }
  cin >> q;
  while (q--) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == 2 && b > 1)
      cout << arr2[c - 1] - arr2[b - 2] << endl;
    else if (a == 2 && b == 1)
      cout << arr2[c - 1] << endl;
    else if (a == 1 && b > 1)
      cout << arr[c - 1] - arr[b - 2] << endl;
    else if (a == 1 && b == 1)
      cout << arr[c - 1] << endl;
  }
  return 0;
}
