#include <bits/stdc++.h>
using namespace std;
long long dp1[100000 + 10], dp2[100000 + 10], v[100000 + 10], cv[100000 + 10];
int t[100000 + 10], l[100000 + 10], r[100000 + 10];
int main() {
  int n, m;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    cv[i] = v[i];
  }
  sort(cv, cv + n);
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> t[i] >> l[i] >> r[i];
    l[i]--;
    r[i]--;
  }
  for (int i = n - 1; i >= 0; i--) {
    if (i == n - 1) {
      dp1[i] = v[i];
      dp2[i] = cv[i];
    } else {
      dp1[i] = dp1[i + 1] + v[i];
      dp2[i] = dp2[i + 1] + cv[i];
    }
  }
  for (int i = 0; i < m; i++) {
    if (t[i] == 1) cout << dp1[l[i]] - dp1[r[i] + 1] << endl;
    if (t[i] == 2) cout << dp2[l[i]] - dp2[r[i] + 1] << endl;
  }
}
