#include <bits/stdc++.h>
using namespace std;
string s[15];
int main() {
  int n, i, j, k;
  cin >> n;
  cin >> s[0];
  for (i = 1; i <= 9; i++) {
    s[i] = s[i - 1];
    for (j = 0; j < s[i].size(); j++) {
      if (s[i][j] == '9')
        s[i][j] = '0';
      else
        s[i][j]++;
    }
  }
  string str;
  char ch;
  for (i = 0; i <= 9; i++) {
    str = s[i];
    for (j = 1; j < n; j++) {
      ch = s[i][n - 1];
      for (k = n - 1; k >= 1; k--) s[i][k] = s[i][k - 1];
      s[i][0] = ch;
      if (s[i] < str) str = s[i];
    }
    s[i] = str;
  }
  str = s[0];
  for (i = 1; i <= 9; i++) {
    if (s[i] < str) str = s[i];
  }
  cout << str;
  return 0;
}
