#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int arr[n];
  for (int i = 0; i < n; i++) arr[i] = s[i] - '0';
  string s1, t;
  set<string> v;
  s1 = s;
  for (int k = 0; k < n; k++) {
    t = s1[n - 1] + s1.substr(0, n - 1);
    s1 = t;
    v.insert(s1);
  }
  for (set<string>::iterator it = v.begin(); it != v.end(); it++) {
    int a1[n];
    string n1 = *it;
    for (int i = 0; i < n; i++) a1[i] = n1[i] - '0';
    string n2;
    for (int j = 0; j < 10; j++) {
      for (int i = 0; i < n; i++) {
        ++a1[i];
        a1[i] %= 10;
        n2 += a1[i] + '0';
      }
      v.insert(n2);
      n2.clear();
    }
  }
  set<string>::iterator it = v.begin();
  string ans = *it;
  cout << ans;
  return 0;
}
