#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  cin >> x;
  long long arr[x], sumS[x + 1], sum[x + 1];
  for (int i = 0; i < x; i++) cin >> arr[i];
  sum[0] = sumS[0] = 0;
  for (int i = 1; i <= x; i++) sum[i] = sum[i - 1] + arr[i - 1];
  sort(arr, arr + x);
  for (int i = 1; i <= x; i++) sumS[i] = sumS[i - 1] + arr[i - 1];
  int j;
  cin >> j;
  int t, l, r;
  while (j--) {
    cin >> t >> l >> r;
    if (t == 1)
      cout << sum[r] - sum[l - 1] << endl;
    else if (t == 2)
      cout << sumS[r] - sumS[l - 1] << endl;
  }
}
