//前缀和序列
include [HTML_REMOVED]
using namespace std;
const int N = 200010;
typedef long long LL;
int n,m;
LL a[N],b[N],s1[N],s2[N];
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
cin>>a[i];
b[i] = a[i];
}
sort(b+1,b+n+1);
s1[1] = a[1];
s2[1] = b[1];
for(int i = 1;i < n ;i++){
s1[i+1] = s1[i] + a[i+1];
s2[i+1] = s2[i] + b[i+1];
}
cin>>m;
while(m--){
LL q,l,r;
LL ans = 0;
cin>>q>>l>>r;
if(q == 1){
ans = s1[r] - s1[l-1];
cout<<ans<<endl;
}
else if(q == 2){
ans = s2[r] - s2[l-1];
cout<<ans<<endl;
}
}
return 0;
}