#include <bits/stdc++.h>
using namespace std;
string opt;
int n;
void check(string now, int ind) {
  string nowShifted = now;
  int j = 0;
  for (int i = ind; i < n && j < n; i++, j++) nowShifted[j] = now[i];
  for (int i = 0; i < ind && j < n; i++, j++) nowShifted[j] = now[i];
  for (int i = 0; i < n; i++)
    if (opt[i] > nowShifted[i]) {
      opt = nowShifted;
      return;
    } else if (opt[i] < nowShifted[i])
      return;
}
void bf(string now, int ind) {
  if (now[ind] != '0') {
    int z = '9' + 1 - now[ind];
    for (int i = 0; i < n; i++) {
      if (now[i] + z > '9') {
        int left = z - ('9' + 1 - now[i]);
        now[i] = left + '0';
      } else
        now[i] += z;
    }
  }
  check(now, ind);
}
void sol(string inp) {
  for (int i = 0; i < n; i++) bf(inp, i);
}
int main() {
  ios::sync_with_stdio(false);
  string inp;
  cin >> n >> inp;
  opt = inp;
  sol(inp);
  cout << opt;
  return 0;
}
