#include <bits/stdc++.h>
using namespace std;
void incr(string& ss, const int& range) {
  for (int i = 0; i < ss.size(); i++) {
    if (ss[i] + range > '9')
      ss[i] += (range - 10);
    else
      ss[i] += range;
  }
}
int main() {
  int n;
  string s, ss, mns;
  stringstream sss;
  cin >> n >> s;
  ss = s;
  mns = s;
  int range = '9' - ss[0] + 1;
  incr(ss, range);
  if (ss < mns) {
    mns = ss;
  }
  for (int i = 1; i < n; i++) {
    s = s[n - 1] + s;
    s.erase(n);
    ss = s;
    if (ss < mns) {
      mns = ss;
    }
    range = '9' - ss[0] + 1;
    incr(ss, range);
    if (ss < mns) {
      mns = ss;
    }
  }
  cout << mns;
  return 0;
}
