#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j = 0;
  char d;
  cin >> n;
  string s;
  cin >> s;
  char a[n][n + 1];
  for (i = 0; i < n; i++) {
    s.copy(a[i], n - i, i), s.copy(a[i] + (n - i), i), a[i][n] = 0;
    d = ('9' - a[i][0] + 1) % 10;
    for (j = 0; j < n; j++)
      a[i][j] = (((a[i][j] + d) > '9') ? (a[i][j] - 10) : a[i][j]) + d;
  }
  for (i = 1, j = 0; i < n; i++) j = ((strcmp(a[i], a[j]) < 0) ? i : j);
  puts(a[j]);
  return 0;
}
