#include <bits/stdc++.h>
using namespace std;
string nb;
int main() {
  int N;
  cin >> N;
  cin >> nb;
  string m;
  m.append(N, '9');
  string act = nb;
  for (int shift = 0; shift < N; shift++) {
    for (int p = 0; p <= 9; p++) {
      m = min(m, act);
      for (int i = 0; i < N; i++) act[i] = ((act[i] - '0' + 1) % 10 + '0');
    }
    char first = act[0];
    for (int i = 1; i < N; i++) act[i - 1] = act[i];
    act[N - 1] = first;
  }
  cout << m << endl;
  return 0;
}
