#include<iostream>
using namespace std;
#define MAXSIZE 1000
typedef int keytype;
typedef struct
{
keytype key;
}redtype;
typedef struct
{
redtype r[MAXSIZE+1];
int length;
}sqlist;
int Partition(sqlist &L,int low,int high)
{
L.r[0]=L.r[low];
int pivotkey=L.r[low].key;
while(low<high)
{
while(low<high&&L.r[high].key>=pivotkey) high--;
L.r[low]=L.r[high];
while(low<high&&L.r[low].key<=pivotkey) low++;
L.r[high]=L.r[low];
}
L.r[low]=L.r[0];
return low;
}
void creat(sqlist &L,int n)
{
L.length=0;
for(int i=1;i<=n;i++)
{
cin>>L.r[i].key;
L.length++;
}
}
void pri_(sqlist L)
{
for(int i=1;i<=L.length;i++)
cout<<L.r[i].key<<' ';
cout<<endl;
}
void qsort(sqlist &L,int low,int high)
{
if(low<high)
{
int pivotloc=Partition(L,low,high);
qsort(L,low,pivotloc-1);
qsort(L,pivotloc+1,high);
}
}
int main()
{
sqlist L;
cout<<"请输入表的长度:"<<endl;
int n;
cin>>n;
creat(L,n);
qsort(L,1,L.length);
pri_(L);
return 0;
}