#include <bits/stdc++.h>
using namespace std;
int n;
void cr(vector<long long>& a) {
  for (int i = n; i < 2 * n; ++i) {
    a[i] = a[i - n];
  }
  for (int i = n - 1; i > 0; --i) {
    a[i] = a[2 * i] + a[2 * i + 1];
  }
}
long long ans(vector<long long>& a, int l, int r) {
  l += n;
  r += n;
  long long sum = 0;
  for (; l <= r; l = (l + 1) >> 1, r = (r - 1) >> 1) {
    if (l & 1) sum += a[l];
    if (!(r & 1)) sum += a[r];
  }
  return sum;
}
int main() {
  scanf("%d\n", &n);
  vector<long long> a(n);
  vector<long long> b(n);
  int tmp;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &tmp);
    a[i] = tmp;
    b[i] = tmp;
  }
  sort(b.begin(), b.begin() + n);
  tmp = n;
  int p2 = 0;
  while (tmp > 0) {
    p2 += 1;
    tmp /= 2;
  }
  a.resize(2 * (1 << (p2 + 1)), 0);
  b.resize(2 * (1 << (p2 + 1)), 0);
  n = 1 << (p2 + 1);
  cr(a);
  cr(b);
  int m;
  int t, l, r;
  scanf("%d\n", &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d%d\n", &t, &l, &r);
    if (t == 1) {
      cout << ans(a, l - 1, r - 1) << endl;
    } else if (t == 2) {
      cout << ans(b, l - 1, r - 1) << endl;
    }
  }
  return 0;
}
