#include <bits/stdc++.h>
using namespace std;
vector<string> v;
char in[2005], tmp[1005];
int n;
int main() {
  cin >> n >> in;
  int len = strlen(in);
  for (int i = len; i < len << 1; ++i) in[i] = in[i - len];
  for (int i = 0; i < n; ++i) {
    strncpy(tmp, in + i, n);
    v.push_back(tmp);
    for (int j = 1; j < 10; ++j) {
      for (int k = 0; k < n; ++k) {
        ++tmp[k];
        if (tmp[k] > '9') tmp[k] -= 10;
      }
      v.push_back(tmp);
    }
  }
  sort(v.begin(), v.end(), less<string>());
  cout << v.front();
  return 0;
}
