#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int main() {
  cin >> n >> s;
  vector<string> v;
  v.resize(n);
  for (int start = 0; start < n; start++) {
    string& news = v[start];
    news.resize(n);
    int d = s[start] - '0';
    int at = 0;
    for (int i = start; i < n; i++) {
      news[at] = s[i] - d;
      if (news[at] < '0') news[at] += 10;
      at++;
    }
    for (int i = 0; i < start; i++) {
      news[at] = s[i] - d;
      if (news[at] < '0') news[at] += 10;
      at++;
    }
  }
  sort(v.begin(), v.end());
  cout << v.front() << endl;
  return 0;
}
