#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, l, r, x;
  cin >> n;
  vector<long long> a(n + 1, 0), b(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b.begin(), b.end());
  for (int i = 1; i <= n; i++) {
    a[i] += a[i - 1];
    b[i] += b[i - 1];
  }
  cin >> m;
  while (m--) {
    cin >> x >> l >> r;
    if (x == 1)
      cout << a[r] - a[l - 1] << endl;
    else
      cout << b[r] - b[l - 1] << endl;
  }
}
