#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  string ans = s;
  for (int j = 0; j < 10; j++) {
    string tmp;
    for (int i = 0; i < n; i++) {
      int val = s[i] - '0';
      val = (val + j) % 10;
      tmp += val + '0';
    }
    string tmp2 = tmp;
    ans = min(ans, tmp2);
    rotate(tmp2.begin(), tmp2.begin() + 1, tmp2.end());
    while (tmp2 != tmp) {
      ans = min(ans, tmp2);
      rotate(tmp2.begin(), tmp2.begin() + 1, tmp2.end());
    }
  }
  cout << ans << endl;
}
