#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, r, t, m, i, j, n, a[100000];
  long long sum1[100000], sum2[100000];
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", a + i);
  sum1[0] = a[0];
  for (i = 1; i < n; i++) sum1[i] = a[i] + sum1[i - 1];
  sort(a, a + n);
  sum2[0] = a[0];
  for (i = 1; i < n; i++) sum2[i] = a[i] + sum2[i - 1];
  scanf("%d", &m);
  while (m--) {
    scanf("%d%d%d", &t, &l, &r);
    l -= 2;
    r--;
    if (t == 1)
      printf("%I64d\n", sum1[r] - ((l > -1) ? sum1[l] : 0));
    else
      printf("%I64d\n", sum2[r] - ((l > -1) ? sum2[l] : 0));
  }
  return 0;
}
