#include <bits/stdc++.h>
using namespace std;
int n, m;
long long a[5 * 222225];
long long b[5 * 222225];
long long dp1[5 * 222225];
long long dp2[5 * 222225];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  dp1[0] = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    b[i] = a[i];
    dp1[i] = dp1[i - 1] + a[i];
  }
  sort(b + 1, b + n + 1);
  dp2[0] = 0;
  for (int i = 1; i <= n; ++i) dp2[i] = dp2[i - 1] + b[i];
  cin >> m;
  for (int i = 1; i <= m; ++i) {
    int x, l, r;
    cin >> x >> l >> r;
    if (x == 1) cout << dp1[r] - dp1[l - 1] << '\n';
    if (x == 2) cout << dp2[r] - dp2[l - 1] << '\n';
  }
  return 0;
}
