#include <bits/stdc++.h>
using namespace std;
int n;
char s[2005];
int a[2005];
int ans[2005];
void ini() {
  scanf("%s", s + 1);
  int i;
  for (i = 1; i <= n; i++) {
    a[i] = s[i] - '0';
    ans[i] = a[i];
  }
  for (i = n + 1; i <= n + n; i++) {
    a[i] = a[i - n];
  }
}
void com() {
  int i, j, k;
  int ff;
  for (i = 1; i <= n; i++) {
    k = i;
    j = 1;
    ff = 0;
    for (; j <= n; j++, k++) {
      if (a[k] < ans[j]) {
        ff = 1;
        break;
      } else if (a[k] > ans[j]) {
        ff = -1;
        break;
      }
    }
    if (ff <= 0) continue;
    k = i;
    j = 1;
    for (; j <= n; j++, k++) {
      ans[j] = a[k];
    }
  }
}
void add() {
  int i;
  for (i = 1; i <= 2 * n; i++) {
    a[i]++;
    if (a[i] == 10) a[i] = 0;
  }
}
void out();
void solve() {
  int i;
  com();
  for (i = 1; i <= 9; i++) {
    add();
    com();
  }
}
void out() {
  int i;
  for (i = 1; i <= n; i++) {
    printf("%d", ans[i]);
  }
  printf("\n");
}
int main() {
  while (scanf("%d", &n) != EOF) {
    ini();
    solve();
    out();
  }
  return 0;
}
