#include <bits/stdc++.h>
const bool debug = 0;
std::string min_shift(std::string s) {
  std::string answ = s;
  for (int i = 0; i < (int)(s).size(); ++i) {
    std::rotate(s.rbegin(), s.rbegin() + 1, s.rend());
    if (debug) {
      std::cout << "\t" << s << std::endl;
    }
    answ = std::min(answ, s);
  }
  return answ;
}
int main() {
  int n;
  std::string s;
  std::cin >> n >> s;
  if (debug) {
    std::cout << s << std::endl;
  }
  auto answ = min_shift(s);
  for (int i = 0; i < 9; ++i) {
    for (auto& it : s) it = char((it - '0' + 1) % 10 + '0');
    if (debug) {
      std::cout << s << std::endl;
    }
    answ = std::min(answ, min_shift(s));
  }
  std::cout << answ;
  return 0;
}
