#include <bits/stdc++.h>
using namespace std;
long long arr[1000000];
void solve() {
  int n;
  cin >> n;
  vector<long long> v(n + 1);
  v[0] = 0;
  long long sum = 0;
  for (int i = 1; i < n + 1; ++i) {
    cin >> v[i];
    sum += v[i];
    arr[i] = sum;
  }
  sort(v.begin(), v.end());
  sum = 0;
  for (int i = 1; i < n + 1; ++i) {
    sum += v[i];
    v[i] = sum;
  }
  int m;
  cin >> m;
  while (m--) {
    int t, l, r;
    cin >> t >> l >> r;
    if (t == 1) {
      cout << arr[r] - arr[l - 1] << endl;
    } else {
      cout << v[r] - v[l - 1] << endl;
    }
  }
}
int main() {
  solve();
  return 0;
}
