#include <bits/stdc++.h>
using namespace std;
string fun(char m, string a) {
  string n;
  return n;
}
int main() {
  string n, t;
  int l;
  cin >> l;
  cin >> n;
  vector<string> pos;
  pos.push_back(n);
  int count = 0;
  for (int i = 1; i < l; i++) {
    t = "";
    count = i;
    for (int c = 0; c < l; c++) {
      t += n[count];
      if (count == l - 1)
        count = 0;
      else
        count++;
    }
    pos.push_back(t);
  }
  int d = pos.size();
  vector<string> fin;
  for (int i = 0; i < d; i++) {
    fin.push_back(pos[i]);
    string temp = pos[i];
    for (int d = 0; d < 10; d++) {
      string t = "";
      for (int j = 0; j < l; j++) {
        if (temp[j] == '9')
          t += '0';
        else
          t += temp[j] + 1;
      }
      fin.push_back(t);
      temp = t;
    }
  }
  string m = fin[0];
  for (int i = 0; i < fin.size(); i++) m = min(m, fin[i]);
  cout << m << endl;
  return 0;
}
