#include <iostream>
#include <string>
using namespace std;
int main()
{
    unsigned long long int n;
    cin>>n;
    char a[n];
    long long int ind=-1,maks=-1,maksInd=-1;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]!=9 && ind==-1)
            ind=i;
    }
    int j=n-1;
    while(j>ind)
    {
        if(a[j]>maks){
            maksInd=j;
            maks=a[j];
        }
        if(maks=='9')
            break;
        j--;
    }
    char pom;
    pom=a[ind];
    a[ind]=a[maksInd];
    a[maksInd]=pom;
    string x=a;
    cout<<x;
    return 0;
}