#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    int maks = 0 , ind = 0;
    int k[n] ;
    for(int i = 0; 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(int j = 0; j < n; j++)
    {
        if(k[j] <= maks)
        {
            swap(k[j] , k[i]);
            break;
        }
    }
    }

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

    return 0;
    
}