#include <bits/stdc++.h>
using namespace std;
string s,mx,n1,n2;
int n;
char a;
int main () {
    cin>>n;
    if(n==2){
        cin>>n1>>n2;
        cout<<n2<<" "<<n1<<endl;
    }
    else {
        mx="0";
        for(int i=0;i<n;i++){
            cin>>a;
            s.push_back(a);
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                swap(s[i],s[j]);
                mx=max(s,mx);
            }
        }
        for(int i=1;i<mx.size();i+=2){
            mx.insert(i," ");
        }
        cout<<mx<<endl;
    }
    return 0;
}