#include <iostream>

using namespace std;

int main()
{
    int n;
    int t,temp,pom;
    int najveci = INT_MIN;

    cin >> n;

    int a[n];
    int b[n];
    int c[n];
    int index[n];
    for(int i=0;i<n;++i)
    {
        cin >> a[i];
        b[i] = a[i];
    }

    if(n == 2)
    {
        cout << a[1] << " " << a[0];
        return 0;
    }
    else
    {
        ///Sortiranje
        for(int i=0;i<n-1;i++)
        {
            t = i;
            for(int j=i+1;j<n;j++)
                if (b[j] > b[t])
                    t = j;
                pom = b[i];
                b[i] = b[t];
                b[t] = pom;
        }
        for(int i=0;i<n;++i)
        {
            c[i] = a[i];
        }
        ///Indexi
        for(int i=0;i<n;++i)
        {
            for(int j=0;j<n;++j)
            {
                if(b[i] == a[j])
                {
                    index[i] = j;
                    a[j] = 0;
                    break;
                }
            }
        }
        ///Restoreaj a
        for(int i=0;i<n;++i)
        {
            a[i] = c[i];
        }
        ///Zameni
        for(int i=0;i<n;++i)
        {
            for(int j=i;j<n;++j)
            {
                if(b[i] > a[j])
                {
                    pom = a[j];
                    a[j] = b[i];
                    a[index[i]] = pom;
                    goto kraj;
                }
                else if(b[i] == a[j])
                {
                    break;
                }
            }
        }
        kraj:
        for(int i=0;i<n;++i)
        {
            cout << a[i] << " ";
        }
    }
    return 0;
}