#include <bits/stdc++.h>
using namespace std;
long long int n, m, type, l, r, sum = 0, i, j, k;
long long dp[300010];
long long dp2[300010];
int main() {
  cin >> n;
  long long int a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  for (j = 0; j < n; j++) {
    sum = sum + a[j];
    dp[j] = sum;
  }
  sort(a, a + n);
  sum = 0;
  for (k = 0; k < n; k++) {
    sum = sum + a[k];
    dp2[k] = sum;
  }
  cin >> m;
  while (m--) {
    cin >> type >> l >> r;
    if (type == 1) {
      cout << dp[r - 1] - dp[l - 2] << endl;
    } else {
      cout << dp2[r - 1] - dp2[l - 2] << endl;
    }
  }
}
