#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll test;
  test = 1;
  while (test--) {
    ll n;
    cin >> n;
    ll arr[n];
    ll sortArr[n];
    for (ll i = 0; i < n; i++) {
      ll x;
      cin >> x;
      arr[i] = x;
      sortArr[i] = x;
    }
    sort(sortArr, sortArr + n);
    ll cumulative[n];
    ll sortCumulative[n];
    cumulative[0] = arr[0];
    sortCumulative[0] = sortArr[0];
    for (ll i = 1; i < n; i++) {
      cumulative[i] = cumulative[i - 1] + arr[i];
      sortCumulative[i] = sortCumulative[i - 1] + sortArr[i];
    }
    ll testCases;
    cin >> testCases;
    while (testCases--) {
      ll type, a, b;
      cin >> type >> a >> b;
      a--;
      b--;
      ll *testArr = cumulative;
      if (type == 2) {
        testArr = sortCumulative;
      }
      ll ans = testArr[b];
      if ((a - 1) >= 0) {
        ans = ans - testArr[a - 1];
      }
      cout << ans << endl;
    }
  }
  return 0;
}
