#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, add;
  string a, b, min, temp;
  cin >> n;
  cin >> a;
  b = a;
  min = a;
  temp = a;
  a = a + a;
  for (int i = 0; i < n; ++i) {
    add = '9' - a[i] + 1;
    for (int j = 0; j < 2 * n; ++j) {
      if (add + a[j] > '9') {
        a[j] = a[j] + (add - 10);
      } else
        a[j] += add;
    }
    b = a.substr(i, n);
    if (b < min) {
      min = b;
    }
  }
  cout << min << endl;
  return 0;
}
