#include <bits/stdc++.h>
using namespace std;
int bs(vector<int> arr, int target) {
  int l = 0;
  int r = arr.size() - 1;
  while (l < r) {
    int mid = l + (r - l) / 2;
    if (arr[mid] == target)
      return arr[mid];
    else if (arr[mid] < target)
      l = mid + 1;
    else
      r = mid - 1;
  }
  return -1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int arr[n];
  int sum[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sum[i] = arr[i];
  }
  long long int prefix[n];
  prefix[0] = arr[0];
  for (int i = 1; i < n; i++) prefix[i] = prefix[i - 1] + arr[i];
  sort(sum, sum + n);
  long long int prefix2[n];
  prefix2[0] = sum[0];
  for (int i = 1; i < n; i++) prefix2[i] = prefix2[i - 1] + sum[i];
  int m;
  cin >> m;
  while (m--) {
    int type, l, r;
    cin >> type >> l >> r;
    if (type == 1) {
      if (l - 1 < 0 || l - 2 < 0)
        cout << prefix[r - 1] << endl;
      else {
        cout << prefix[r - 1] - prefix[l - 2] << endl;
      }
    } else {
      if (l - 1 < 0 || l - 2 < 0)
        cout << prefix2[r - 1] << endl;
      else {
        cout << prefix2[r - 1] - prefix2[l - 2] << endl;
      }
    }
  }
  return 0;
}
