#include <bits/stdc++.h>

using namespace std;

int main()
{
    long n;
    int maks = 0 , ind = 0;
    cin >> n;
    int k[n] ;
    for(long i = 1; i < n; i++)
    {
        cin >> k[i];
        if(k[i] >= maks)
        {
            maks = k[i];
            ind = i;
        }
    }
    
    if(n == 2)
    {
        swap(k[0] , k[1]);
    }
    else
    {
        for(long j = 0; j < n; j++)
    {
        if(k[j] <= maks)
        {
            swap(k[j] , k[ind]);
            break;
        }
    }
    }

    for(long h = 0; h < n; h++)
    {
        cout << k[h] << " ";
    }

    return 0;
    
}