#include <iostream>
using namespace std;
int main()
{int n, v[100], i, aux, sw, mid=0;
cout<<"n=";cin>>n;
for(i=1;i<=n;i++)
{
cout<<"v["<<i<<"]=";
cin>>v[i];
}
do
{ sw=0;
for(i=1;i<=n/2;i++)
{ if(v[i]>v[i+1])
{ aux=v[i];
v[i]=v[i+1];
v[i+1]=aux;
sw=1;
}
}
}
while(sw==1);
mid=n/2+1;
do
{ sw=0;
for(i=mid;i<=n;i++)
{ if(v[i]<v[i+1])
{ aux=v[i];
v[i]=v[i+1];
v[i+1]=aux;
sw=1;
}
}
}
while(sw==1);
for(i=1;i<=n;i++)
{
cout<<v[i]<<" ";
}
return 0;
}