#include <iostream>

using namespace std;

char niz[1000001];

int main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  long long n;

  cin >> n;

  if (n == 2){
    int c1, c2;
    cin >> c1 >> c2;
    cout << c2 << " " << c1;
    return 0;
  }
  
  char max = 0; 
  char secondMax = 0;
  for (int i = 0; i < n; ++i){
    cin >> niz[i];
    if (niz[max] < niz[i]){
      secondMax = max;
      max = i;
    }
    else if (niz[secondMax] < niz[i]){
      secondMax = i;
    }
    else if (i == 1){
      secondMax = 1;
    }
  }

  char c = 0;
  if (max == 0){
    max = secondMax;
    c = 1;
    if (secondMax == 1){
      c = 0;
    }
  }

  char temp;
  temp = niz[max];
  niz[max] = niz[c];
  niz[c] = temp;

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

  return 0;
}