#include <iostream>
#include <vector>

int main()
{
    unsigned long long N;
    std::cin >> N;

    std::vector<unsigned long long> books;
    books.reserve(N);
    for (unsigned long long i = 1; i <= N; i++)
    {
        unsigned long long n;
        std::cin >> n;
        books.emplace_back(n);
    }

    if (books.size() > 2)
    {
        for (unsigned long long i = 0; i < N; i++)
        {
            bool dobreak = false;
            for (unsigned long long j = (i + 1); j < N; j++)
            {
                if (books[j] > books[i])
                {
                    unsigned long long tmp = books[i];
                    books[i] = books[j];
                    books[j] = tmp;
                    dobreak = true;
                    break;
                }
            }

            if (dobreak)
            {
                break;
            }
        }
    }
    else
    {
        unsigned long long tmp = books[0];
        books[0] = books[1];
        books[1] = tmp;
    }

    for (unsigned long long n : books)
    {
        std::cout << n << " ";
    }

    return 0;
}