#include <bits/stdc++.h>
using namespace std;
vector<int> sol(0);
vector<int> on(0);
int main() {
  int n;
  cin >> n;
  sol.resize(n);
  on.resize(n);
  for (int j = 0; j < n; j++) {
    char c;
    cin >> c;
    on[j] = c - '0';
    sol[j] = 9;
  }
  for (int j = 0; j < n; j++) {
    int temp = 10 - on[0];
    temp %= 10;
    for (int i = 0; i < n; i++) {
      on[i] += temp;
      on[i] %= 10;
    }
    int i = 0;
    while (i != n && sol[i] == on[i]) {
      i++;
    }
    if (i != n && on[i] < sol[i]) {
      for (int k = 0; k < n; k++) sol[k] = on[k];
    }
    int sw = on[0];
    for (int k = 1; k < n; k++) {
      on[k - 1] = on[k];
    }
    on[n - 1] = sw;
  }
  for (int j = 0; j < n; j++) cout << sol[j];
  cout << endl;
}
