#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int caotoi(string s0) {
  int res = 0;
  for (int i = 0; i < s0.size(); i++) res = res * 10 + s0[i] - '0';
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  cin >> s;
  int best = 1000000;
  string sbest = s;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < s.length(); j++)
      if (s[j] == '9')
        s[j] = '0';
      else
        s[j] += 1;
    for (int j = 0; j < s.length(); j++) {
      string ss = "";
      for (int k = j, idx = 0; idx < s.length(); idx++, k += 1, k %= s.length())
        ss += s[k];
      bool ok = false;
      for (int k = 0; k < s.length(); k++) {
        if (ss[k] < sbest[k]) {
          ok = true;
          break;
        }
        if (ss[k] > sbest[k]) break;
      }
      if (ok) sbest = ss;
    }
  }
  cout << sbest << "\n";
  return 0;
}
