#include <bits/stdc++.h>
using namespace std;
char a[1010], b[1010], ans[1010], temp[1010];
int main() {
  int n;
  int i, j;
  cin >> n;
  cin >> a;
  strcpy(ans, a);
  for (i = 0; i <= 9; i++) {
    for (j = 0; j < n; j++) {
      b[j] = a[j] + i;
      int x = b[j] - '0';
      x = x % 10;
      b[j] = x + '0';
    }
    if (strcmp(b, ans) < 0) strcpy(ans, b);
    for (j = 0; j < n; j++) {
      char c = b[n - 1];
      strcpy(temp, b);
      strcpy(b + 1, temp);
      b[0] = c;
      b[n] = 0;
      if (strcmp(b, ans) < 0) strcpy(ans, b);
    }
  }
  cout << ans << endl;
  return 0;
}
