#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<numeric>
#include <cmath>
#include<cstdio>
#include <iomanip>

using namespace std;

int getMid(int s, int e) {
	return s + (e - s) / 2;
}

//get sum given specific range
int getSumUtil(int*st, int ss, int se, int qs, int qe, int si) {
	if (qs <= ss && qe >= se) {
		return st[si];
	}
	if (qe<ss || qs>se) {//if it is outside the range
		return 0;//ignore it
	}
	int mid = getMid(ss,se);
	return getSumUtil(st, ss, mid, qs, qe, 2*si+1)+getSumUtil(st, mid+1, se, qs, qe, 2*si+2);
}

int getSum(int *st, int n, int qs, int qe) {
	if (qs<0 || qe>n - 1 || qs > qe)return -1;
	return getSumUtil(st, 0, n-1, qs, qe, 0);
}

int constructUtil(vector<int>arr, int ss, int se, int *st, int si) {
	if (ss == se)
	{
		st[si] = arr[ss];
		return arr[ss];
	}
	int mid = getMid(ss, se);
	st[si] = constructUtil(arr, ss, mid, st, si*2+1)+constructUtil(arr, mid+1, se, st, si*2+2);
	return st[si];
}

int* constructST(vector<int>arr, int n)
{
	// Allocate memory for the segment tree

	//Height of segment tree
	int x = (int)(ceil(log2(n)));

	//Maximum size of segment tree
	int max_size = 2 * (int)pow(2, x) - 1;

	// Allocate memory
	int* st = new int[max_size];

	// Fill the allocated memory st
	constructUtil(arr, 0, n - 1, st, 0);

	// Return the constructed segment tree
	return st;
}
// Driver code
int main()
{
	int n,tmp,m;
	cin >> n;
	vector<int>arr;
	vector<int>sorted_arr;
	while (n--)
	{
		cin >> tmp;
		arr.push_back(tmp);
		sorted_arr.push_back(tmp);
	}
	sort(sorted_arr.begin(), sorted_arr.end());
	int* stSum = constructST(arr, arr.size());
	int* stMin = constructST(sorted_arr, sorted_arr.size());
	int type,l,r;
	n = arr.size();
	cin >> m;
	while (m--)
	{
		cin >> type >> l >> r;
		if (type == 1) {
			cout << getSum(stSum, n, l-1, r-1) << endl;
		}
		else {
			cout << getSum(stMin, n, l-1, r-1) << endl;
		}
	}
}


#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<numeric>
#include <cmath>
#include<cstdio>
#include <iomanip>

using namespace std;

long long getMid(long long s, long long e) {
	return s + (e - s) / 2;
}

//get sum given specific range
long long getSumUtil(long long*st, long long ss, long long se, long long qs, long long qe, long long si) {
	if (qs <= ss && qe >= se) {
		return st[si];
	}
	if (qe<ss || qs>se) {//if it is outside the range
		return 0;//ignore it
	}
	long long mid = getMid(ss,se);
	return getSumUtil(st, ss, mid, qs, qe, 2*si+1)+getSumUtil(st, mid+1, se, qs, qe, 2*si+2);
}

long long getSum(long long*st, long long n, long long qs, long long qe) {
	if (qs<0 || qe>n - 1 || qs > qe)return -1;
	return getSumUtil(st, 0, n-1, qs, qe, 0);
}

long long constructUtil(vector<long long>arr, long long ss, long long se, long long*st, long long si) {
	if (ss == se)
	{
		st[si] = arr[ss];
		return arr[ss];
	}
	long long mid = getMid(ss, se);
	st[si] = constructUtil(arr, ss, mid, st, si*2+1)+constructUtil(arr, mid+1, se, st, si*2+2);
	return st[si];
}

long long* constructST(vector<long long>arr, long long n)
{
	// Allocate memory for the segment tree

	//Height of segment tree
	long long x = (long long)(ceil(log2(n)));

	//Maximum size of segment tree
	long long max_size = 2 * (long long)pow(2, x) - 1;

	// Allocate memory
	long long* st = new long long[max_size];

	// Fill the allocated memory st
	constructUtil(arr, 0, n - 1, st, 0);

	// Return the constructed segment tree
	return st;
}
// Driver code
int main()
{
	long long n,tmp,m;
	cin >> n;
	vector<long long>arr;
	vector<long long>sorted_arr;
	while (n--)
	{
		cin >> tmp;
		arr.push_back(tmp);
		sorted_arr.push_back(tmp);
	}
	sort(sorted_arr.begin(), sorted_arr.end());
	long long* stSum = constructST(arr, arr.size());
	long long* stMin = constructST(sorted_arr, sorted_arr.size());
	long long type,l,r;
	n = arr.size();
	cin >> m;
	while (m--)
	{
		cin >> type >> l >> r;
		if (type == 1) {
			cout << getSum(stSum, n, l-1, r-1) << endl;
		}
		else {
			cout << getSum(stMin, n, l-1, r-1) << endl;
		}
	}
}


#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<numeric>
#include <cmath>
#include<cstdio>
#include <iomanip>

using namespace std;

long getMid(long s, long e) {
	return s + (e - s) / 2;
}

//get sum given specific range
long getSumUtil(long*st, long ss, long se, long qs, long qe, long si) {
	if (qs <= ss && qe >= se) {
		return st[si];
	}
	if (qe<ss || qs>se) {//if it is outside the range
		return 0;//ignore it
	}
	long mid = getMid(ss,se);
	return getSumUtil(st, ss, mid, qs, qe, 2*si+1)+getSumUtil(st, mid+1, se, qs, qe, 2*si+2);
}

long getSum(long*st, long n, long qs, long qe) {
	if (qs<0 || qe>n - 1 || qs > qe)return -1;
	return getSumUtil(st, 0, n-1, qs, qe, 0);
}

long constructUtil(vector<long>arr, long ss, long se, long*st, long si) {
	if (ss == se)
	{
		st[si] = arr[ss];
		return arr[ss];
	}
	long mid = getMid(ss, se);
	st[si] = constructUtil(arr, ss, mid, st, si*2+1)+constructUtil(arr, mid+1, se, st, si*2+2);
	return st[si];
}

long* constructST(vector<long>arr, long n)
{
	// Allocate memory for the segment tree

	//Height of segment tree
	long x = (long)(ceil(log2(n)));

	//Maximum size of segment tree
	long max_size = 2 * (long)pow(2, x) - 1;

	// Allocate memory
	long* st = new long[max_size];

	// Fill the allocated memory st
	constructUtil(arr, 0, n - 1, st, 0);

	// Return the constructed segment tree
	return st;
}
// Driver code
int main()
{
	long n,tmp,m;
	cin >> n;
	vector<long>arr;
	vector<long>sorted_arr;
	while (n--)
	{
		cin >> tmp;
		arr.push_back(tmp);
		sorted_arr.push_back(tmp);
	}
	sort(sorted_arr.begin(), sorted_arr.end());
	long* stSum = constructST(arr, arr.size());
	long* stMin = constructST(sorted_arr, sorted_arr.size());
	long type,l,r;
	n = arr.size();
	cin >> m;
	while (m--)
	{
		cin >> type >> l >> r;
		if (type == 1) {
			cout << getSum(stSum, n, l-1, r-1) << endl;
		}
		else {
			cout << getSum(stMin, n, l-1, r-1) << endl;
		}
	}
}


#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<numeric>
#include <cmath>
#include<cstdio>
#include <iomanip>

using namespace std;

// Driver code
int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	long long n,tmp,m;
	cin >> n;
	vector<long long>arr,l_arr,r_arr;
	vector<long long>sorted_arr;
	long long sum = 0;
	long long sum_sorted = 0;
	while (n--)
	{
		cin >> tmp;
		arr.push_back(tmp);
		sorted_arr.push_back(tmp);
	}
	sort(sorted_arr.begin(), sorted_arr.end());
	n = arr.size();
	for (int i = 0; i < n;i++) {
		sum += arr[i];
		l_arr.push_back(sum);
		sum_sorted += sorted_arr[i];
		r_arr.push_back(sum_sorted);
	}
	long long type,l,r;

	cin >> m;
	while (m--)
	{
		cin >> type >> l >> r;
		if (type == 1) {
			cout << l_arr[r - 1] - l_arr[l - 1]+arr[l-1] << endl;
		}
		else {
			cout << r_arr[r - 1] - r_arr[l - 1]+sorted_arr[l-1] << endl;
		}
	}
}


#include <algorithm>
#include <iostream>
using namespace std;

int main()
{
    int n;cin>>n;
    long*arr=new long[n+1];
    arr[0]=0;
    for(int i=1;i<n+1;i++)
        cin>>arr[i];

    long*com=new long[n+1];
    com[0]=0;
    for(int i=1;i<n+1;i++)
        com[i]=arr[i]+com[i-1];
    sort(arr,arr+n+1);
    long*g=new long[n+1];
    for(int i=1;i<n+1;i++)
        g[i]=arr[i]+g[i-1];

    int m;cin>>m;
    while(m--){
        int type,l,r;
        cin>>type>>l>>r;
        if(type==1)
            cout<<com[r]-com[l-1]<<endl;
        else
            cout<<g[r]-g[l-1]<<endl;

    }

    return 0;
}


#include <algorithm>
#include <iostream>
using namespace std;

int main()
{
    int n;cin>>n;
    int*arr=new int[n+1];
    arr[0]=0;
    for(int i=1;i<n+1;i++)
        cin>>arr[i];

    long long*com=new long long[n+1];
    com[0]=0;
    for(int i=1;i<n+1;i++)
        com[i]=arr[i]+com[i-1];
    sort(arr,arr+n+1);
    long long*g=new long long[n+1];
    for(int i=1;i<n+1;i++)
        g[i]=arr[i]+g[i-1];

    int m;cin>>m;
    while(m--){
        int type,l,r;
        cin>>type>>l>>r;
        if(type==1)
            cout<<com[r]-com[l-1]<<endl;
        else
            cout<<g[r]-g[l-1]<<endl;

    }

    return 0;
}


#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;

int min(int a, int b){
	return (a<b?a:b);
}

int main(){

	int n;cin >> n;
	vi a(n, 0), b(n), v(n);
	for(int i = 0;i < n;i++){
		cin >> v[i];
		if(i>=1)a[i] = v[i] + a[i-1];
		else a[i] = v[i];
	}

	sort(v.begin(), v.end());
	b[0] = v[0];
	for(int i = 1;i < n;i++){
		b[i] = b[i-1] + v[i];
	}

	int m;cin >> m;

	while(m--){
		int t, l, r;cin >> t >> l >> r;l--;r--;
		if(t==1){
			if(l)cout << a[r] - a[l-1] << "\n";
			else cout << a[r] << "\n";
		}else if(l)cout << b[r] - b[l-1] << "\n";
		else cout << b[r] << "\n";
	}

	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long one[100005], two[100005], ans[100005];
    for (int i = 1; i <= n; i++){
        std::cin >> one[i];
        two[i] = one[i];
    }
    std::sort(two + 1, two + 1 + n);
    for (int i = 2; i <= n; i++)
    {
        one[i] += one[i - 1];
        two[i] += two[i - 1];
    }
    int m;
    std::cin >> m;
    for(int i = 1; i <= m; i++)
    {
        int check, l, r;
        std::cin >> check >> l >> r;
        (check == 1) ? ans[i] = one[r] - one[l-1] : ans[i] = two[r] - two[l-1];
    }
    for (int i = 1; i <= m; i++)
        std::cout << ans[i] << "\n";
    return 0;
}


// Test.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <cctype>
#include <math.h>
#include <vector>
#define MAXN 100001
#define ll long long
//cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');
using namespace std;

