#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  string r = s;
  for (int i = 0; i < s.size(); i++) {
    s = s.substr(s.size() - 1, 1) + s.substr(0, s.size() - 1);
    int x = s[0] - '0';
    for (int j = 0; j < s.size(); j++) {
      if (s[j] - '0' >= x)
        s[j] -= x;
      else
        s[j] += 10 - x;
    }
    r = min(r, s);
  }
  cout << r << endl;
}
