#include <bits/stdc++.h>
using namespace std;
string s;
unordered_set<string> h;
int main() {
  int n;
  cin >> n >> s;
  string ans = s;
  queue<string> q;
  q.push(s);
  h.insert(s);
  while (!q.empty()) {
    const string t = q.front();
    q.pop();
    ans = min(ans, t);
    string u = t;
    int carry = 0;
    for (int i = n - 1; i >= 0; i--) {
      const int tmp = t[i] - '0' + 1;
      u[i] = tmp % 10 + '0';
      carry = tmp / 10;
    }
    if (!h.count(u)) {
      h.insert(u);
      q.push(u);
    }
    string v = t;
    for (int i = 0; i < n - 1; i++) {
      v[i + 1] = t[i];
    }
    v[0] = t[n - 1];
    if (!h.count(v)) {
      h.insert(v);
      q.push(v);
    }
  }
  puts(ans.c_str());
  return 0;
}
