#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, p;
  cin >> n;
  string s;
  cin >> s;
  string a = s, b;
  for (int i = 0; i < n; i++) {
    int p = 10 - s[i] + '0';
    for (int j = 0; j < n; j++) {
      b += (p + s[(i + j) % n] - '0') % 10 + '0';
    }
    a = min(a, b);
    b.clear();
  }
  cout << a;
}
