#include<iostream>
#include<queue>
using namespace std;
struct MAX
{
int x;
}t;
struct MIN
{
int x;
}s;
bool operator<(const MAX &a,const MAX &b)
{
return a.x<b.x;
}//大根堆
bool operator<(const MIN &a,const MIN &b)
{
return a.x>b.x;
}//小根堆
priority_queue<MAX>qmax;
priority_queue<MIN>qmin;
int a,n,i;
int main()
{
cout<<"输入n"<<endl;
cin>>n;
cout<<"输入n个数"<<endl;
for(i=1;i<=n;i++)
{
cin>>a;
t.x=a;
qmax.push(t);
s.x=a;
qmin.push(s);
}
while(!qmax.empty())
{
a=qmax.top().x;
cout<<a<<" ";
qmax.pop();
}
cout<<endl;
while(!qmin.empty())
{
a=qmin.top().x;
cout<<a<<" ";
qmin.pop();
}
cout<<endl;
//system("pause");
return 0;
}