#include <bits/stdc++.h>
using namespace std;
const long long N = 123456;
long long n, m, x, l, r;
vector<long long> v1;
vector<long long> v2;
long long a1[N];
long long a2[N];
int main() {
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &x);
    v1.push_back(x);
  }
  v2 = v1;
  sort(v2.begin(), v2.end());
  for (int i = 0; i < v1.size(); i++) {
    a2[i] = v2[i] + a2[i - 1];
    a1[i] = v1[i] + a1[i - 1];
  }
  scanf("%lld", &m);
  for (int i = 0; i < m; i++) {
    long long q;
    scanf("%lld %lld %lld", &q, &l, &r);
    if (q == 1)
      printf("%lld\n", a1[r - 1] - a1[l - 2]);
    else
      printf("%lld\n", a2[r - 1] - a2[l - 2]);
  }
}
