#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  stack<string> nums;
  for (int t = 0; t < 10; t++) {
    string s1 = s;
    for (int i = 0; i < n; i++) s1[i] = ((s[i] - '0' + t) % 10) + '0';
    for (int i = 0; i < n; i++)
      if (s1[i] == '0') nums.push(s1.substr(i, n - i) + s1.substr(0, i));
  }
  string mins = nums.top();
  nums.pop();
  while (!nums.empty()) {
    string comp = nums.top();
    for (int i = 0; i < n; i++) {
      if (mins[i] < comp[i]) break;
      if (comp[i] < mins[i]) {
        mins = comp;
        break;
      }
    }
    nums.pop();
  }
  cout << mins;
  return 0;
}
