#include <bits/stdc++.h>
using namespace std;
int n;
int m;
vector<long long> a;
vector<long long> b;
void solve() {
  a.clear();
  b.clear();
  cin >> n;
  ++n;
  a.resize(n);
  for (int i = 1; i < n; ++i) cin >> a[i];
  b = a;
  sort(b.begin(), b.end());
  for (int i = 1; i < n; ++i) {
    a[i] = a[i - 1] + a[i];
    b[i] = b[i - 1] + b[i];
  }
  cin >> m;
  while (m--) {
    int type;
    int l;
    int r;
    cin >> type >> l >> r;
    long long ans = 0;
    if (type == 1) {
      ans = a[r] - a[l - 1];
    } else {
      ans = b[r] - b[l - 1];
    }
    cout << ans << '\n';
  }
}
int main() {
  int t = 1;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  while (t--) solve();
}
