#include <bits/stdc++.h>
void fre() {
  freopen("c://test//input.in", "r", stdin);
  freopen("c://test//output.out", "w", stdout);
}
template <class T>
inline void gmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline void gmin(T &a, T b) {
  if (b < a) a = b;
}
using namespace std;
const int N = 1010, M = 0, L = 0, Z = 1e9 + 7, maxint = 2147483647,
          ms31 = 522133279, ms63 = 1061109567, ms127 = 2139062143;
const double eps = 1e-8, PI = acos(-1.0);
map<int, int> mop;
struct A {};
int casenum, casei;
int n;
char s[N], a[N], b[N];
int getmin(char s[]) {
  int i = 0, j = 1, k = 0;
  int len = strlen(s);
  while (i < len && j < len && k < len) {
    int t = s[(i + k) % len] - s[(j + k) % len];
    if (t == 0)
      k++;
    else {
      if (t > 0)
        i += k + 1;
      else
        j += k + 1;
      if (i > j)
        swap(i, j);
      else if (i == j)
        j++;
      k = 0;
    }
  }
  return i;
}
int main() {
  while (~scanf("%d", &n)) {
    scanf("%s", s);
    int p = getmin(s);
    for (int i = 0; i < n; i++) {
      a[i] = s[p++];
      if (p == n) p = 0;
    }
    a[n] = 0;
    for (int i = 1; i <= 9; i++) {
      for (int j = 0; j < n; j++) {
        s[j]++;
        if (s[j] > '9') s[j] = '0';
      }
      int p = getmin(s);
      for (int i = 0; i < n; i++) {
        b[i] = s[p++];
        if (p == n) p = 0;
      }
      b[n] = 0;
      if (strcmp(a, b) > 0) memcpy(a, b, sizeof(a));
    }
    puts(a);
  }
  return 0;
}
