#include <bits/stdc++.h>
using namespace std;
bool vis[1000];
pair<int, string> ll[1000][1000];
int x[] = {1, -1, 0, 0};
int y[] = {0, 0, 1, -1};
using namespace std;
int main() {
  int n;
  cin >> n;
  string s, ans = "9999999999";
  cin >> s;
  for (int i = 0; i < n; i++) {
    string s1 = "0";
    int j = (i + 1) % n;
    int z = int('9' - s[i]);
    z++;
    z = z % 10;
    while ((j % n) != i) {
      int c = int(s[j] - '0');
      c = (c + z) % 10;
      s1 += char('0' + c);
      j = (j + 1) % n;
    }
    ans = min(ans, s1);
  }
  cout << ans;
}
