#include <bits/stdc++.h>
using namespace std;
string s = "0123456789012345678901234567890";
int main() {
  int n, t;
  string s1, s2, s3 = "";
  cin >> n >> s1;
  char ch;
  for (int i = 1; i <= n; i++) {
    if (i != 1) {
      ch = s1[0];
      for (int j = 1; j < n; j++) {
        s1[j - 1] = s1[j];
      }
      s1[n - 1] = ch;
    }
    s2 = s1;
    t = '9' - s1[0] + 1;
    s2[0] = '0';
    for (int j = 1; j < n; j++) {
      s2[j] = s[s2[j] - '0' + t];
    }
    if (i == 1 || s3 > s2) {
      s3 = s2;
    }
  }
  cout << s3 << endl;
  return 0;
}
