#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, a[111111], m, b[111111];
  vector<long long> v;
  priority_queue<string> q;
  char c[111111];
  string s, s1;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> c[i];
    a[i] = c[i] - 48;
  }
  for (i = 1; i <= 10; i++) {
    for (int i1 = 1; i1 <= n; i1++) a[i1] = (a[i1] + 1) % 10;
    for (int i1 = 1; i1 <= n; i1++) {
      for (int i2 = i1; i2 <= n; i2++) s += a[i2] + 48;
      for (int i2 = 1; i2 <= i1 - 1; i2++) s += a[i2] + 48;
      q.push(s);
      s = "";
    }
  }
  while (!q.empty()) {
    s1 = q.top();
    q.pop();
  }
  cout << s1;
}
