#include <bits/stdc++.h>
using namespace std;
set<string> S;
char s[5000];
char aa[6000];
int main() {
  int n;
  scanf("%d", &n);
  S.clear();
  scanf("%s", s);
  S.insert(s);
  for (int i = 0; i < n; i++) s[i + n] = s[i];
  s[2 * n] = NULL;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < n; j++) aa[j] = s[i + j];
    aa[n] = NULL;
    S.insert(aa);
  }
  for (int k = 1; k <= 10; k++) {
    for (int i = 0; i < n; i++) {
      if (s[i] == '9')
        s[i] = '0';
      else
        s[i] = s[i] + 1;
    }
    s[n] = NULL;
    S.insert(s);
    for (int i = 0; i < n; i++) s[i + n] = s[i];
    s[2 * n] = NULL;
    for (int i = n - 1; i >= 0; i--) {
      for (int j = 0; j < n; j++) aa[j] = s[i + j];
      aa[n] = NULL;
      S.insert(aa);
    }
  }
  cout << *S.begin() << endl;
  return 0;
}
