#include <bits/stdc++.h>
using namespace std;
const int OO = (int)2e9;
const double eps = 1e-9;
int daysInMonths[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int di[] = {-1, 0, 1, 0};
int dj[] = {0, 1, 0, -1};
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, l, r, type;
  cin >> n;
  vector<long long> pref(n);
  vector<long long> pref_sorted(n), a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i == 0)
      pref[i] = a[i];
    else
      pref[i] = pref[i - 1] + a[i];
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    pref_sorted[i] = (i == 0 ? a[i] : pref_sorted[i - 1] + a[i]);
  }
  cin >> m;
  while (m--) {
    cin >> type >> l >> r;
    l--, r--;
    if (type == 1)
      cout << (l == 0 ? pref[r] : pref[r] - pref[l - 1]) << "\n";
    else
      cout << (l == 0 ? pref_sorted[r] : pref_sorted[r] - pref_sorted[l - 1])
           << "\n";
  }
  return 0;
}
