#include <bits/stdc++.h>
using namespace std;
int a[2010];
char str[1010];
int ans[2010];
int tmp[2010];
int main() {
  int n;
  cin >> n;
  scanf("%s", str);
  for (int i = 0; i < n; i++) {
    a[i] = str[i] - '0';
  }
  for (int i = n; i < 2 * n; i++) {
    a[i] = a[i - n];
  }
  for (int i = 0; i < n; i++) ans[i] = 9;
  for (int i = 0; i < n; i++) {
    int d = 10 - a[i];
    for (int j = 0; j < n; j++) {
      tmp[j] = (a[i + j] + d) % 10;
    }
    for (int j = 0; j < n; j++) {
      if (tmp[j] < ans[j]) {
        memcpy(ans, tmp, sizeof(tmp));
        break;
      } else if (tmp[j] > ans[j])
        break;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i];
  }
  return 0;
}
