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