#include <bits/stdc++.h>
using namespace std;
bool mind(string s1, string s2) {
  bool chech = false;
  for (int i = 0; i < s1.size(); i++) {
    if (s1[i] == s2[i])
      continue;
    else if (s1[i] > s2[i]) {
      chech = true;
      break;
    } else {
      chech = false;
      break;
    }
  }
  return chech;
}
string addone(string s1) {
  int i;
  for (int i = 0; i < s1.size(); i++) {
    if (s1[i] == '9')
      s1[i] = '0';
    else
      s1[i]++;
  }
  return s1;
}
string right(string s) {
  string d;
  d = s.substr(s.size() - 1, 1) + s.substr(0, s.size() - 1);
  return d;
}
int main() {
  int n;
  string s, mins;
  cin >> n;
  cin >> s;
  mins = s;
  for (int i = 0; i < n; i++) {
    string s1 = s;
    for (int i = 0; i < 9; i++) {
      s1 = addone(s1);
      if (mind(mins, s1)) mins = s1;
    }
    s = right(s);
    if (mind(mins, s)) mins = s;
  }
  cout << mins << "\n";
}
