#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  string s, mini;
  cin >> n >> s;
  mini = s;
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < n; ++j) {
      char c = s[n - 1];
      s = s.substr(0, n - 1);
      string aux = "";
      aux.push_back(c);
      aux.append(s);
      s = aux;
      mini = min(mini, s);
    }
    for (int j = 0; j < n; ++j) s[j] = s[j] != '9' ? s[j] + 1 : '0';
  }
  cout << mini << "\n";
  return 0;
}
