#include <bits/stdc++.h>
using namespace std;
const int inf = (int)(1e9) + 100;
const int mod = (int)(1e9) + 7;
const int N = (int)(1e5) + 100;
string s;
int n;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> s;
  string cur = s, ans = "zzzzzzzzz";
  int cnt = -1;
  while (true) {
    if (cnt == 10) break;
    cnt++;
    for (int i = 0; i < n; i++) {
      if (s[i] == '9')
        s[i] = '0';
      else {
        s[i]++;
      }
    }
    cur = s;
    string t = "zzzzzzzzz";
    for (int i = 0; i < n; i++) {
      char c = cur[n - 1];
      cur.erase(n - 1, 1);
      cur.insert(cur.begin(), c);
      t = min(cur, t);
    }
    ans = min(t, ans);
  }
  cout << ans;
  return 0;
}
