#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  long long int p1[n + 1], p2[n + 1], v[n], i, sum = 0;
  p1[0] = 0;
  p2[0] = 0;
  for (i = 0; i < n; i++) {
    cin >> v[i];
    sum += v[i];
    p1[i + 1] = sum;
  }
  sum = 0;
  sort(v, v + n);
  for (i = 0; i < n; i++) {
    sum += v[i];
    p2[i + 1] = sum;
  }
  int m;
  cin >> m;
  int type, l, r;
  for (i = 0; i < m; i++) {
    cin >> type >> l >> r;
    if (type == 1) {
      cout << p1[r] - p1[l - 1];
    } else {
      cout << p2[r] - p2[l - 1];
    }
    if (i != m - 1) cout << endl;
  }
  return 0;
}
