#include <bits/stdc++.h>
using namespace std;
long long int mod = pow(10, 9) + 7;
int main() {
  long long int n, m, t, l, r;
  cin >> n;
  vector<long long int> s1(100010, 0), s2(100010, 0);
  long long int v1[100010];
  for (long long int i = 0; i < n; i++) {
    cin >> v1[i];
    s1[i + 1] = s1[i] + v1[i];
  }
  sort(v1, v1 + n);
  for (long long int i = 0; i < n; i++) {
    s2[i + 1] = s2[i] + v1[i];
  }
  cin >> m;
  for (long long int i = 0; i < m; i++) {
    cin >> t >> l >> r;
    if (t == 1) {
      long long int p = s1[r] - s1[l - 1];
      cout << p << endl;
    } else {
      long long int p = s2[r] - s2[l - 1];
      cout << p << endl;
    }
  }
  return 0;
}
