#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<string> S;
  vector<string> V;
  string s, a, b, x, y, z;
  cin >> s;
  y = s;
  V.push_back(s);
  S.insert(s);
  for (int k = 0; k < 9; k++) {
    x = "";
    for (int i = 0; i < n; i++) {
      if (y[i] == '0')
        x += "1";
      else if (y[i] == '1')
        x += "2";
      else if (y[i] == '2')
        x += "3";
      else if (y[i] == '3')
        x += "4";
      else if (y[i] == '4')
        x += "5";
      else if (y[i] == '5')
        x += "6";
      else if (y[i] == '6')
        x += "7";
      else if (y[i] == '7')
        x += "8";
      else if (y[i] == '8')
        x += "9";
      else if (y[i] == '9')
        x += "0";
    }
    V.push_back(x);
    S.insert(x);
    y = x;
  }
  for (int idx = 0; idx < V.size(); idx++) {
    for (int i = 1; i < n; i++) {
      x = "";
      y = "";
      for (int k = 0; k < i; k++) y += V[idx][k];
      for (int k = i; k < n; k++) x += V[idx][k];
      z = x + y;
      S.insert(z);
    }
  }
  cout << *S.begin();
  return 0;
}
