#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> pref = a;
  for (long long i = 1; i < n; i++) {
    pref[i] += pref[i - 1];
  }
  vector<long long> b = a;
  sort(b.begin(), b.end());
  vector<long long> spref = b;
  for (long long i = 1; i < n; i++) {
    spref[i] += spref[i - 1];
  }
  long long q;
  cin >> q;
  for (long long i = 0; i < q; i++) {
    long long type, l, r;
    cin >> type >> l >> r;
    l--;
    r--;
    if (type == 1) {
      cout << pref[r] - pref[l] + a[l] << "\n";
    } else {
      cout << spref[r] - spref[l] + b[l] << "\n";
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  clock_t start = clock();
  long long t = 1;
  while (t--) {
    solve();
  }
  clock_t stop = clock();
  return 0;
}
