#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> v;
  vector<int> ms;
  long long int sv[n];
  memset(sv, 0, sizeof(sv));
  long long int sms[n];
  memset(sms, 0, sizeof(sms));
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
    ms.push_back(tmp);
  }
  sort(ms.begin(), ms.end());
  sv[0] = v[0];
  sms[0] = ms[0];
  for (int i = 1; i < n; i++) {
    sv[i] = sv[i - 1] + v[i];
    sms[i] = sms[i - 1] + ms[i];
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int type, l, r;
    cin >> type >> l >> r;
    long long int sum = 0;
    if (type == 1) {
      cout << sv[r - 1] - sv[l - 1] + v[l - 1] << "\n";
    } else if (type == 2) {
      cout << sms[r - 1] - sms[l - 1] + ms[l - 1] << "\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  for (int i = 0; i < t; i++) {
    solve();
  }
  return 0;
}