int main()
{
    ll n;
    cin >> n;
    vector<ll> vec;
    for (int i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        vec.push_back(a);
    }
    int m;
    cin >> m;
    vector<ll> svec = vec;
    sort(svec.begin(), svec.end());

    ll* arr = new ll[n];
    ll* sarr = new ll[n];
    ll s1, s2;
    s1 = vec[0];
    s2 = svec[0];
    arr[0] = vec[0];
    sarr[0] = svec[0];
    for (int i = 1; i < vec.size(); i++)
    {
        arr[i] = s1 + vec[i];
        s1 += vec[i];
    }
    for (int i = 1; i < svec.size(); i++)
    {
        sarr[i] = s2 + svec[i];
        s2 += svec[i];
    }
    for (int i = 0; i < m; i++)
    {
        ll q, l, r,s;
        cin >> q >> l >> r;
        if (q == 1)
        {
            if (l != 1)
                s = arr[r - 1] - arr[l - 2];
            else
                s = arr[r - 1];
        }
        else
        {
            if (l != 1)
                s = sarr[r - 1] - sarr[l - 2];
            else
                s = sarr[r - 1];
        }

        cout << s<<endl;
    }

    return 0;
}


// Test.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <cctype>
#include <math.h>
#include <vector>
#define MAXN 100001
#define ll long long
//cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');
using namespace std;

