#include <bits/stdc++.h>
using namespace std;
string s, maxs(1001, '9'), forms;
int n;
int main() {
  cin >> n;
  cin >> s;
  int c;
  int a, i, j;
  string::iterator it;
  forms.resize(n);
  for (j = 0; j < n; j++) {
    a = (10 - (s[0] - '0')) % 10;
    s[n] = s[0];
    for (i = 0; i < n; i++) {
      forms[i] = (s[i] - '0' + a) % 10 + '0';
      s[i] = s[i + 1];
    }
    if (forms < maxs) maxs = forms;
  }
  cout << maxs;
}
