#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 * 1000 + 3;
int n;
long long prs[MAXN], a[MAXN], prs2[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i != 0)
      prs[i] = prs[i - 1] + a[i];
    else
      prs[0] = a[0];
  }
  sort(a, a + n);
  prs2[0] = a[0];
  for (int i = 1; i < n; i++) {
    prs2[i] = prs2[i - 1] + a[i];
  }
  int m;
  cin >> m;
  while (m) {
    m--;
    int t, l, r;
    cin >> t >> l >> r;
    l--, r--;
    if (t == 1) {
      if (l == 0) {
        cout << prs[r] << endl;
      } else {
        cout << prs[r] - prs[l - 1] << endl;
      }
    } else {
      if (l == 0) {
        cout << prs2[r] << endl;
      } else {
        cout << prs2[r] - prs2[l - 1] << endl;
      }
    }
  }
  return 0;
}
