#include <bits/stdc++.h>
using namespace std;
bool operator>(string a, string s) {
  long long as = a.size(), sh = s.size();
  if (as != sh) return as > sh;
  for (int i = 0; i < sh; i++)
    if (a[i] > s[i])
      return true;
    else if (a[i] < s[i])
      return false;
  return false;
}
int main() {
  int i, j, k, n, m, l, x, y;
  cin >> n;
  string s, p = "", r = "", w = "";
  char c;
  cin >> s;
  p.resize(n);
  r.resize(n);
  w.resize(n);
  p = s;
  for (i = 0; i < n; i++) {
    m = s[i] - 48;
    m = 10 - m;
    for (j = 0; j < n; j++) {
      k = ((s[j] - 48) + m) % 10;
      r[j] = k + 48;
    }
    l = i;
    for (x = 0; x < n; x++) {
      w[x] = r[l % n];
      l++;
    }
    if (p > w) {
      p = w;
    }
  }
  cout << p << endl;
}
