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