#include <bits/stdc++.h>
using namespace std;
char a[1002];
int main() {
  int n;
  char ans[1002] = {'9'};
  char tmp[1002] = {'\0'};
  char c[1002];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] -= '0';
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      c[j] = a[j] - a[i];
      if (c[j] < 0) c[j] += 10;
    }
    int len = 0;
    for (int j = i; j < n; j++) tmp[len++] = c[j];
    for (int j = 0; j < i; j++) tmp[len++] = c[j];
    bool big = 0;
    for (int i = 0; i < n; i++) {
      if (tmp[i] > ans[i]) {
        big = 1;
        break;
      }
      if (tmp[i] < ans[i]) {
        big = 0;
        break;
      }
    }
    if (!big) memcpy(ans, tmp, sizeof(tmp));
  }
  for (int i = 0; i < n; i++) cout << (int)ans[i];
  return 0;
}
