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