#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string str;
  cin >> n;
  cin >> str;
  for (int i = 0; i < n; i++) str[i] -= '0';
  string mstr = str;
  for (int i = 0; i < 10; i++) {
    string strc = str;
    for (int j = 0; j < n; j++) str[j] = (str[j] + i) % 10;
    for (int j = 0; j < n; j++) {
      if (str < mstr) mstr = str;
      char c = str[n - 1];
      str.pop_back();
      reverse(str.begin(), str.end());
      str.push_back(c);
      reverse(str.begin(), str.end());
    }
    str = strc;
  }
  for (int i = 0; i < n; i++) mstr[i] += '0';
  cout << mstr;
  return 0;
}
