#include <bits/stdc++.h>
using namespace std;
int main(){
int n, arr[10];
int k=0;
int x, y, a, b;
cin >> n;
for (int i = 0; i < n; i++){
    cin >> arr[i];
}
a = max_element(arr, arr + n) - arr;
if(n==2){
    cout<<arr[1]<<" "<<arr[0];
}
else{
    if(a==0){
        for(int i=0; i<n; i++){
            if(arr[i]<arr[i+1]){
                k++;
            }
            }
            if(k==0){
                arr[n-2]+=arr[n-1];
                arr[n-1]=arr[n-2]-arr[n-1];
                arr[n-2]=arr[n-2]-arr[n-1];
                for (int i = 0; i < n; i++){
                    cout<< arr[i]<< " ";
                }
            }else{
                a = max_element(arr+1, arr + n) - arr;
        arr[1]+=arr[a];
        arr[a]=arr[1]-arr[a];
        arr[1]=arr[1]-arr[a];
        for (int i = 0; i < n; i++){
            cout<< arr[i]<< " ";
    }
            }
            }else{
        arr[0]+=arr[a];
        arr[a]=arr[0]-arr[a];
        arr[0]=arr[0]-arr[a];
        for (int i = 0; i < n; i++){
            cout<< arr[i]<< " ";
    }
}
}
return 0;
}