#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s1, s2, sm, s;
  cin >> n;
  cin >> s;
  for (int i = 0; i < 11; i++) {
    for (int j = 0; j < s.size(); j++)
      if (s[j] == '9')
        s[j] = '0';
      else
        s[j] = char(s[j] + 1);
    for (int j = 0; j <= s.size(); j++) {
      s1 = s.substr(0, j);
      s2 = s.substr(j, n);
      if (s2 + s1 < sm || ((j == 0) && (i == 0))) sm = s2 + s1;
    }
  }
  cout << sm;
}
