#include <bits/stdc++.h>
using namespace std;
int one[112345];
int two[112345];
long long s1[112345];
long long s2[112345];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> one[i];
    two[i] = one[i];
  }
  sort(two + 1, two + n + 1);
  for (long long i = 1; i <= n; i++) {
    s1[i] = one[i] + s1[i - 1];
    s2[i] = two[i] + s2[i - 1];
  }
  int q, type, l, r;
  cin >> q;
  while (q--) {
    cin >> type >> l >> r;
    if (type == 1) {
      cout << s1[r] - s1[l - 1] << "\n";
    } else {
      cout << s2[r] - s2[l - 1] << "\n";
    }
  }
  return 0;
}
