#include <bits/stdc++.h>
using namespace std;
const int maxN = 100 * 1000 + 5;
const int mod = 1000 * 1000 * 1000;
int a[maxN];
int n;
string make(string s, int t) {
  string res;
  res.resize(n);
  for (int i = t; i < n; i++) res[i] = s[i - t];
  for (int i = 0; i < t; i++) res[i] = s[i + n - t];
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  string s;
  cin >> s;
  vector<string> res;
  for (int j = 0; j < 10; j++) {
    for (int i = 0; i < n; i++)
      if (s[i] == '9')
        s[i] = '0';
      else
        s[i]++;
    for (int i = 0; i < n; i++) res.push_back(make(s, i));
  }
  sort(res.begin(), res.end());
  cout << res[0] << endl;
  return 0;
}
