#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
char a[maxn];
int n;
void add(char a[], int added) {
  for (int i = 0; i < n; i++) {
    int tmp = (a[i] - '0' + added) % 10;
    a[i] = tmp + '0';
  }
}
void get_reverse(char a[]) {
  char tmp = a[0];
  for (int i = 1; i < n; i++) a[i - 1] = a[i];
  a[n - 1] = tmp;
}
int main() {
  while (scanf("%d", &n) != EOF) {
    getchar();
    char b[maxn] = {'0'};
    char ans[maxn] = {'9'};
    for (int i = 0; i < n; i++) scanf("%c", &a[i]);
    for (int i = 0; i <= 9; i++) {
      strcpy(b, a);
      add(a, i);
      for (int j = 0; j < n; j++) {
        if (strcmp(ans, a) > 0) strcpy(ans, a);
        get_reverse(a);
      }
      strcpy(a, b);
    }
    puts(ans);
  }
  return 0;
}
