#include <bits/stdc++.h>
using namespace std;
ifstream fin("data.in");
int m[1010], v[2010], i, j, n;
char s[2010];
void minim(int j) {
  for (int i = j; i <= j + n - 1; i++)
    if (v[i] != m[i - j]) {
      if (v[i] < m[i - j]) {
        for (int k = 0; k < n; k++) m[k] = v[k + j];
        return;
      } else
        return;
    }
}
int main() {
  cin >> n;
  cin >> s;
  for (i = 0; i < n; i++) m[i] = 9;
  for (i = n; i < 2 * n; i++) s[i] = s[i - n];
  for (i = 0; i <= 9; i++) {
    for (j = 0; j < n; j++) v[j] = (s[j] - '0' + i) % 10;
    minim(0);
    for (; j < 2 * n; j++) {
      v[j] = (s[j] - '0' + i) % 10;
      minim(j - n);
    }
  }
  for (i = 0; i < n; i++) cout << m[i];
  return 0;
}
