#include <bits/stdc++.h>
using namespace std;
long long int n, r, l, t, m, sum, h, i, a[100004], b, j, ar[100003],
    arr[100003];
string s;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) ar[i] += (i == 0) ? a[i] : a[i] + ar[i - 1];
  sort(a, a + n);
  for (i = 0; i < n; i++) arr[i] += (i == 0) ? a[i] : a[i] + arr[i - 1];
  cin >> m;
  while (m--) {
    cin >> t >> l >> r;
    if (t == 1) {
      if (l == 0)
        cout << ar[r - 1] << "\n";
      else
        cout << ar[r - 1] - ar[l - 2] << "\n";
    } else if (t == 2) {
      if (l == 0)
        cout << arr[r - 1] << "\n";
      else
        cout << arr[r - 1] - arr[l - 2] << "\n";
    }
  }
  return 0;
}
