#include <bits/stdc++.h>
using namespace std;
const int N = 1000;
int n;
string s;
int a[N];
int main() {
  cin >> n;
  cin >> s;
  for (int i = 0; i < n; i++) {
    a[i] = s[i] - '0';
  }
  string ss = s;
  int cnt = 10;
  while (cnt) {
    for (int i = 0; i < n; i++) {
      a[i] = (a[i] + 1) % 10;
      s[i] = a[i] + 48;
    }
    string se = s;
    int cnt1 = n;
    while (cnt1) {
      char ch = s[0], ch1 = s[n - 1];
      for (int i = 1; i < n; i++) {
        char c = s[i];
        s[i] = ch;
        ch = c;
      }
      s[0] = ch1;
      if (ss.compare(s) > 0) ss = s;
      cnt1--;
    }
    s = se;
    cnt--;
  }
  cout << ss << '\n';
  return 0;
}
