#include <bits/stdc++.h>
using namespace std;
long long sum(int l, int r, long long p[]) { return p[r] - (l ? p[l - 1] : 0); }
int main() {
  int n;
  scanf("%d", &n);
  static long long a[100010];
  static long long pa[100010];
  static long long s[100010];
  static long long ps[100010];
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    s[i] = a[i];
  }
  sort(s, s + n);
  pa[0] = a[0];
  ps[0] = s[0];
  for (int i = 1; i < n; i++) {
    pa[i] = a[i] + pa[i - 1];
    ps[i] = s[i] + ps[i - 1];
  }
  int qn;
  scanf("%d", &qn);
  for (int i = 0; i < qn; i++) {
    int l, r, t;
    scanf("%d%d%d", &t, &l, &r);
    l--;
    r--;
    if (t == 1)
      printf("%lld\n", sum(l, r, pa));
    else
      printf("%lld\n", sum(l, r, ps));
  }
}
