#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  string sol = "";
  for (int poc = 0; poc < n; poc++) {
    int kolko = '9' - s[poc] + 1;
    int i = poc;
    string tren = "";
    for (int cntr = 0; cntr < n; cntr++) {
      char pom;
      if (s[i] + kolko > '9') {
        pom = (char)(s[i] + kolko - 10);
      } else {
        pom = (char)(s[i] + kolko);
      }
      tren.push_back((char)(pom));
      i++;
      if (i == n) {
        i = 0;
      }
    }
    if (sol == "") {
      sol = tren;
    } else {
      if (tren < sol) {
        sol = tren;
      }
    }
  }
  cout << sol << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
