#include <bits/stdc++.h>
using namespace std;
string res;
int main() {
  int n;
  cin >> n;
  string buffer, t;
  cin >> buffer;
  res = buffer;
  for (int j = 0; j < n; ++j) {
    buffer = buffer.substr(n - 1, 1) + buffer.substr(0, n - 1);
    int dx = '9' + 1 - buffer[0];
    t = buffer;
    for (int i = 0; i < n; ++i) {
      t[i] = (t[i] - '0' + dx) % 10 + '0';
    }
    if (t < res) res = t;
  }
  cout << res << endl;
  return 0;
}
