#include <bits/stdc++.h>
using namespace std;
int n, m, op, l, r;
long long arr1[100005];
long long arr2[100005];
int main(int argc, char** argv) {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &arr1[i]);
    arr2[i] = arr1[i];
  }
  sort(arr2, arr2 + n + 1);
  arr1[0] = arr2[0] = 0;
  for (int i = 1; i <= n; i++) {
    arr1[i] += arr1[i - 1];
    arr2[i] += arr2[i - 1];
  }
  scanf("%d", &m);
  while (m--) {
    scanf("%d%d%d", &op, &l, &r);
    if (op == 1) {
      printf("%I64d\n", arr1[r] - arr1[l - 1]);
    } else {
      printf("%I64d\n", arr2[r] - arr2[l - 1]);
    }
  }
  return 0;
}
