#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n;
  vector<uint64_t> arr(n + 1, 0), arr2(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    arr2[i] = arr[i];
  }
  sort(arr2.begin() + 1, arr2.end());
  for (int i = 1; i <= n; i++) {
    arr[i] += arr[i - 1];
    arr2[i] += arr2[i - 1];
  }
  cin >> m;
  while (m--) {
    int x, y, z;
    cin >> x >> y >> z;
    if (x == 1) {
      uint64_t ans = arr[z] - arr[y - 1];
      cout << ans << endl;
    } else {
      uint64_t ans = arr2[z] - arr2[y - 1];
      cout << ans << endl;
    }
  }
  return 0;
}
