#include <bits/stdc++.h>
using namespace std;
long long n, m, pedra[200010], prefix[200010], prefix1[200010];
void solve() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> pedra[i];
    prefix[i] = prefix[i - 1] + pedra[i];
  }
  sort(pedra + 1, pedra + n + 1);
  for (long long i = 1; i <= n; i++) prefix1[i] = prefix1[i - 1] + pedra[i];
  cin >> m;
  for (long long i = 0; i < m; i++) {
    long long op, l, r;
    cin >> op >> l >> r;
    if (op == 1)
      cout << prefix[r] - prefix[l - 1] << "\n";
    else
      cout << prefix1[r] - prefix1[l - 1] << "\n";
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}
