#include <iostream>
#include <string>

using namespace std;

//zadatak b
int main()
{
	int n, i, j;
	int sw1, sw2;
	char tmp;
	int mindiff = 0;

	int difaop = 0;
	string minstr;
   string  tarr;
	string s;

	cin >> n ;



	for (i = 0; i < n; i++) {
		cin >> tmp;
		s.push_back(tmp);
		minstr.push_back(0);
	//	arr.push_back(tmp);
	//vop.push_back(tmp);
	};

	
	if (n == 2) {
		sw1 = 0;
		sw2 = 1; 
	}
	else
	{
		for (i = 0; i < n / 2 + 1; i++) {
			for (j = i + 1; j < n; j++) {
				tarr = s;
				tmp = tarr[i];
				tarr[i] = tarr[j];
				tarr[j] = tmp;
			
			if (tarr>minstr) {
				    minstr = tarr;
					sw1 = i;
					sw2 = j;
				}
			}

		}
	}
	tmp = s[sw1];
	s[sw1] = s[sw2];
	s[sw2] = tmp;

	for (j = 0; j < n; j++) {
		cout << s[j] << " ";
	}

	return 0;
}