#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i;
  cin >> n;
  long int arr[n], sorted[n];
  long long int sum_array[n], sum_sorted[n];
  long long int sum = 0;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    sorted[i] = arr[i];
  }
  sort(sorted, sorted + n);
  sum_array[0] = arr[0];
  sum_sorted[0] = sorted[0];
  for (i = 1; i < n; i++) {
    sum_array[i] = arr[i] + sum_array[i - 1];
    sum_sorted[i] = sorted[i] + sum_sorted[i - 1];
  }
  cin >> m;
  while (m != 0) {
    short type;
    cin >> type;
    int l, r;
    cin >> l >> r;
    if (type == 1) {
      sum = sum_array[r - 1] - sum_array[l - 1] + arr[l - 1];
      cout << sum << endl;
    } else {
      sum = sum_sorted[r - 1] - sum_sorted[l - 1] + sorted[l - 1];
      cout << sum << endl;
    }
    sum = 0;
    m--;
  }
  return 0;
}
