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