#include <bits/stdc++.h>
using namespace std;
int main() {
  string ch, a, b, c, d;
  int m = 0, i, j, n, x, l, k;
  cin >> n;
  cin >> ch;
  d = a = b = c = ch;
  for (i = 0; i < n; i++) {
    x = 10 - (ch[i] - '0');
    for (j = 0; j < n; j++) {
      a[j] = (ch[j] - '0' + x) % 10 + '0';
    }
    m = 0;
    for (k = i; k < n; k++) {
      b[m++] = a[k];
    }
    for (l = 0; l < i; l++) b[m++] = a[l];
    if (b < c) c = b;
  }
  cout << c;
}
