#include <bits/stdc++.h>
int main() {
  char str[1001], t1[1001], t2[1001], t3[1001], ans[1001], min[1001];
  int i, j, n, l;
  scanf("%d", &n);
  scanf("%s", str);
  strcpy(ans, str);
  for (i = 0; i < 10; i++) {
    strcpy(t1, str);
    for (j = 0; j < n; j++) {
      t1[j] = (t1[j] - '0' + i) % 10 + '0';
    }
    strcpy(t3, t1);
    strcpy(min, t1);
    for (j = 0; j < n; j++) {
      t2[0] = t3[n - 1];
      t2[1] = '\0';
      strcat(t2, t3);
      l = strlen(t2);
      t2[l - 1] = '\0';
      if (strcmp(min, t2) > 0) strcpy(min, t2);
      strcpy(t3, t2);
    }
    if (strcmp(ans, min) > 0) strcpy(ans, min);
  }
  printf("%s", ans);
  return 0;
}
