#include <bits/stdc++.h>
using namespace std;
int i, j, n, m, a, b, c, t;
string s, ans, cand;
int main() {
  cin >> n >> s;
  ans = s;
  for (i = 0; i < 10; i++) {
    for (j = 0; j < n; j++) {
      if (s[j] != '9')
        s[j] = s[j] + 1;
      else
        s[j] = '0';
    }
    for (j = 0; j < n; j++) {
      s = s.substr(1).append(s.substr(0, 1));
      if (s.compare(ans) < 0) ans = s;
    }
    if (s.compare(ans) < 0) ans = s;
  }
  cout << ans;
  return 0;
}
