#include <bits/stdc++.h>
using namespace std;
int n, m;
long long a[100005];
long long sum1[100005], sum2[100005];
int main() {
  memset(sum1, 0, sizeof(sum1));
  memset(sum2, 0, sizeof(sum2));
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    sum1[i] = sum1[i - 1] + a[i];
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i) {
    sum2[i] = sum2[i - 1] + a[i];
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int q, l, r;
    cin >> q >> l >> r;
    if (q == 1) {
      cout << sum1[r] - sum1[l - 1] << endl;
    } else {
      cout << sum2[r] - sum2[l - 1] << endl;
    }
  }
  return 0;
}