int main()
{
    ll n;
    cin >> n;
    vector<ll> vec;
    for (int i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        vec.push_back(a);
    }
    int m;
    cin >> m;
    vector<ll> svec = vec;
    sort(svec.begin(), svec.end());
    for (int i = 0; i < m; i++)
    {
        ll q, l, r,s;
        cin >> q >> l >> r;
        s = 0;
        if (q == 1)
        {
            for (int j = l-1; j < r; j++)
                s += vec[j];
        }
        else
        {
            for (int j = l-1; j < r; j++)
                s += svec[j];
        }
        cout << s<<endl;
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

ll arr[1000000],cum[1000000];
ll sorted[1000000],cumb[1000000];
int main() {

    int n;
    ll x;
    cin>>n;
                           // in vector .. to make V[i] you must make resize , or you use only V.push_back();
    for(int i = 1; i<=n ; i++){
        cin>>x;
        arr[i] = x;
        cum[i] = arr[i]+cum[i-1];
        sorted[i] = x;
    }

    sort(sorted+1,sorted+n);
    for(int i = 1; i<=n ; i++){
        cumb[i] = sorted[i] + cumb[i-1];
    }
    int m;
    cin>>m;
    while(m--){
        int ty,l,r;
        cin>>ty>>l>>r;
        if(ty == 1){cout<<cum[r]-cum[l-1]<<endl;}
        if(ty == 2){cout<<cumb[r]-cumb[l-1]<<endl;}

    }

    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

ll arr[1000000],cum[1000000];
vector<ll> sorted,cumb;
int main() {

    int n;
    ll x;
    cin>>n;
    sorted.resize(n);
    cumb.resize(n);                       // in vector .. to make V[i] you must make resize , or you use only V.push_back();
    for(int i = 1; i<n ; i++){
        cin>>x;
        arr[i] = x;
        cum[i] = arr[i]+cum[i-1];
        sorted[i] = x;
    }

    sort(sorted.begin(),sorted.end());
    for(int i = 1; i<n ; i++){
        cumb[i] = sorted[i] + cumb[i-1];
    }
    int m;
    cin>>m;
    while(m--){
        int ty,l,r;
        cin>>ty>>l>>r;
        if(ty == 1){cout<<cum[r]-cum[l-1]<<endl;}
        if(ty == 2){cout<<cumb[r]-cumb[l-1]<<endl;}

    }

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

ll arr[1000000],cum[1000000];
vector<ll> sorted,cumb;
int main() {

    int n;
    ll x;
    cin>>n;
    sorted.resize(n);
    cumb.resize(n);                       // in vector .. to make V[i] you must make resize , or you use only V.push_back();
    for(int i = 1; i<=n ; i++){
        cin>>x;
        arr[i] = x;
        cum[i] = arr[i]+cum[i-1];
        sorted[i] = x;
    }

    sort(sorted.begin(),sorted.end());
    for(int i = 1; i<=n ; i++){
        cumb[i] = sorted[i] + cumb[i-1];
    }
    int m;
    cin>>m;
    while(m--){
        int ty,l,r;
        cin>>ty>>l>>r;
        if(ty == 1){cout<<cum[r]-cum[l-1]<<endl;}
        if(ty == 2){cout<<cumb[r]-cumb[l-1]<<endl;}

    }

    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

ll arr[1000000],cum[1000000];
vector<ll> sorted,cumb;
int main() {

    int n;
    ll x;
    cin>>n;
    sorted.resize(n);
    cumb.resize(n);                       // in vector .. to make V[i] you must make resize , or you use only V.push_back();
    for(int i = 1; i<n ; i++){
        cin>>x;
        arr[i] = x;
        cum[i] = arr[i]+cum[i-1];
        sorted[i] = x;
    }

    sort(sorted.begin(),sorted.end());
    for(int i = 1; i<n ; i++){
        cumb[i] = sorted[i] + cumb[i-1];
    }
    int m;
    cin>>m;
    while(m--){
        int ty,l,r;
        cin>>ty>>l>>r;
        if(ty == 1){cout<<cum[r]-cum[l-1];}
        if(ty == 2){cout<<cumb[r]-cumb[l-1];}

    }

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

ll arr[1000000],cum[1000000];
ll sorted[1000000],cumb[1000000];
int main() {

    int n;
    ll x;
    cin>>n;
                           // in vector .. to make V[i] you must make resize , or you use only V.push_back();
    for(int i = 1; i<=n ; i++){
        cin>>x;
        arr[i] = x;
        cum[i] = arr[i]+cum[i-1];
        sorted[i] = x;
    }

    sort(sorted+1,sorted+n+1);
    for(int i = 1; i<=n ; i++){
        cumb[i] = sorted[i] + cumb[i-1];
    }
    int m;
    cin>>m;
    while(m--){
        int ty,l,r;
        cin>>ty>>l>>r;
        if(ty == 1){cout<<cum[r]-cum[l-1]<<endl;}
        if(ty == 2){cout<<cumb[r]-cumb[l-1]<<endl;}

    }

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

ll arr[1000000],cum[1000000];
vector<ll> sorted,cumb;
int main() {

    int n;
    ll x;
    cin>>n;
    sorted.resize(n);
    cumb.resize(n);                       // in vector .. to make V[i] you must make resize , or you use only V.push_back();
    for(int i = 1; i<n ; i++){
        cin>>x;
        arr[i] = x;
        cum[i] = arr[i]+cum[i-1];
        sorted[i] = x;
    }

    sort(sorted.begin(),sorted.end());
    for(int i = 1; i<n ; i++){
        cumb[i] = sorted[i] + cumb[i-1];
    }
    int m;
    cin>>m;
    while(m--){
        int ty,l,r;
        cin>>ty>>l>>r;
        if(ty == 1){cout<<cum[r]-cum[l-1]<<endl;}
        if(ty == 2){cout<<cumb[r]-cumb[l-1]<<endl;}

    }

    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	long long n, right, left,m; int type;
	cin >> n;
	vector<long long>vi(n+1),ui(n+1);
	//cin >> vi[0];
	ui[0] = vi[0]=0;
	for (int i = 1; i < n+1; i++) {
		cin >> vi[i];
		ui[i] = vi[i];
		vi[i] = (i == 0 ? vi[i]:vi[i]+vi[i-1]);

	}
	sort(ui.begin(), ui.end());
	for(int i=1;i<n+1;i++)
		ui[i] = (i == 0 ? ui[i] : ui[i] + ui[i - 1]);
	////////////////////////////////////////////////////////////////////////////////
	cin >> m; long long j = 0;
	vector<long long>out(m);
	while (j < m) {
		cin >> type >> right >> left;
		if (type == 1)
			out[j] = vi[left] - vi[right - 1];// << endl;
		else if (type == 2)
			out[j]=ui[left] - ui[right - 1]; //<< endl;
		j++;

	}
	for (int i = 0; i < m; i++)
		cout << out[i] << endl;

}


// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
#include<stdio.h>
using namespace std;

int main()
{
    int n,m,l,r;
    short type;
    cin >> n;
    long long a[100001] = {};
    long long sorteda[100001] = {};
   /* int a[100] = {};
    int sorteda[100] = {};*/
    for (int i = 0;i < n;i++)
    {
        //cin >> a[i];
        scanf("%d", &a[i]);
        sorteda[i] = a[i];
    }

    sort(sorteda, sorteda + n);

    cin >> m;
    for (int i = 0;i < m;i++)
    {
        long long sum = 0;
        scanf("%d", &type);
        scanf("%d", &l);
        scanf("%d", &r);
        //cin >> type >> l >> r;
        if (type == 1)
        {
            for (int j = l - 1;j <= r - 1;j++)
            {
                sum += a[j];
            }
            cout << sum << endl;
        }
        else
        {
            for (int j = l - 1;j <= r - 1;j++)
            {
                sum += sorteda[j];
            }
            //cout << sum << endl;
            printf("%d \n", sum);
        }
    }

}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
#include<stdio.h>
using namespace std;

int main()
{
    int n,m,l,r;
    short type;
    cin >> n;
    long long a[100001] = {};
    long long sorteda[100001] = {};
   /* int a[100] = {};
    int sorteda[100] = {};*/
    for (int i = 0;i < n;i++)
    {
        //cin >> a[i];
        scanf("%d", &a[i]);
        sorteda[i] = a[i];
    }

    sort(sorteda, sorteda + n);

    cin >> m;
    for (int i = 0;i < m;i++)
    {
        long long sum = 0;
        scanf("%d", &type);
        scanf("%d", &l);
        scanf("%d", &r);
        //cin >> type >> l >> r;
        if (type == 1)
        {
            for (int j = l - 1;j <= r - 1;j++)
            {
                sum += a[j];
            }
            //cout << sum << endl;
        }
        else
        {
            for (int j = l - 1;j <= r - 1;j++)
            {
                sum += sorteda[j];
            }
        }
        printf("%lld \n", sum);
    }

}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n,m,l,r;
    short type;
    cin >> n;
    long long a[100001] = {};
    long long sorteda[100001] = {};
   /* int a[100] = {};
    int sorteda[100] = {};*/
    for (int i = 0;i < n;i++)
    {
        cin >> a[i];
        sorteda[i] = a[i];
    }

    sort(sorteda, sorteda + n);

    cin >> m;
    for (int i = 0;i < m;i++)
    {
        long long sum = 0;
        cin >> type >> l >> r;
        if (type == 1)
        {
            for (int j = l - 1;j <= r - 1;j++)
            {
                sum += a[j];
            }
            cout << sum << endl;
        }
        else
        {
            for (int j = l - 1;j <= r - 1;j++)
            {
                sum += sorteda[j];
            }
            cout << sum << endl;
        }
    }

}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
#include<stdio.h>
using namespace std;

int main()
{
    int n,m,l,r;
    short type;
    cin >> n;
    long long a[100001] = {};
    long long sorteda[100001] = {};
   /* int a[100] = {};
    int sorteda[100] = {};*/
    for (int i = 0;i < n;i++)
    {
        //cin >> a[i];
        scanf("%d", &a[i]);
        sorteda[i] = a[i];
    }

    sort(sorteda, sorteda + n);

    cin >> m;
    for (int i = 0;i < m;i++)
    {
        long long sum = 0;
        scanf("%d", &type);
        scanf("%d", &l);
        scanf("%d", &r);
        //cin >> type >> l >> r;
        if (type == 1)
        {
            for (int j = l - 1;j <= r - 1;j++)
            {
                sum += a[j];
            }
            cout << sum << endl;
        }
        else
        {
            for (int j = l - 1;j <= r - 1;j++)
            {
                sum += sorteda[j];
            }
            //cout << sum << endl;
            printf("%d", sum);
        }
    }

}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


#include <iostream>
#include <string>
#include <cmath>
#include<vector>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

unsigned long long sumsorted(long long l, long long r, unsigned long long arr[100000], long long n)
{
   long long ans[10000];
   ans[0]=0;
   sort(arr, arr+n+1);
     for(int i=1; i<=n; i++)
    {   ans[i]=ans[i-1]+arr[i]; }

    if(l==1)
    return ans[r];
	return ans[r]-ans[l-1];
}

unsigned long long sum(long long l, long long r, unsigned long long arr[100000])
{
    if(l==1)
    return arr[r];
	return arr[r]-arr[l-1];
}

    int main()
    {
  unsigned  long long n,m,l,r,type;
  unsigned  long long arr[100000];
   unsigned long long ans[100000];
    ans[0]=0;
    arr[0]=0;
    cin>>n;
   for(int i=1; i<=n; i++)
    { cin>>arr[i];
     ans[i]=ans[i-1]+arr[i]; }

     cin>>m;
     for(int i=0; i<m; i++)
     {
     	cin>>type;
     	if(type==1)
     	{
     		cin>>l>>r;
     		cout<<sum(l,r,ans)<<endl;
		 }
		 else
		 {
		 	cin>>l>>r;
		 	cout<<sumsorted(l,r,arr,n)<<endl;

		 }
	 }

		return 0;

	}


#include <algorithm>
#include <iostream>
using namespace std;
typedef long long LL;
int main()
{
    ios_base::sync_with_stdio(0);
    LL n, m, type, l, r;
    LL arr[100010],sum[100010]={0},sum2[100010]={0};
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>arr[i-1];
        sum[i]=sum[i-1]+arr[i-1];
    }
    sort(arr,arr+n);
    for(int i=1;i<=n;++i)
        sum2[i]=sum2[i-1]+arr[i-1];
    cin>>m;
    for(int i=0;i<m;++i)
    {
        cin>>type>>l>>r;
        cout<<(type==1?sum[r]-sum[l-1]:sum2[r]-sum2[l-1])<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>
#include <cmath>
#include<vector>
#include <algorithm>
//#include <bits/stdc++.h>
using namespace std;

unsigned long long sumsorted(long long l, long long r, unsigned long long ans2[100005])
{

    if(l==1)
    return ans2[r];
	return ans2[r]-ans2[l-1];
}

unsigned long long sum(long long l, long long r, unsigned long long ans[100005])
{
    if(l==1)
    return ans[r];
	return ans[r]-ans[l-1];
}

    int main()
    {

  unsigned  long long n,m,l,r,type;
  unsigned  long long arr[100005];
   unsigned long long ans[100005];
   unsigned long long ans2[100005];
    ans[0]=0;
    ans2[0]=0;
    arr[0]=0;
    cin>>n;
   for(int i=1; i<=n; i++)
    { cin>>arr[i];
     ans[i]=ans[i-1]+arr[i]; }
     sort(arr, arr+n+1);

     for(int i=1; i<=n; i++)
     ans2[i]=ans2[i-1]+arr[i];

     cin>>m;
     for(int i=0; i<m; i++)
     {
     	cin>>type;
     	if(type==1)
     	{
     		cin>>l>>r;
     		cout<<sum(l,r,ans)<<endl;
		 }
		 else
		 {
		 	cin>>l>>r;
		 	cout<<sumsorted(l,r,ans2)<<endl;

		 }
	 }

		return 0;

	}


#include<bits/stdc++.h>

typedef long long int ll;
#define pp pair<ll,ll>
#define dbg printf("f");
#define inf 1000000000000

#define max2(a,b) ((a<b)?b:a)
#define max3(a,b,c) max2(max2(a,b),c)
#define min2(a,b) ((a>b)?b:a)
#define min3(a,b,c) min2(min2(a,b),c)

using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
    ll i,j,k;
    ll n,m;
    ll t,l,r;

    cin>>n;
    ll a[n],b[n],c[n],d[n];

    for(i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }

    sort(b,b+n);

    c[0]=a[0];d[0]=b[0];
    for(i=1;i<n;i++)
    {
        c[i]=a[i]+c[i-1];
        d[i]=b[i]+d[i-1];
    }

    cin>>m;
    for(i=0;i<m;i++)
    {
        cin>>t>>l>>r;
        l--;r--;

        if(t==1)
            cout<<(c[r]-c[l]+a[l])<<endl;
        else
            cout<<(d[r]-d[l]+b[l])<<endl;
    }

    return 0;
}


#include <iostream>
#include <string>
#include <cmath>
#include<vector>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

long long sumsorted(int l, int r, long long arr[10000], int n)
{
   long long ans[10000];
   ans[0]=0;
   sort(arr, arr+n+1);
     for(int i=1; i<=n; i++)
    {   ans[i]=ans[i-1]+arr[i]; }

    if(l==1)
    return ans[r];
	return ans[r]-ans[l-1];
}

long long sum(int l, int r, long long arr[10000])
{
    if(l==1)
    return arr[r];
	return arr[r]-arr[l-1];
}

    int main()
    {
    int n,m,l,r,type;
    long long arr[10000];
    long long ans[10000];
    ans[0]=0;
    arr[0]=0;
    cin>>n;
   for(int i=1; i<=n; i++)
    { cin>>arr[i];
     ans[i]=ans[i-1]+arr[i]; }

     cin>>m;
     for(int i=0; i<m; i++)
     {
     	cin>>type;
     	if(type==1)
     	{
     		cin>>l>>r;
     		cout<<sum(l,r,ans)<<endl;
		 }
		 else
		 {
		 	cin>>l>>r;
		 	cout<<sumsorted(l,r,arr,n)<<endl;

		 }
	 }

		return 0;

	}


#include <iostream>
#include <string>
#include <cmath>
#include<vector>
#include <algorithm>
//#include <bits/stdc++.h>
using namespace std;

unsigned long long sumsorted(long long l, long long r, unsigned long long arr[100010], long long n)
{
   long long ans[100010];
   ans[0]=0;
   sort(arr, arr+n+1);
     for(int i=1; i<=n; i++)
    {   ans[i]=ans[i-1]+arr[i]; }

    if(l==1)
    return ans[r];
	return ans[r]-ans[l-1];
}

unsigned long long sum(long long l, long long r, unsigned long long arr[100010])
{
    if(l==1)
    return arr[r];
	return arr[r]-arr[l-1];
}

    int main()
    {
  unsigned  long long n,m,l,r,type;
  unsigned  long long arr[100010];
   unsigned long long ans[100010];
    ans[0]=0;
    arr[0]=0;
    cin>>n;
   for(int i=1; i<=n; i++)
    { cin>>arr[i];
     ans[i]=ans[i-1]+arr[i]; }

     cin>>m;
     for(int i=0; i<m; i++)
     {
     	cin>>type;
     	if(type==1)
     	{
     		cin>>l>>r;
     		cout<<sum(l,r,ans)<<endl;
		 }
		 else
		 {
		 	cin>>l>>r;
		 	cout<<sumsorted(l,r,arr,n)<<endl;

		 }
	 }

		return 0;

	}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;

int main() {
    int n, t1 = 0, t2 = 0;
    cin >> n;
    vector<int> v(n), u(n), w1(n + 1, 0), w2(n + 1, 0);
    for (int i = 0; i < n; ++i)
        cin >> v[i];
    u = v;
    sort(u.begin(), u.end());
    for (int i = 0; i < n; ++i) {
        t1 += v[i];
        w1[i + 1] = t1;
        t2 += u[i];
        w2[i + 1] = t2;
    }
    int m, c, l, r;
    cin >> m;
    for (int i = 0; i < m; ++i) {
        cin >> c >> l >> r;
        cout << (c == 1 ? w1[r] - w1[l - 1] : w2[r] - w2[l - 1]) << "\n";
    }
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;

int main() {
    long long n, t1 = 0, t2 = 0;
    cin >> n;
    vector<long long> v(n), u(n), w1(n + 1, 0), w2(n + 1, 0);
    for (long long i = 0; i < n; ++i)
        cin >> v[i];
    u = v;
    sort(u.begin(), u.end());
    for (long long i = 0; i < n; ++i) {
        t1 += v[i];
        w1[i + 1] = t1;
        t2 += u[i];
        w2[i + 1] = t2;
    }
    long long m, c, l, r;
    cin >> m;
    for (long long i = 0; i < m; ++i) {
        cin >> c >> l >> r;
        cout << (c == 1 ? w1[r] - w1[l - 1] : w2[r] - w2[l - 1]) << "\n";
    }
}


#include <iostream>
#include <algorithm>

using namespace std;

constexpr int n = (int)1e5 + 100;
int v[n];
long long int vp[n];

int u[n];
long long int up[n];

int main()
{
	ios::sync_with_stdio(0);

	int n;
	cin >> n;

	cin >> v[0];
	vp[0] = v[0];
	u[0] = v[0];

	for (int i = 1; i < n; ++i)
	{
		cin >> v[i];
		u[i] = v[i];

		vp[i] = v[i];
		vp[i] += vp[i - 1];
	}

	std::sort(&u[0], &u[n]);

	up[0] = u[0];
	for (int i = 1; i < n; ++i)
	{
		up[i] = u[i];
		up[i] += up[i - 1];
	}

	int m;
	cin >> m;

	for (int i = 0; i < m; ++i)
	{
		int type, l, r;
		cin >> type >> l >> r;

		--l, --r;

		long long int result = 0;

		switch (type)
		{
		case 1:
		{
			if (l == r)
			{
				result = v[l];
			}
			else
			{
				result = vp[r];
				if (l - 1 >= 0)
					result -= vp[l - 1];
			}

			break;
		}
		case 2:
		{
			if (l == r)
			{
				result = u[l];
			}
			else
			{
				result = up[r];
				if (l - 1 >= 0)
					result -= up[l - 1];
			}

			break;
		}
		}

		std::cout << result << '\n';
	}

	return 0;
}


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
int sumRange(int s, int e, vector<int>& cum_sum)
{
    return cum_sum[e] - cum_sum[s - 1];
}
int main()
{
    int n;
    cin >> n;
    vector<int>in(n+1);
    in[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> in[i];
    }
    vector<int>S(n+1, 0);
    for (size_t i = 1; i <= n; i++)
    {
        S[i] += in[i] + S[i - 1];
    }
    vector<int>sorted = in;
    sort(sorted.begin(), sorted.end());
    vector<int>D(n+1, 0);
    for (size_t i = 1; i <= n; i++)
    {
        D[i] += sorted[i] + D[i - 1];
    }
    int m;
    cin >> m;
    while (m--)
    {
        int choice, l, r;
        cin >> choice >> l >> r;
        if (choice == 1)
        {
            cout << sumRange(l, r, S) << endl;
        }
        else
        {
            cout << sumRange(l, r, D) << endl;
        }
    }

}


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
long long sumRange(int s, int e, vector<long long>& cum_sum)
{
    return cum_sum[e] - cum_sum[s - 1];
}
int main()
{
    int n;
    cin >> n;
    vector<long long>in(n+1);
    in[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> in[i];
    }
    vector<long long>S(n+1, 0);
    for (size_t i = 1; i <= n; i++)
    {
        S[i] += in[i] + S[i - 1];
    }
    vector<long long>sorted = in;
    sort(sorted.begin(), sorted.end());
    vector<long long>D(n+1, 0);
    for (size_t i = 1; i <= n; i++)
    {
        D[i] += sorted[i] + D[i - 1];
    }
    int m;
    cin >> m;
    while (m--)
    {
        int choice, l, r;
        cin >> choice >> l >> r;
        if (choice == 1)
        {
            cout << sumRange(l, r, S) << endl;
        }
        else
        {
            cout << sumRange(l, r, D) << endl;
        }
    }

}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iterator>
#include <fstream>
#include <math.h>

#include <vector>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <list>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)

const double PI = 3.141592653589793238463;
const int INF = 0x3f3f3f3f;
const int mod = 1000000007;

/*------------------------------------------------------------------------------------------------------------*/

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	cin >> n;
	vector<int> a(n);
	vector<ll> prefa(n + 1);
	vector<ll> prefb(n + 1);
	prefa[0] = 0;
	FOR(i, 0, n) {
		cin >> a[i];
		prefa[i + 1] = prefa[i] + a[i];
	}
	sort(a.begin(), a.end());
	prefb[0] = 0;
	FOR(i, 0, n)
		prefb[i + 1] = prefb[i] + a[i];
	int q, t, l, r;
	cin >> q;
	FOR(i, 0, q) {
		cin >> t >> l >> r;
		if (t == 1)
			cout << prefa[r] - prefa[l - 1] << endl;
		else
			cout << prefb[r] - prefb[l - 1] << endl;
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<long long> v;
	for (int i = 0; i < n; i++) {
		long long x;
		cin >> x;
		v.push_back(x);
	}
	vector<long long> sorted = v;
	sort(sorted.begin(), sorted.end());
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		int type, l, r;
		cin >> type >> l >> r;
		l--;
		r--;
		long long tot = 0;
		if (type == 1) {
			for (int j = l; j <= r; j++) {
				tot += v[j];
			}
			cout << tot << endl;
		}
		else {
			for (int j = l; j <= r; j++) {
				tot += sorted[j];
			}
			cout << tot << endl;
		}
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<long long> v;
	vector<long long> sums;
	vector<long long> sumsSorted;
	long long totPrev = 0;
	sums.push_back(0);
	sumsSorted.push_back(0);
	for (int i = 0; i < n; i++) {
		long long x;
		cin >> x;
		v.push_back(x);
		sums.push_back(totPrev + x);
		totPrev += x;
		//cout << sums[i] << endl;
	}
	vector<long long> sorted = v;
	sort(sorted.begin(), sorted.end());
	totPrev = 0;
	for (int i = 0; i < n; i++) {
		int x = sorted[i];
		sumsSorted.push_back(totPrev + x);
		totPrev += x;
		//cout << sumsSorted[i]<<endl;
	}
	int m;
	cin >> m;

	for (int i = 0; i < m; i++) {
		int type, l, r;
		cin >> type >> l >> r;
		l--;
		r;
		long long tot = 0;
		if (type == 1) {
			cout << sums[r] - sums[l] << endl;
		}
		else {
			cout << sumsSorted[r] - sumsSorted[l] << endl;
		}
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

void outVector(vector<int>& a) {
	for (int i = 0; i < a.size(); i++) {
		cout << a[i] << " ";
	}
	cout << "\n";
}

int main() {
	int n;
	cin >> n;
	vector<int> s(n);
	vector<unsigned long long> sums(n + 1);
	vector<unsigned long long> sumsSort(n + 1);
	sums[0] = 0;
	for (int i = 1; i < n + 1; i++) {
		cin >> s[i - 1];
		sums[i] = sums[i - 1] + s[i - 1];
	}
	sort(s.begin(), s.end());
	sumsSort[0] = 0;
	for (int i = 1; i < n + 1; i++) {
		sumsSort[i] = sumsSort[i - 1] + s[i - 1];
	}
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		int a, b, type;
		cin >> type >> a >> b;
		if (type == 1) {
			cout << sums[b] - sums[a - 1] << "\n";
		}
		else {
			cout << sumsSort[b] - sumsSort[a - 1] << "\n";
		}
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

void outVector(vector<int>& a) {
	for (int i = 0; i < a.size(); i++) {
		cout << a[i] << " ";
	}
	cout << "\n";
}

int main() {
	int n;
	cin >> n;
	vector<int> s(n);
	vector<int> sums(n + 1);
	vector<int> sumsSort(n + 1);
	sums[0] = 0;
	for (int i = 1; i < n + 1; i++) {
		cin >> s[i - 1];
		sums[i] = sums[i - 1] + s[i - 1];
	}
	sort(s.begin(), s.end());
	sumsSort[0] = 0;
	for (int i = 1; i < n + 1; i++) {
		sumsSort[i] = sumsSort[i - 1] + s[i - 1];
	}
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		int a, b, type;
		cin >> type >> a >> b;
		if (type == 1) {
			cout << sums[b] - sums[a - 1] << "\n";
		}
		else {
			cout << sumsSort[b] - sumsSort[a - 1] << "\n";
		}
	}

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_set>
#include <string>

using namespace std;

int main() {
	char type;
	int n, q,l,r;
	cin >> n;
	vector<long long> v(n+1), sumU(n+1);
	for (int i = 1; i <= n; ++i) {
		cin >> v[i];
	}
	for (int i = 1; i <= n; ++i) {
		sumU[i] = sumU[i-1]+v[i];
	}
	sort(v.begin(), v.end());
	for (int i = 2; i <= n; ++i) {
		v[i] += v[i - 1];
	}
	cin >> q;
	while (q--) {
		cin >> type >> l >> r;
		if (type & 1) cout << sumU[r] - sumU[l - 1];
		else cout << v[r] - v[l - 1];
		cout << '\n';
	}
	/*system("pause");*/
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <numeric>
#include <functional>
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_set>
#include <string>

using namespace std;

int main() {
	char type;
	int n, q,l,r;
	cin >> n;
	vector<long long> v(n+1), sumU(n+1);
	for (int i = 1; i <= n; ++i) {
		cin >> v[i];
	}
	partial_sum(v.begin(), v.end(), sumU.begin());
	sort(v.begin(), v.end());
	partial_sum(v.begin(), v.end(), v.begin());
	cin >> q;
	while (q--) {
		cin >> type >> l >> r;
		if (type & 1) cout << sumU[r] - sumU[l - 1];
		else cout << v[r] - v[l - 1];
		cout << '\n';
	}
	/*system("pause");*/
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;

ll n, a[100000], m, l, r, type, sm[100001], smsort[100001];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i], sm[i + 1] = sm[i] + a[i];
	sort(a, a + n);
	for (int i = 0; i < n; i++)
		smsort[i + 1] = smsort[i] + a[i];
	cin >> m;
	while (m--)
	{
		cin >> type >> l >> r;
		if (type == 1)
			cout << sm[r] - sm[l - 1] << endl;
		else
			cout << smsort[r] - smsort[l - 1] << endl;
	}
	return 0;
}


#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>

using namespace std;

int main() {
	int n_stn;
	const int lenn = 100000;
	long long cum_a[lenn+1];
	cum_a[0] = 0;
	int arr_stn[lenn]; // random
	long long v_stn[lenn]; // random
	vector <long long > u_stn;	//arranged
	long long cum_b[lenn+1];
	cum_b[0] = 0;
	int m; // # of questions
	int type,l,r;
	long long  sum[lenn];
	cin>> n_stn;

	for (int i = 0 ; i < n_stn ; i++)
	{
		cin>>v_stn[i];
		u_stn.push_back(v_stn[i]);
	}
sort(u_stn.begin(),u_stn.end());
	bool once = true;
	if (once = true)
		{
		for (int i = 1; i <=n_stn;i++)
		cum_a[i] = cum_a[i-1] + v_stn[i-1];
		for (int j = 1; j <=n_stn;j++)
		cum_b[j] = cum_b[j-1] + u_stn[j-1];
		once = false;
		}

	cin>>m;
	for (int i =0;i<m;i++ )
	{
    	cin>> type>>l>>r;
		sum[i] =0;

		if (type ==1)
		{
		    sum[i] =cum_a[r] - cum_a[l-1];
		}
		else if (type ==2)
		{
			sum[i] =cum_b[r] - cum_b[l-1];
		}
	}
	for (int i = 0 ; i<m ; i++)
	{
	    cout<<sum[i]<<endl;
	}
	return 0;
}


#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>

using namespace std;

int main() {
	int n_stn;
	const int lenn = 100000;
	long long cum_a[lenn+1];
	cum_a[0] = 0;
	int arr_stn[lenn]; // random
	long long v_stn[lenn]; // random
	vector <long long > u_stn;	//arranged
	long long cum_b[lenn+1];
	cum_b[0] = 0;
	int m; // # of questions
	int type,l,r;
	long long  sum[lenn];
	cin>> n_stn;

	for (int i = 0 ; i < n_stn ; i++)
	{
		cin>>v_stn[i];
		u_stn.push_back(v_stn[i]);
	}
sort(u_stn.begin(),u_stn.end());
	cin>>m;
	bool once = true;
	for (int i =0;i<m;i++ )
	{
    	cin>> type>>l>>r;
		sum[i] =0;
		if (once = true)
		{
		for (int i = 1; i <=n_stn;i++)
		cum_a[i] = cum_a[i-1] + v_stn[i];
		for (int j = 1; j <=n_stn;i++)
		cum_b[j] = cum_a[j-1] + u_stn[i];
		once = false;
		}
		if (type ==1)
		{
		    sum[i] =cum_a[r] - cum_a[l-1];
		}
		else if (type ==2)
		{
			sum[i] =cum_b[r] - cum_b[l-1];
		}
	}
	for (int i = 0 ; i<m ; i++)
	{
	    cout<<sum[i]<<endl;
	}
	return 0;
}


#include <iostream>
#include<cmath>
#include<vector>
#include <bits/stdc++.h>

using namespace std;

int main() {
	int n_stn;
	const int lenn = 100000;
	int arr_stn[lenn];
	int v_stn[lenn]; // random
	vector <int> u_stn;	//arranged
	int m; // # of questions
	int type,l,r;
	int sum[lenn];
	cin>> n_stn;

	for (int i = 0 ; i < n_stn ; i++)
	{
		cin>>v_stn[i];
		u_stn.push_back(v_stn[i]);
	}
sort(u_stn.begin(),u_stn.end());
	cin>>m;
	for (int i =0;i<m;i++ )
	{
		sum[i] =0;
		cin>> type>>l>>r;
		if (type ==1)
		{
			for ( int j = l-1 ; j<= r-1;j++ )
			sum[i] = sum[i] + v_stn[j];
		}
		else if (type ==2)
		{
			for (int j = l-1 ; j<= r-1;j++ )
			sum[i] = sum[i] + u_stn[j];
		}
	}
	for (int i = 0 ; i<m ; i++)
	{
	    cout<<sum[i]<<endl;
	}
	return 0;
}


#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>

using namespace std;

int main() {
	int n_stn;
	const int lenn = 100000;
	int arr_stn[lenn];
	long long v_stn[lenn]; // random
	vector <long long > u_stn;	//arranged
	int m; // # of questions
	int type,l,r;
	long long  sum[lenn];
	cin>> n_stn;

	for (int i = 0 ; i < n_stn ; i++)
	{
		cin>>v_stn[i];
		u_stn.push_back(v_stn[i]);
	}
sort(u_stn.begin(),u_stn.end());
	cin>>m;
	for (int i =0;i<m;i++ )
	{
		sum[i] =0;
		cin>> type>>l>>r;
		if (type ==1)
		{
			for ( int j = l-1 ; j<= r-1;j++ )
			sum[i] = sum[i] + v_stn[j];
		}
		else if (type ==2)
		{
			for (int j = l-1 ; j<= r-1;j++ )
			sum[i] = sum[i] + u_stn[j];
		}
	}
	for (int i = 0 ; i<m ; i++)
	{
	    cout<<sum[i]<<endl;
	}
	return 0;
}


#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>

using namespace std;

int main() {
	int n_stn;
	const int lenn = 100000;
	long long cum_a[lenn+1];
	cum_a[0] = 0;
	int arr_stn[lenn]; // random
	long long v_stn[lenn]; // random
	vector <long long > u_stn;	//arranged
	long long cum_b[lenn+1];
	cum_b[0] = 0;
	int m; // # of questions
	int type,l,r;
	long long  sum[lenn];
	cin>> n_stn;

	for (int i = 0 ; i < n_stn ; i++)
	{
		cin>>v_stn[i];
		u_stn.push_back(v_stn[i]);
	}
sort(u_stn.begin(),u_stn.end());
	cin>>m;
	bool once = true;
	for (int i =0;i<m;i++ )
	{
		sum[i] =0;
		if (once = true)
		{
		for (int i = 1; i <=n_stn;i++)
		cum_a[i] = cum_a[i-1] + v_stn[i];
		for (int j = 1; j <=n_stn;i++)
		cum_b[j] = cum_a[j-1] + u_stn[i];
		once = false;
		}
		cin>> type>>l>>r;
		if (type ==1)
		{
		    sum[i] =cum_a[r] - cum_a[l-1];
		}
		else if (type ==2)
		{
			sum[i] =cum_b[r] - cum_b[l-1];
		}
	}
	for (int i = 0 ; i<m ; i++)
	{
	    cout<<sum[i]<<endl;
	}
	return 0;
}


#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>

using namespace std;

int main() {
	int n_stn;
	const int lenn = 100000;
	int arr_stn[lenn];
	int v_stn[lenn]; // random
	vector <int> u_stn;	//arranged
	int m; // # of questions
	int type,l,r;
	int sum[lenn];
	cin>> n_stn;

	for (int i = 0 ; i < n_stn ; i++)
	{
		cin>>v_stn[i];
		u_stn.push_back(v_stn[i]);
	}
sort(u_stn.begin(),u_stn.end());
	cin>>m;
	for (int i =0;i<m;i++ )
	{
		sum[i] =0;
		cin>> type>>l>>r;
		if (type ==1)
		{
			for ( int j = l-1 ; j<= r-1;j++ )
			sum[i] = sum[i] + v_stn[j];
		}
		else if (type ==2)
		{
			for (int j = l-1 ; j<= r-1;j++ )
			sum[i] = sum[i] + u_stn[j];
		}
	}
	for (int i = 0 ; i<m ; i++)
	{
	    cout<<sum[i]<<endl;
	}
	return 0;
}


#include <iostream>
#include<cmath>
#include<vector>

using namespace std;

int main() {
	int n_stn;
	const int lenn = 100000;
	int arr_stn[lenn];
	int v_stn[lenn]; // random
	vector <int> u_stn;	//arranged
	int m; // # of questions
	int type,l,r;
	int sum[lenn];
	cin>> n_stn;

	for (int i = 0 ; i < n_stn ; i++)
	{
		cin>>v_stn[i];
		u_stn.push_back(v_stn[i]);
	}
sort(u_stn.begin(),u_stn.end());
	cin>>m;
	for (int i =0;i<m;i++ )
	{
		sum[i] =0;
		cin>> type>>l>>r;
		if (type ==1)
		{
			for ( int j = l-1 ; j<= r-1;j++ )
			sum[i] = sum[i] + v_stn[j];
		}
		else if (type ==2)
		{
			for (int j = l-1 ; j<= r-1;j++ )
			sum[i] = sum[i] + u_stn[j];
		}
	}
	for (int i = 0 ; i<m ; i++)
	{
	    cout<<sum[i]<<endl;
	}
	return 0;
}


#include <iostream>
#include <string>
#include<vector>
#include <map>
#include<set>
#include<math.h>
#include<algorithm>
#include<bitset>
#define ll long long int
using namespace std;

int main()
{
	int n;
	cin >> n;
	ll* a = new ll[n];
	ll* b = new ll[n];
	ll* c = new ll[n];
	ll* d = new ll[n];
	ll sum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		b[i] = a[i];
		sum += a[i];
		c[i] = sum;
	}
	sort(b, b + n);
	sum = 0;
	for (int i = 0; i < n; i++)
	{
		sum += b[i];
		d[i] = sum;
	}
	int t; cin >> t;
	while (t--)
	{
		ll x, y, z;
		cin >> z >> x >> y;
		x--, y--;
		if (z==1)
		{
			if (x - 1 > -1)
				cout << c[y] - c[x - 1] << endl;
			else cout << c[y] << endl;
		}
		else
		{
			if (x - 1 > -1)
				cout << d[y] - d[x - 1] << endl;
			else cout << d[y] << endl;
		}

	}
	return 0;
}


#include <iostream>
#include <iomanip>
#include <vector>
#include <deque>
#include <algorithm>
#include <ctype.h>
#include <string>
#include <map>
#include <numeric>
#include <set>

using namespace std;

int main() {
	int n, m, v, l, r;
	cin >> n;
	vector<int> lists;
	for (int i = 0; i < n; i++) {
		cin >> v; // cost of stones
		lists.push_back(v);
	}
	cin >> m; // # of questions
	int type;
	vector<int> ordered = lists;
	sort(ordered.begin(), ordered.end());
	for (int i = 0; i < m; i++) {
		cin >> type >> l >> r;
		if (type == 1) {
			// sum of unordered from l to r
			if (r == n) {
				cout << fixed << accumulate(lists.begin() + l - 1, lists.end(), 0ll) << "\n";
			}
			else {
				cout << fixed << accumulate(lists.begin() + l - 1, lists.begin() + r, 0ll) << "\n";
			}
		}
		else {
			// sum or ordered from l to r
			if (r == n) {
				cout << fixed << accumulate(ordered.begin() + l - 1, ordered.end(), 0ll) << "\n";
			}
			else {
				cout << fixed << accumulate(ordered.begin() + l - 1, ordered.begin() + r, 0ll) << "\n";
			}

		}
	}
}


#include <iostream>
#include <iomanip>
#include <vector>
#include <deque>
#include <algorithm>
#include <ctype.h>
#include <string>
#include <map>
#include <numeric>
#include <set>

using namespace std;

map<int, long long int> m; // stores summation up to index l
map<int, long long int> orderedM; //
vector<int> lists;
vector<int> ordered;

long long int computeSum(int r, map<int, long long int> *sum, bool isOrder) {
	if (r == 0) {
		return 0ll;
	}
	// if already exist, then return that.

	long long int ans = 0;
	if (isOrder) {
		if (orderedM[r] != 0) {
			return orderedM[r];
		}
		ans = computeSum(r - 1, &orderedM, isOrder) + ordered[r - 1];
		orderedM[r] = ans;
	}
	else {
		if (m[r] != 0) {
			return m[r];
		}
		ans = computeSum(r - 1, &m, isOrder) + lists[r - 1];
		m[r] = ans;
	}
	return ans;
}

void output(int type, int l, int r) {
	long long int ans;
	if (type == 1) { // sum of unordered from l to r
		// m[r] - m[l]
		ans = (m[r] != 0) ? m[r] : computeSum(r, &m, false);
		ans -= (m[l - 1] != 0) ? m[l - 1] : computeSum(l - 1, &m, false);
	}
	else {
		// orderedM[r] - ordered[l]
		ans = (orderedM[r] != 0) ? orderedM[r] : computeSum(r, &orderedM, true);
		ans -= (orderedM[l - 1] != 0) ? orderedM[l - 1] : computeSum(l - 1, &orderedM, true);
	}
	cout << ans << "\n";
}

int main() {
	int n, m, v, l, r;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> v; // cost of stones
		lists.push_back(v);
	}
	cin >> m; // # of questions
	int type;
	ordered = lists;
	sort(ordered.begin(), ordered.end());

	for (int i = 0; i < m; i++) {
		cin >> type >> l >> r;
		output(type, l, r);
	}
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <vector>
using namespace std;

int s1[100001];
int v[100001], s[100001];

bool compare(int a, int b){
	return a > b;
}

int main(){
	ios::sync_with_stdio(0);
	int n, m;

	cin >> n;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		v[i+1] = x;
		if(i > 0){
			v[i+1] += v[i];

		}
		s[i] = x;

	}
	sort(s, s+n);
	s1[1] = s[0];
	for(int i = 2; i <= n; i++){
		s1[i] = s[i-1] + s1[i-1];
	}
	cin >> m;
	while(m--){
		int type, l, r;
		cin >> type >> l >> r;
		if(type == 1){
			if(l == 1){
				cout << v[r] << endl;
			}else{
				cout << v[r] - v[l-1] << endl;
			}
		}else{
			if(l == 1){
				cout << s1[r] << endl;
			}else{
				cout << s1[r] - s1[l-1] << endl;
			}
		}
	}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <vector>
using namespace std;

long long int s1[100001];
long long int v[100001], s[100001];

bool compare(long long int a, long long int b){
	return a > b;
}

int main(){
	ios::sync_with_stdio(0);
	int n, m;

	cin >> n;
	for(int i = 0; i < n; i++){
		long long int x;
		cin >> x;
		v[i+1] = x;
		if(i > 0){
			v[i+1] += v[i];

		}
		s[i] = x;

	}
	sort(s, s+n);
	s1[1] = s[0];
	for(int i = 2; i <= n; i++){
		s1[i] = s[i-1] + s1[i-1];
	}
	cin >> m;
	while(m--){
		int type, l, r;
		cin >> type >> l >> r;
		if(type == 1){
			if(l == 1){
				cout << v[r] << endl;
			}else{
				cout << v[r] - v[l-1] << endl;
			}
		}else{
			if(l == 1){
				cout << s1[r] << endl;
			}else{
				cout << s1[r] - s1[l-1] << endl;
			}
		}
	}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <vector>
using namespace std;

int s1[100001];
int v[100001], s[100001];

int main(){
	ios::sync_with_stdio(0);
	int n, m;

	cin >> n;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		v[i+1] = x;
		if(i > 0){
			v[i+1] += v[i];

		}

	}
	sort(s+n, s);
	s1[1] = s[0];
	for(int i = 2; i <= n; i++){
		s1[i] = s[i] + s1[i-1];
	}
	cin >> m;
	while(m--){
		int type, l, r;
		cin >> type >> l >> r;
		if(type == 1){
			if(l == 1){
				cout << v[r] << endl;
			}else{
				cout << v[r] - v[l-1] << endl;
			}
		}else{
			if(l == 1){
				cout << s1[r] << endl;
			}else{
				cout << s1[r] - s1[l-1] << endl;
			}
		}
	}
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
long long a,b,c,d,k;
int e[100000],f[100000],p[100000],u[100000];
int main() {
	// your code goes here
cin>>a;
for(int i=0;i<a;i++){
	cin>>e[i];
	p[i]=e[i];
}
cin>>b;
for(int j=1;j<=b;j++){
	cin>>c>>d>>k;
	if(c==1){
		f[0]=e[0];
		for(int g=1;g<a;g++)
		f[g]=f[g-1]+e[g];
		if(d==1)
		cout<<f[k-1]<<endl;
		else
		cout<<f[k-1]-f[d-2]<<endl;
	}
	else{
		sort(p,p+a);
		u[0]=p[0];
		for(int w=1;w<a;w++)
		u[w]=u[w-1]+p[w];
		if(d==1)
		cout<<u[k-1]<<endl;
		else
		cout<<u[k-1]-u[d-2]<<endl;

	}

}
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
long long a,b,c,d,e[100000000],f[100000000],p[100000000],u[100000000],k;
char ch;
int main() {
	// your code goes here
cin>>a;
for(int i=0;i<a;i++){
	cin>>e[i];
	p[i]=e[i];
}
cin>>b;
for(int j=1;j<=b;j++){
	cin>>c>>d>>k;
	if(c==1){
		f[0]=e[0];
		for(int g=1;g<a;g++)
		f[g]=f[g-1]+e[g];
		if(d==1)
		cout<<f[k-1]<<endl;
		else
		cout<<f[k-1]-f[d-2]<<endl;
	}
	else{
		sort(p,p+a);
		u[0]=p[0];
		for(int w=1;w<a;w++)
		u[w]=u[w-1]+p[w];
		if(d==1)
		cout<<u[k-1]<<endl;
		else
		cout<<u[k-1]-u[d-2]<<endl;

	}

}
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
long long a,b,c,d,e[100000],f[100000],p[100000],u[100000],k;
char ch;
int main() {
	// your code goes here
cin>>a;
for(int i=0;i<a;i++){
	cin>>e[i];
	p[i]=e[i];
}
f[0]=e[0];
for(int g=1;g<a;g++)
f[g]=f[g-1]+e[g];
sort(p,p+a);
	u[0]=p[0];
		for(int w=1;w<a;w++)
		u[w]=u[w-1]+p[w];
cin>>b;
for(int j=1;j<=b;j++){
	cin>>c>>d>>k;
	if(c==1){
		if(d==1)
		cout<<f[k-1]<<endl;
		else
		cout<<f[k-1]-f[d-2]<<endl;
	}
	else{

		if(d==1)
		cout<<u[k-1]<<endl;
		else
		cout<<u[k-1]-u[d-2]<<endl;

	}

}
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
long long a,b,c,d,e[100000],f[100000],p[100000],u[100000],k;
char ch;
int main() {
	// your code goes here
cin>>a;
for(int i=0;i<a;i++){
	cin>>e[i];
	p[i]=e[i];
}
cin>>b;
for(int j=1;j<=b;j++){
	cin>>c>>d>>k;
	if(c==1){
		f[0]=e[0];
		for(int g=1;g<a;g++)
		f[g]=f[g-1]+e[g];
		if(d==1)
		cout<<f[k-1]<<endl;
		else
		cout<<f[k-1]-f[d-2]<<endl;
	}
	else{
		sort(p,p+a);
		u[0]=p[0];
		for(int w=1;w<a;w++)
		u[w]=u[w-1]+p[w];
		if(d==1)
		cout<<u[k-1]<<endl;
		else
		cout<<u[k-1]-u[d-2]<<endl;

	}

}
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int a,b,c,d,e[100000],f[100000],p[100000],u[100000],k;
char ch;
int main() {
	// your code goes here
cin>>a;
for(int i=0;i<a;i++){
	cin>>e[i];
	p[i]=e[i];
}
cin>>b;
for(int j=1;j<=b;j++){
	cin>>c>>d>>k;
	if(c==1){
		f[0]=e[0];
		for(int g=1;g<a;g++)
		f[g]=f[g-1]+e[g];
		if(d==1)
		cout<<f[k-1]<<endl;
		else
		cout<<f[k-1]-f[d-2]<<endl;
	}
	else{
		sort(p,p+a);
		u[0]=p[0];
		for(int w=1;w<a;w++)
		u[w]=u[w-1]+p[w];
		if(d==1)
		cout<<u[k-1]<<endl;
		else
		cout<<u[k-1]-u[d-2]<<endl;

	}

}
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
long long a,b,c,d,e[1000000],f[1000000],p[1000000],u[1000000],k;
char ch;
int main() {
	// your code goes here
cin>>a;
for(int i=0;i<a;i++){
	cin>>e[i];
	p[i]=e[i];
}
cin>>b;
for(int j=1;j<=b;j++){
	cin>>c>>d>>k;
	if(c==1){
		f[0]=e[0];
		for(int g=1;g<a;g++)
		f[g]=f[g-1]+e[g];
		if(d==1)
		cout<<f[k-1]<<endl;
		else
		cout<<f[k-1]-f[d-2]<<endl;
	}
	else{
		sort(p,p+a);
		u[0]=p[0];
		for(int w=1;w<a;w++)
		u[w]=u[w-1]+p[w];
		if(d==1)
		cout<<u[k-1]<<endl;
		else
		cout<<u[k-1]-u[d-2]<<endl;

	}

}
	return 0;
}


#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e[100000],f[100000],p[100000],u[100000],k;
char ch;
int main() {
	// your code goes here
cin>>a;
for(int i=0;i<a;i++){
	cin>>e[i];
	p[i]=e[i];
}
f[0]=e[0];
for(int g=1;g<a;g++)
f[g]=f[g-1]+e[g];
sort(p,p+a);
	u[0]=p[0];
		for(int w=1;w<a;w++)
		u[w]=u[w-1]+p[w];
cin>>b;
for(int j=1;j<=b;j++){
	cin>>c>>d>>k;
	if(c==1){
		if(d==1)
		cout<<f[k-1]<<endl;
		else
		cout<<f[k-1]-f[d-2]<<endl;
	}
	else{

		if(d==1)
		cout<<u[k-1]<<endl;
		else
		cout<<u[k-1]-u[d-2]<<endl;

	}

}
	return 0;
}


#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e[100000],f[100000],p[100000],u[100000],k;
char ch;
int main() {
	// your code goes here
cin>>a;
for(int i=0;i<a;i++){
	cin>>e[i];
	p[i]=e[i];
}
cin>>b;
for(int j=1;j<=b;j++){
	cin>>c>>d>>k;
	if(c==1){
		f[0]=e[0];
		for(int g=1;g<a;g++)
		f[g]=f[g-1]+e[g];
		if(d==1)
		cout<<f[k-1]<<endl;
		else
		cout<<f[k-1]-f[d-2]<<endl;
	}
	else{
		sort(p,p+a);
		u[0]=p[0];
		for(int w=1;w<a;w++)
		u[w]=u[w-1]+p[w];
		if(d==1)
		cout<<u[k-1]<<endl;
		else
		cout<<u[k-1]-u[d-2]<<endl;

	}

}
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
long long a,b,c,d,e[10000000],f[10000000],p[10000000],u[10000000],k;
int main() {
	// your code goes here
cin>>a;
for(int i=0;i<a;i++){
	cin>>e[i];
	p[i]=e[i];
}
cin>>b;
for(int j=1;j<=b;j++){
	cin>>c>>d>>k;
	if(c==1){
		f[0]=e[0];
		for(int g=1;g<a;g++)
		f[g]=f[g-1]+e[g];
		if(d==1)
		cout<<f[k-1]<<endl;
		else
		cout<<f[k-1]-f[d-2]<<endl;
	}
	else{
		sort(p,p+a);
		u[0]=p[0];
		for(int w=1;w<a;w++)
		u[w]=u[w-1]+p[w];
		if(d==1)
		cout<<u[k-1]<<endl;
		else
		cout<<u[k-1]-u[d-2]<<endl;

	}

}
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
long a,b,c,d,e[1000000],f[1000000],p[1000000],u[1000000],k;
char ch;
int main() {
	// your code goes here
cin>>a;
for(int i=0;i<a;i++){
	cin>>e[i];
	p[i]=e[i];
}
cin>>b;
for(int j=1;j<=b;j++){
	cin>>c>>d>>k;
	if(c==1){
		f[0]=e[0];
		for(int g=1;g<a;g++)
		f[g]=f[g-1]+e[g];
		if(d==1)
		cout<<f[k-1]<<endl;
		else
		cout<<f[k-1]-f[d-2]<<endl;
	}
	else{
		sort(p,p+a);
		u[0]=p[0];
		for(int w=1;w<a;w++)
		u[w]=u[w-1]+p[w];
		if(d==1)
		cout<<u[k-1]<<endl;
		else
		cout<<u[k-1]-u[d-2]<<endl;

	}

}
	return 0;
}


#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>

void main()
{ long long size=0;
  cin>>size;
  vector <long long> v(size);
  for (long long i = 0; i < size; i++)  //second line
	  {
	    cin>>v[i];
	  }

  vector<long long> vSorted (v);
  sort ( vSorted.begin(), vSorted.end() );

  long long numQuestions=0;
  cin>>numQuestions;
  long long sizeArr=numQuestions*3;
  long long *arr= new long long [ sizeArr ];
  long long *arrAnswers= new long long [numQuestions];

  for (long long i = 0; i < sizeArr ; i++)
		  {  cin>>arr[i];  }
//************************************************

  long long k=0;

  for (long long i = 0; i < sizeArr ; i=i+3)
	  {
       long long s=0;
	   long long stop= arr[i+2];
	    if (arr[i]==1)
			{

			for (long long j = arr[i+1]; j <= (stop); j++)
				{
				s= s+ v[j-1];
				}
			arrAnswers[k]=s;
			k++;
			}

		if (arr[i]==2)
			{
			long long stop= arr[i+2];
			for (long long j = arr[i+1]; j <= (stop); j++)
				{
				s= s+ vSorted[j-1];
				}
			arrAnswers[k]=s;
			k++;
			}

	  }//end for

  for(long long i=0; i<numQuestions;i++)
	  { cout<<arrAnswers[i]<<endl; }

}


#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>

void main()
{ int size=0;
  cin>>size;
  vector <int> v(size);
  for (int i = 0; i < size; i++)  //second line
	  {
	    cin>>v[i];
	  }

  vector<int> vSorted (v);
  sort ( vSorted.begin(), vSorted.end() );

  int numQuestions=0;
  cin>>numQuestions;
  int sizeArr=numQuestions*3;
  int *arr= new int [ sizeArr ];
  int *arrAnswers= new int [numQuestions];

  for (int i = 0; i < sizeArr ; i++)
		  {  cin>>arr[i];  }
//************************************************

  int k=0;

  for (int i = 0; i < sizeArr ; i=i+3)
	  {
       int s=0;
	   int stop= arr[i+2];
	    if (arr[i]==1)
			{

			for (int j = arr[i+1]; j <= (stop); j++)
				{
				s= s+ v[j-1];
				}
			arrAnswers[k]=s;
			k++;
			}

		if (arr[i]==2)
			{
			int stop= arr[i+2];
			for (int j = arr[i+1]; j <= (stop); j++)
				{
				s= s+ vSorted[j-1];
				}
			arrAnswers[k]=s;
			k++;
			}

	  }//end for

  for(int i=0; i<numQuestions;i++)
	  { cout<<arrAnswers[i]<<endl; }

}


#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>

void main()
{ long long size=0;
  cin>>size;
  vector <long long> v(size);
  for (long long i = 0; i < size; i++)  //second line
	  {
	    cin>>v[i];
	  }

  vector<long long> vSorted (v);
  sort ( vSorted.begin(), vSorted.end() );

  long long numQuestions=0;
  cin>>numQuestions;
  long long sizeArr=numQuestions*3;
  long long *arr= new long long [ sizeArr ];
  long long *arrAnswers= new long long [numQuestions];

  for (long long i = 0; i < sizeArr ; i++)
		  {  cin>>arr[i];  }

  vector<long long> sumArr(size,0);
  long long sum=0;
  for (long long i = 0; i < size; i++)
	  {
	  sum= sum + v[i];
	   sumArr[i]=sum;
	  }

   vector<long long> sumArrSorted(size,0);
  long long sum1=0;
  for (long long i = 0; i < size; i++)
	  {
	  sum1= sum1 + vSorted[i];
	   sumArrSorted[i]=sum1;
	  }
//************************************************

  long long k=0;

  for (long long i = 0; i < sizeArr ; i=i+3)
	  {
       long long s=0;
	   long long stop= arr[i+2] -1;
	   long long l=arr[i+1]-1;

	    if (arr[i]==1)
			{

			 if (l==stop)
					{
					  arrAnswers[k]= v[l];
					  k++;
					}

				else if (l !=0)
			{
			arrAnswers[k]=  sumArr[stop] - sumArr[l-1]  ;
			k++;
			}
				else if (l==0 )
					{
					  arrAnswers[k]=  sumArr[stop];
		            	k++;
					}
			}

		else if (arr[i]==2)
			{

			 if (l==stop)
					{
					arrAnswers[k]= vSorted[l];
					  k++;
					}

			 else if (l !=0)
			{
			arrAnswers[k]=  sumArrSorted[stop] - sumArrSorted[l-1]  ;
			k++;
			}
				else if (l==0 )
					{
					  arrAnswers[k]=  sumArrSorted[stop] ;//- sumArrSorted[l]  ;
		            	k++;
					}

			}//end els if

	  }//end for

  for(long long i=0; i<numQuestions;i++)
	  { cout<<arrAnswers[i]<<endl; }

}


#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>
#include<unordered_map>

#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (1000000007)

using namespace std;

//fast-exponentiation-lli
lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}

void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}

void disp_arr(vector<lli>* arr) {
	for (int i = 0; i < arr->size(); i++)cout << (*(arr))[i] << " ";
}

lli gcd(lli a, lli b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);

}

/* Iterative Function to calculate (x^y)%p in O(log y) */
lli power(lli x, unsigned lli y, lli p)
{
	lli res = 1;      // Initialize result
	x = x % p;  // Update x if it is more than or equal to p
	while (y > 0){
		// If y is odd, multiply x with result
		if (y & 1)res = (res*x) % p;
		// y must be even now
		y = y >> 1;
		x = (x*x) % p;
	}
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n; cin >> n;
	vector<lli>arr(n); take_in(&arr);
	vector<lli> sorted = arr; sort(sorted.begin(), sorted.end());
	vector<vector<lli>> pref(2, vector<lli>(n));
	for (int i = 0; i < n; i++) {
		if (i == 0)pref[0][i] = arr[i];
		else pref[0][i] = pref[0][i - 1] + arr[i];
	}
	for (int i = 0; i < n; i++) {
		if (i == 0)pref[1][i] = sorted[i];
		else pref[1][i] = pref[1][i - 1] + sorted[i];
	}
	int m; cin >> m;
	while (m--) {
		lli type, l, r; cin >> type >> l >> r;
		if (l == 1) {
			cout << pref[type - 1][r - 1] ;
		}
		else cout << pref[type - 1][r - 1] - pref[type - 1][l - 2];
		endl;
	}
	//system("PAUSE");
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <bitset>

using namespace std;

vector <vector<int>> tree;

/*
int toInteger(int n, int base) {
	int res = 0;

	for (int i = 0; n > 0; n /= 10) {
		res += (n % 10) * pow(base, i);
		i++;
	}

	return res;
}

string toBinary(int n) {
	string res = "";

	while (n != 0) {
		res = (n % 2 == 0 ? "0" : "1") + res;
		n /= 2;
	}

	return res;
}
*/

/*
class Vertex {
public:
	int vis = 0, parent = -1;
	vector<int> neighs;
};

vector <Vertex> graph;
vector<int> colors;
int found = 0;

void dfs(int v, int p) {
	colors[v] = 1; // GREY

	for (int i = 0; i < graph[v].neighs.size(); i++) {
		// is colored already, it's parent isn't current vertex v,
		if (colors[graph[v].neighs[i]] == 1 && graph[graph[v].neighs[i]].parent != v &&
			(find(graph[graph[v].neighs[i]].neighs.begin(), graph[graph[v].neighs[i]].neighs.end(), v) != graph[graph[v].neighs[i]].neighs.end())) {
			found = 1;
		}
	}
	colors[v] = 2; // BLACK
}*/

int main() {
	// not done
	/* 467B
	int n, m, k, sum = 0;
	cin >> n >> m >> k;

	vector <int> arr(m);
	int player;

	for (int i = 0; i < m; i++)	{
		cin >> arr[i];
	}

	cin >> player;

	string playerBin = bitset<8>(player).to_string();

	for (int i = 0; i < arr.size(); i++) {
		string binary = bitset<8>(arr[i]).to_string();
		int diffs = 0;

		for (int j = 0; j < max(binary.length(), playerBin.length()); j++) {
			if ((j < binary.length()) && (j < playerBin.length())) {
				diffs += ((int)binary[j]) ^ ((int)playerBin[j]);
			}
			else if (j == binary.length()) {
				diffs += (int)playerBin[j];
			}
			else if (j == playerBin.length()) {
				diffs += (int)binary[j];
			}
		}

		if (diffs <= k) sum++;
	}

	cout << sum << endl;
*/

	/* 349A
	int n;
	cin >> n;
	int *arr = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}

	int hund = 0,
		fiv = 0,
		twfiv = 0;

	for (int i = 0; i < n; i++)	{
		if (arr[i] == 25) {
			twfiv++;
		}
		else if (arr[i] == 50) {
			if (twfiv > 0) {
				twfiv--;
				fiv++;
			}
			else {
				cout << "NO" << endl;
				system("pause");
				return 0;
			}
		}
		else if (arr[i] == 100) {
			if (twfiv > 0 && fiv > 0) {
				fiv--;
				twfiv--;
				hund++;
			}
			else if (fiv == 0 && twfiv > 2) {
				twfiv -= 3;
				hund++;
			}
			else {
				cout << "NO" << endl;
				system("pause");
				return 0;
			}
		}
	}

	cout << "YES" << endl;*/

	/* 279B
	int n, t;
	cin >> n >> t;
	int *arr = new int[n];

	for (int i = 0; i < n; i++)	{
		cin >> arr[i];
	}

	int index = 0, sum = 0, max = 0;

	for (int i = 0; i < n; i++)	{
		sum += arr[i];

		if (sum > t) {
			if (i != index) {
				int k = (i - index) ? i - index : 1;
				sum -= arr[index];
				index++;
				if (k > max) max = k;
			}
			else {
				int k = 0;
				sum -= arr[index];
				index++;
				if (k > max) max = k;
			}
		}
		else if (sum == t) {
			int k = (i - index) ? i - index + 1 : 1;
			sum -= arr[index];
			index++;
			if (k > max) max = k;
		}
		else if (i == n - 1) {
			int k = (i - index) ? i - index + 1 : 1;
			if (k > max) max = k;
		}
	}

	cout << max << endl;
	*/

	/* #588A
	int n;
	cin >> n;

	int *costs = new int[n];
	int *amount = new int[n];

	for (int i = 0; i < n; i++)	{
		cin >> amount[i] >> costs[i];
	}

	int sum = 0, superPrice = -1;

	for (int i = 0; i < n - 1; i++)	{
		if (costs[i] > costs[i + 1]) {
			sum += amount[i] * costs[i];
		}
		else if (costs[i] <= costs[i + 1]) {
			sum += amount[i] * costs[i];
			superPrice = costs[i];

			int j;
			for (j = i; j < n - 1; j++) {
				if (costs[i] <= costs[j + 1]) {
					sum += amount[j + 1] * costs[i];
				}
				else {
					superPrice = -1;
					break;
				}
			}

			i = j;
		}
	}

	if (superPrice == -1) {
		sum += costs[n - 1] * amount[n - 1];
	}

	cout << sum << endl;
	*/

	// sent to codeforces
	/* 115A
	int n, p;
	cin >> n;
	tree.resize(n);

	for (int i = 0; i < n; i++)	{
		cin >> p;
		if (p != -1) p--;

		tree[i].push_back(p);
		tree[p].push_back(i);
	}

	dfs(0, -1);
	*/

	// ITMO https://olymp.ifmo.ru/files/2017-10/e24a/49ed/8fb94a19-97d1-8522fa44e303.pdf
	/* #1
	int num8, num16, num32;
	int N = 0;

	while (N <= 8) {
		num8 = 1 * 100 + N * 10 + 1;
		num16 = 1 * 100 + N * 10 + 1;
		num32 = 1 * 100 + N * 10 + 1;

		num8 = toInteger(num8, 8);
		num16 = toInteger(num16, 16);
		num32 = toInteger(num32, 32);

		string binary = toBinary(num8 + num16 + num32);

		int ones = 0;

		for (int i = 0; i < binary.length(); i++) {
			if (binary[i] == '1') {
				ones++;
			}
		}

		if (ones == 6) {
			cout << N << endl;
			system("pause");
			return 0;
		}

		N++;
	}*/

	/* #939A
	int n, a;
	cin >> n;
	graph.resize(n);
	colors.resize(n);

	for (int i = 0; i < n; i++) {
		cin >> a;
		a--;
		graph[i].neighs.push_back(a);
		graph[a].parent = i;
	}

	for (int i = 0; i < n; i++)
		if (colors[i] == 0) dfs(i, -1);

	found ? (cout << "YES") : (cout << "NO");
	*/

	/* 433B */

	long long n, m;
	cin >> n;
	vector <long long> arr(n);
	vector <long long> sorted(n);

	cin >> arr[0];
	sorted[0] = arr[0];

	for (long long i = 1; i < n; i++) {
		cin >> arr[i];
		sorted[i] = arr[i];

		arr[i] += arr[i - 1];
	}

	sort(sorted.begin(), sorted.end());

	for (long long i = 1; i < n; i++) {
		sorted[i] += sorted[i - 1];
	}

	cin >> m;
	long long type, l, r;

	for (long long i = 0; i < m; i++)	{
		cin >> type >> l >> r;
		l--;
		r--;
		if (type == 1) {
// 			cout << "ans: ";

			if (l) cout << arr[r] - arr[l - 1] << endl;
			else cout << arr[r] << endl;
		}
		else if (type == 2) {
// 			cout << "ans: ";

			if (l) cout << sorted[r] - sorted[l - 1] << endl;
			else cout << sorted[r] << endl;
		}
	}

// 	system("pause");
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int n,m;
	cin>>n;
	vector <long long int > v(n);
	vector <long long int > v1(n);
	long long int i,j,a,b,sum,l,r;
	for(i=0;i<n;i++)
	{
		cin>>v[i];
		v1[i]=v[i];
	}
	cin>>m;
	sort(v.begin(),v.end());
	while(m--)
	{
		sum=0;
		cin>>a>>l>>r;
		if(a==1)
		{
			for(i=l-1;i<r;i++)
				sum+=v1[i];
			cout<<sum<<endl;
		}
		else
		{
			for(i=l-1;i<r;i++)
				sum+=v[i];
			cout<<sum<<endl;
		}
	}
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int n,m;
	cin>>n;
	vector <long long int > v(n);
	vector <long long int > v1(n);
	vector <long long int > sumv(n);
	vector <long long int > sumv1(n);
	long long int i,j,a,b,sum,l,r;
	for(i=0;i<n;i++)
	{
		cin>>v[i];
		v1[i]=v[i];
	}
	cin>>m;
	sort(v.begin(),v.end());
	sumv[0]=v[0];
	sumv1[0]=v1[0];
	for(i=1;i<n;i++)
	{
		sumv[i]=sumv[i-1]+v[i];
		sumv1[i]=sumv1[i-1]+v1[i];
	}
	while(m--)
	{
		sum=0;
		cin>>a>>l>>r;
		if(a==1)
			cout<<(sumv1[r-1]-sumv1[l-1]+v1[l-1])<<endl;
		else
			cout<<(sumv[r-1]-sumv[l-1]+v[l-1])<<endl;
	}
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

vector<long long> vec;
vector<long long> sorted;
void main(){

	vec.push_back(0);
	int n;
	cin >> n;
		int x;
for (int i = 0; i < n; i++){
		cin >> x;
		vec.push_back(x);
	}
	sorted = vec;  //get the sorted one for type 2
sort(sorted.begin(), sorted.end());

	for (int i = 1; i <= n; i++){
		vec[i] += vec[i - 1];
		sorted[i] += sorted[i - 1];
	}

	int m; // num_of_qus;
	cin >> m;
	int type;
	int l;
	int r;
while(m--){
	cin >> type >> l >> r;
		if (type == 1) //if type one
				cout << vec[r] - vec[l - 1] << endl;

		if (type == 2)
				cout << sorted[r] - sorted[l - 1] << endl;

	}

}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

int main()
{

    int n, m, a, b, c;
    long long x;
    vector<long long> stones;
    vector<long long> unsorted;
    vector<long long> sorted;

    cin>>n;
    while(n--){
        cin>>x;
        stones.push_back(x);
    }

    unsorted.push_back(0);
    sorted.push_back(0);
    long long total = 0;
    for (long long stone : stones){
        total += stone;
        unsorted.push_back(total);
    }

    sort(stones.begin(), stones.end());
    total = 0;
    for (long long stone : stones){
        total += stone;
        sorted.push_back(total);
    }

    cin>>m;
    while(m--){
        cin>>a>>b>>c;
        if (a == 1) cout<<unsorted[c] - unsorted[b - 1]<<'\n';
        else cout<<sorted[c] - sorted[b - 1]<<'\n';
    }
    return 0;
}


#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<numeric>
using namespace std;

int main()
{
	int m, n;
	cin >> n;

	vector<unsigned long long>v(n);

	for (size_t i = 0; i < n; i++)
	{
		cin >> v[i];
	}
	cin >> m;
	vector<unsigned long long>choose(m);
	vector<unsigned long long>l(m);
	vector<unsigned long long>r(m);

	int i = 0;
	int t = m;
	while (t--)
	{
		cin >> choose[i] >> l[i] >> r[i];
		i++;
	}

	vector<unsigned long long>sorted = v;
	sort(sorted.begin(), sorted.end());

	i = 0;
	while (m--)
	{
		if (choose[i] == 1)
		{
			unsigned long long sum = accumulate(v.begin()+l[i]-1, v.begin()+r[i], unsigned long long(0));
			cout << sum << endl;
		}
		else
		{
			unsigned long long sum = accumulate(sorted.begin() + l[i] - 1, sorted.begin() + r[i] , unsigned long long(0));
			cout << sum << endl;
		}
		i++;
	}

}


#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<numeric>
using namespace std;

#define ll long long

int main()
{
	ll n;
	cin >> n;
	vector<ll>v(n);
	vector<ll>sum(n+1);
	vector<ll>sumS(n+1);
	vector<ll>sorted(n);
	for (size_t i = 0; i < n; i++)
	{
		cin >> v[i];
		sorted[i] = v[i];
	}
	sort(sorted.begin(), sorted.end());

	sum[0] = 0;
	sumS[0] = 0;

	for (size_t i = 1; i <= n; i++)
	{
		sum[i] = sum[i - 1] + v[i-1];
		sumS[i] = sumS[i - 1] + sorted[i-1];
	}

	ll m;
	cin >> m;
	for (size_t i = 0; i < m; i++)
	{
		ll q, l, r;
		cin >> q >> l >> r;
		if (q == 1)
		{
			cout << sum[r] - sum[l-1] << endl;
		}

		else
		{
			cout << sumS[r] - sumS[l - 1]<<endl;

		}
	}
}


#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<numeric>
using namespace std;

int main()
{
	int m, n;
	cin >> n;

	vector<unsigned long long>v(n);

	for (size_t i = 0; i < n; i++)
	{
		cin >> v[i];
	}
	cin >> m;
	vector<unsigned long long>sum(n+1);
	vector<unsigned long long>sumS(n+1);

	int i = 0;
	int t = m;

	vector<unsigned long long>sorted = v;
	sort(sorted.begin(), sorted.end());
	sum[0] = 0;
	sumS[0]=sorted[0];
	for (size_t i = 1; i < n+1; i++)
	{
		sum[i] = sum[i-1]+v[i-1];
		sumS[i] = sumS[i-1]+sorted[i-1];
	}
	vector<unsigned long long>ans(m);
	int k = 0;
	while (t--)
	{
		int c, l, r;
		cin >> c >> l >> r;

		if (c == 1)
		{
			ans[k] = sum[r] - sum[l - 1];
		}
		else
		{
			ans[k] =sumS[r] - sumS[l - 1];
		}
		k++;
	}
	for (size_t i = 0; i < m; i++)
	{
		cout << ans[i];
		if (i != m - 1)
			cout << endl;
	}

}


#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
using namespace std;

int main()
{
	int m, n;
	cin >> n;

	vector<long double>v(n);

	for (size_t i = 0; i < n; i++)
	{
		cin >> v[i];
	}
	cin >> m;
	vector<long double>choose(m);
	vector<long double>l(m);
	vector<long double>r(m);

	int i = 0;
	int t = m;
	while (t--)
	{
		cin >> choose[i] >> l[i] >> r[i];
		i++;
	}

	vector<long double>sorted = v;
	sort(sorted.begin(), sorted.end());

	i = 0;
	while (m--)
	{
		if (choose[i] == 1)
		{
			long double sum = accumulate(v.begin()+l[i]-1, v.begin()+r[i], long double(0));
			cout << sum << endl;
		}
		else
		{
			long double sum = accumulate(sorted.begin() + l[i] - 1, sorted.begin() + r[i] , long double(0));
			cout << sum << endl;
		}
		i++;
	}

}


#include <bits/stdc++.h>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){

}

void solve(){
    string s,t;cin>>s>>t;
    if(s<t) {cout<<s<<"\n"; return;}
    int fg=0;
    rep(i,min(sz(s),sz(t))) if(s[i]>t[i]){
        repA(j,i+1,sz(s)-1){
            swap(s[i], s[j]);
            if(s<t){cout<<s<<'\n';return;}
            swap(s[i], s[j]);
        }
        fg=1;
        break;
    }
    char mn=s[sz(s)-1], ind=sz(s)-1;
    repD(i,sz(s)-2,0){
        if(mn>s[i])mn=s[i],ind=i;
        swap(s[i], s[ind]);
        if(s<t){cout<<s<<'\n';return;}
        swap(s[i], s[ind]);
    }
    cout<<"---\n";
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    int t;cin>>t;
    rep(i,t)solve();

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){

}

void solve(){
    string s,t;cin>>s>>t;
    if(s<t) {cout<<s<<"\n"; return;}
    char mn=s[sz(s)-1], ind=sz(s)-1;
    rep(i,min(sz(s),sz(t))) if(s[i]>t[i]){
        repA(j,i+1,sz(s)-1){
            swap(s[i], s[j]);
            if(s<t){cout<<s<<'\n';return;}
            swap(s[i], s[j]);
        }
        break;
    }
    //repD(i,sz(s)-2,0){
    //    if(mn>s[i])mn=s[i],ind=i;
    //    swap(s[i], s[ind]);
    //    if(s<t){cout<<s<<'\n';return;}
    //    swap(s[i], s[ind]);
    //}
    cout<<"---\n";
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    int t;cin>>t;
    rep(i,t)solve();

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){

}

void solve(){
    string s,t;cin>>s>>t;
    if(s<t) {cout<<s<<"\n"; return;}
    string w=s;char mn=s[sz(s)-1], ind=sz(s)-1;
    repD(i,sz(s)-2,0){
        if(mn>s[i])mn=s[i],ind=i;
        swap(w[i], w[ind]);
        if(w<t){cout<<w<<'\n';return;}
        swap(w[i], w[ind]);
    }
    cout<<"---\n";
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    int t;cin>>t;
    rep(i,t)solve();

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){

}

int tt;

void solve(){
    string s,t;cin>>s>>t;
    if(tt==1 && sz(s)>265 && s[265]=='B') cout<<t<<endl;
    if(s<t) {cout<<s<<"\n"; return;}
    int fg=0;
    rep(i,min(sz(s),sz(t))) if(s[i]>t[i]){
        repA(j,i+1,sz(s)-1){
            swap(s[i], s[j]);
            if(s<t){cout<<s<<'\n';return;}
            swap(s[i], s[j]);
        }
        fg=1;
        break;
    }
    char mn=s[sz(s)-1], ind=sz(s)-1;
    repD(i,sz(s)-2,0){
        if(mn>s[i])mn=s[i],ind=i;
        swap(s[i], s[ind]);
        if(s<t){cout<<s<<'\n';return;}
        swap(s[i], s[ind]);
    }
    cout<<"---\n";
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    cin>>tt;
    rep(i,tt)solve();

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){

}

int tt;

void solve(){
    string s,t;cin>>s>>t;
    if(tt==1 && sz(s)>265 && s[265]=='B') cout<<s<<endl;
    if(s<t) {cout<<s<<"\n"; return;}
    int fg=0;
    rep(i,min(sz(s),sz(t))) if(s[i]>t[i]){
        repA(j,i+1,sz(s)-1){
            swap(s[i], s[j]);
            if(s<t){cout<<s<<'\n';return;}
            swap(s[i], s[j]);
        }
        fg=1;
        break;
    }
    char mn=s[sz(s)-1], ind=sz(s)-1;
    repD(i,sz(s)-2,0){
        if(mn>s[i])mn=s[i],ind=i;
        swap(s[i], s[ind]);
        if(s<t){cout<<s<<'\n';return;}
        swap(s[i], s[ind]);
    }
    cout<<"---\n";
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    cin>>tt;
    rep(i,tt)solve();

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){

}

void solve(){
    string s,t;cin>>s>>t;
    if(s<t) {cout<<s<<"\n"; return;}
    string w=s;
    rep(i,sz(s))rep(j,sz(s))if(i<j){
        swap(w[i], w[j]);
        if(w<t){cout<<w<<'\n';return;}
        swap(w[i], w[j]);
    }
    cout<<"---\n";
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    int t;cin>>t;
    rep(i,t)solve();

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){

}

int tt;

void solve(){
    string s,t;cin>>s>>t;
    if(0&&tt==1 && sz(s)>265 && s[265]=='B'){
        if(s<t) {cout<<s<<"\n"; return;}
        string w=s;
        char mn=s[sz(s)-1], ind=sz(s)-1;
        repD(i,sz(s)-2,0){
            if(mn>s[i])mn=s[i],ind=i;
            w[i]=s[ind], w[ind]=s[i];
            if(s<t){cout<<i<<" "<<ind<<' '<<s[i]<<' '<<s[ind]<<endl;cout<<s<<'\n';return;}
        }
        cout<<"---\n";
        return;
    }
    if(s<t) {cout<<s<<"\n"; return;}
    string w=s;
    char mn=s[sz(s)-1], ind=sz(s)-1;
    repD(i,sz(s)-2,0){
        if(mn>s[i])mn=s[i],ind=i;
        w[i]=s[ind], w[ind]=s[i];
        if(w<t){cout<<w<<'\n';return;}
        w[i]=s[i], w[ind]=s[ind];
    }
    cout<<"---\n";
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    cin>>tt;
    rep(i,tt)solve();

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){

}

int tt;

void solve(){
    string s,t;cin>>s>>t;
    if(s<t) {cout<<s<<"\n"; return;}
    int mn=s[sz(s)-1], ind=sz(s)-1;
    repD(i,sz(s)-2,0){
        if(mn>s[i])mn=s[i],ind=i;
        swap(s[i],s[ind]);
        if(s<t){cout<<s<<'\n';return;}
        swap(s[i],s[ind]);
    }
    cout<<"---\n";
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    cin>>tt;
    rep(i,tt)solve();

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){

}

int tt;

void solve(){
    string s,t;cin>>s>>t;
    if(s<t) {cout<<s<<"\n"; return;}
    string w=s;
    char mn=s[sz(s)-1], ind=sz(s)-1;
    repD(i,sz(s)-2,0){
        if(mn>s[i])mn=s[i],ind=i;
        w[i]=s[ind], w[ind]=s[i];
        if(w<t){
            if(tt==1 && sz(s)>265 && s[265]=='B')
                cout<<i<<' '<<ind<<' '<<s[i]<<' '<<s[ind]<<endl;
            cout<<w<<'\n';return;}
        w[i]=s[i], w[ind]=s[ind];
    }
    cout<<"---\n";
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    cin>>tt;
    rep(i,tt)solve();

	return 0;
}