#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  vector<string> all;
  for (long long i = 0; i <= 9; i++) {
    all.push_back(s);
    for (char &c : s)
      if (c == '9')
        c = '0';
      else
        c++;
  }
  string ans = s;
  for (string &x : all) {
    for (long long i = 0; i < n; i++) {
      string y = x;
      rotate(y.begin(), y.begin() + y.size() - i, y.end());
      ans = min(y, ans);
    }
  }
  cout << ans << '\n';
}
void solve(bool testcase) {
  long long t;
  cin >> t;
  while (t--) solve();
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
