#include <bits/stdc++.h>
using namespace std;
const int64_t MAXN = 1e5 + 5, mod = 1e9 + 7;
int64_t a[105][2];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int64_t n;
  cin >> n;
  string s;
  cin >> s;
  string cur = s;
  for (int64_t i = 0; i < n; i++) {
    while (s[0] > '0') {
      for (int64_t j = 0; j < n; j++) {
        if (s[j] == '0')
          s[j] = '9';
        else
          s[j]--;
      }
    }
    int64_t st = 1;
    for (int64_t j = 0; j < n; j++) {
      if (s[j] < cur[j]) break;
      if (s[j] > cur[j]) {
        st = 0;
        break;
      }
    }
    if (st) cur = s;
    s = s.substr(1, n - 1) + s[0];
  }
  cout << cur << '\n';
}
