#include <bits/stdc++.h>
using namespace std;
int main() {
  int stones[100011];
  long long prefix1[111111];
  long long prefix2[111111];
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &stones[i]);
    prefix1[i] = prefix1[i - 1] + stones[i];
  }
  sort(stones + 1, stones + n + 1);
  for (int i = 1; i <= n; i++) {
    prefix2[i] = prefix2[i - 1] + stones[i];
  }
  int Question;
  scanf("%d", &Question);
  int type, l, r;
  for (int i = 1; i <= Question; i++) {
    scanf("%d%d%d", &type, &l, &r);
    if (type == 1) {
      printf("%lld\n", prefix1[r] - prefix1[l - 1]);
    } else {
      printf("%lld\n", prefix2[r] - prefix2[l - 1]);
    }
  }
  return 0;
}
