#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i;
  cin >> n;
  vector<long long int> v(n);
  vector<long long int> so(n);
  vector<long long int> vsum(n, 0);
  vector<long long int> sosum(n, 0);
  for (i = 0; i < n; i++) {
    cin >> v[i];
    so[i] = v[i];
  }
  sort(so.begin(), so.end());
  vsum[0] = v[0];
  sosum[0] = so[0];
  for (i = 1; i < n; i++) {
    vsum[i] = vsum[i - 1] + v[i];
    sosum[i] = sosum[i - 1] + so[i];
  }
  {}
  int m;
  cin >> m;
  int t, l, r;
  for (i = 0; i < m; i++) {
    cin >> t >> l >> r;
    l--;
    r--;
    if (t == 1) {
      if (l != 0)
        cout << vsum[r] - vsum[l - 1] << endl;
      else
        cout << vsum[r] << endl;
    } else if (t == 2) {
      if (l != 0)
        cout << sosum[r] - sosum[l - 1] << endl;
      else
        cout << sosum[r] << endl;
    }
  }
}
