#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e16;
const long long int maxn = 1 << 20;
double pie = 3.1415926535;
string str[101];
bool done[101];
int main() {
  long long int n, i, j, cnt, offset;
  string s, s1, ans;
  cin >> n >> s;
  ans = "";
  for (i = 0; i < n; i++) ans += '9';
  for (i = 0; i < n; i++) {
    offset = 10 - (s[i] - '0');
    s1.clear();
    for (j = i, cnt = 0; cnt < n; cnt++, j++) {
      long long int x = (s[j] - '0' + offset) % 10;
      s1 += (x + '0');
      if (j == n - 1) j = -1;
    }
    ans = min(ans, s1);
  }
  cout << ans << endl;
}
