#include <bits/stdc++.h>
using namespace std;
int a[1010], b[1010], c[1010];
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < n; i++) b[i] = a[i] = s[i] - '0';
  int m = 10;
  while (m--) {
    for (int i = 0; i < n; i++) a[i] = (a[i] + 1) % 10;
    for (int i = 0; i < n; i++) {
      bool flag = 1, flag1 = 1;
      int k = 0;
      for (int j = i; flag || j != i; j = (j + 1) % n) {
        flag = 0;
        c[k++] = a[j];
        if (flag1) {
          if (c[k - 1] > b[k - 1])
            break;
          else if (c[k - 1] < b[k - 1])
            flag1 = 0;
        }
      }
      if (!flag1 && k == n)
        for (int i = 0; i < n; i++) b[i] = c[i];
    }
  }
  for (int i = 0; i < n; i++) cout << b[i];
}
