#include <bits/stdc++.h>
using namespace std;
struct _ {
  ios_base::Init i;
  _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); }
} _;
int n;
string s;
void increment(string &s) {
  for (int j = 0; j <= n - 1; j++) {
    int dig = s[j] - '0';
    dig = (dig + 1) % 10;
    s[j] = dig + '0';
  }
}
void right_shift(string &s) {
  char t = s[n - 1];
  for (int i = n - 1; i >= 1; i--) s[i] = s[i - 1];
  s[0] = t;
}
int main() {
  cin >> n >> s;
  string ans = s;
  for (int i = 0; i <= n - 1; i++) {
    for (int d = 0; d <= 10; d++) {
      increment(s);
      ans = min(ans, s);
    }
    right_shift(s);
  }
  cout << ans;
  return 0;
}
