#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5, M = 1e4 + 5, OO = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  string s, mn(n, '9');
  cin >> s;
  for (int i = 0; i < n; ++i) {
    char lst = s[n - 1];
    s.erase(n - 1, 1);
    s = lst + s;
    int add = 10 - (s[0] - '0');
    string ans = s;
    for (int j = 0; j < n; ++j) {
      ans[j] = (ans[j] - '0' + add) % 10 + '0';
    }
    mn = min(mn, ans);
  }
  cout << mn;
  return 0;
}
