#include <iostream>
using namespace std;
int v[100], emax, imax, i, n, j;
int main()
{
cout << "n= "; cin >> n;
cout << "introdu " << n << " numere naturale distincte: " << endl;
cin >> v[1]; emax=v[1]; imax=1;
for (i=2; i<=n; ++i)
{
cin >> v[i];
if (v[i]>emax) { emax=v[i]; imax=i; }
}
for (i=1; i<imax; ++i)
{
for (j=i+1; j<=imax; ++j)
if (v[j]<v[i])
{ int t=v[i]; v[i]=v[j]; v[j]=t; }
}
for (i=imax+1; i<n; ++i)
{
for (j=i+1; j<=n; ++j)
if (v[j]>v[i])
{ int t=v[i]; v[i]=v[j]; v[j]=t; }
}
for (i=1; i<=n; ++i)
cout << v[i] << " ";
}