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