#include <bits/stdc++.h>
using namespace std;
int n;
void PrintSolve(const vector<int> &a) {
  for (int i = 0; i < n; ++i) cout << a[i];
}
int main() {
  cin >> n;
  vector<int> a(n);
  string s;
  cin >> s;
  for (int i = 0; i < n; ++i) a[i] = s[i] - '0';
  bool st = true;
  int step = 0;
  vector<vector<int>> states;
  states.push_back(a);
  while (st) {
    if (a[n - 1] != 0) {
      int add = 10 - a[n - 1];
      for (int i = 0; i < n; ++i) a[i] = (a[i] + add) % 10;
    }
    for (int i = n - 1; i > 0; --i) a[i] = a[i - 1];
    a[0] = 0;
    if (step != 0) {
      for (size_t i = 0; i < states.size(); ++i) {
        if (states[i] == a) {
          vector<int> minState = states[0];
          for (size_t i = 1; i < states.size(); ++i)
            if (states[i] < minState) minState = states[i];
          PrintSolve(minState);
          st = false;
          break;
        }
      }
    }
    states.push_back(a);
    ++step;
  }
  return 0;
}
