#include <bits/stdc++.h>
using namespace std;
int n;
string second, ans;
void ch(string second) {
  string a = "";
  for (int i = 0; i < n; i++) {
    a = second.substr(i, n - i) + second.substr(0, i);
    if (a < ans) ans = a;
  }
}
int main() {
  string second;
  cin >> n >> second;
  string a;
  ans = second;
  for (int i = 0; i < 10; i++) {
    a = "";
    for (int j = 0; j < n; j++) a.push_back((second[j] + i) % 10 + '0');
    ch(a);
  }
  cout << ans;
}
