#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, a[100005], b[100005];
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  a[0] = a[0];
  for (long long i = 1; i < n; i++) a[i] = a[i] + a[i - 1];
  b[0] = b[0];
  for (long long i = 1; i < n; i++) b[i] = b[i] + b[i - 1];
  long long ch, m, q, p;
  cin >> m;
  while (m--) {
    cin >> ch >> p >> q;
    if (ch == 1) {
      if (p != 1)
        cout << a[q - 1] - a[p - 2];
      else
        cout << a[q - 1];
    } else {
      if (p != 1)
        cout << b[q - 1] - b[p - 2];
      else
        cout << b[q - 1];
    }
    cout << endl;
  }
  return 0;
}
