#include <bits/stdc++.h>
using namespace std;
long long a[100005], b[100005], c[100005];
int main() {
  int q, t, l, r, n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (long long i = 1; i <= n; i++) b[i] = b[i - 1] + a[i];
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) c[i] = c[i - 1] + a[i];
  cin >> q;
  while (q--) {
    cin >> t >> l >> r;
    if (t == 1)
      cout << b[r] - b[l - 1] << "\n";
    else
      cout << c[r] - c[l - 1] << "\n";
  }
  return 0;
}
