6 1 3 2 4
8 3 1 6 9 2
1 8 6 3 9 2
#include <bits/stdc++.h>
using namespace std;
int a[10005];
int main (){
int N,l1,r1,l2,r2;
cin >> N >> l1 >> r1 >> l2 >> r2;
for(int i = 1; i <= N; i++){
cin >> a[i];
}
sort(a+l1,a+r1+1);
sort(a+l2,a+r2+1,greater<int>());
for(int i = 1; i < N; i++)
cout << a[i] << " ";
cout << a[N] <<endl;
return 0;
}