#include <bits/stdc++.h>
const int INF = 2e9;
double eps = 1e-9;
int main() {
  int n, m;
  std::vector<long long> tp, tp1, tp2, tp3;
  std::cin >> n;
  for (int i = 0, j; i < n; ++i) {
    std::cin >> j;
    tp.push_back(j);
    tp1.push_back(j);
  }
  std::sort(tp.begin(), tp.end());
  long long j = 0, k = 0;
  for (int i = 0; i < n; ++i) {
    j += tp1[i];
    k += tp[i];
    tp2.push_back(j);
    tp3.push_back(k);
  }
  std::cin >> m;
  for (int r, l, t; std::cin >> t >> l >> r;) {
    if (t == 1) {
      std::cout << tp2[r - 1] - tp2[l - 1] + tp1[l - 1] << std::endl;
    } else {
      std::cout << tp3[r - 1] - tp3[l - 1] + tp[l - 1] << std::endl;
    }
  }
  getchar();
  getchar();
  exit(0);
}
