#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s, ans, st;
  cin >> s;
  ans = s;
  s = s + s;
  for (int i = 0; i < n; i++) {
    st = s.substr(i, n);
    int k = '9' - st[0] + 1;
    for (int j = 0; j < st.size(); j++) st[j] = '0' + (st[j] - '0' + k) % 10;
    ans = min(ans, st);
  }
  cout << ans;
  return 0;
}
