#include <bits/stdc++.h>
using namespace std;
long long dp[100005] = {0}, dp1[100005] = {0};
long long a[100005] = {0};
long long n, m, l, r, t;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    dp[i] = a[i];
    dp[i] += dp[i - 1];
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    dp1[i] = a[i];
    dp1[i] += dp1[i - 1];
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> t >> l >> r;
    if (t == 1) {
      cout << dp[r] - dp[l - 1] << endl;
    } else {
      cout << dp1[r] - dp1[l - 1] << endl;
    }
  }
  return 0;
}
