#include <bits/stdc++.h>
using namespace std;
string s, ans;
int n;
string getP(string a) {
  for (int i = 0; i < n; i++)
    if (a[i] == '9')
      a[i] = '0';
    else
      a[i]++;
  return a;
}
string getS(string a) {
  char x = a[n - 1];
  for (int i = n - 1; i > 0; i--) a[i] = a[i - 1];
  a[0] = x;
  return a;
}
int main() {
  cin >> n;
  cin >> s;
  ans = s;
  for (int i = 0; i <= 10; i++) {
    ans = min(ans, s);
    string t = s;
    for (int j = 0; j < n; j++) {
      t = getS(t);
      ans = min(ans, t);
    }
    s = getP(s);
  }
  cout << ans;
  return 0;
}
