#include <bits/stdc++.h>
using namespace std;
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
void file() {}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
}
int n, k, add;
map<string, int> mp;
void solve(string str) {
  if (mp.find(str) != mp.end()) return;
  string tmp = str;
  mp[str] = 1;
  for (int i = 0; i < n; i++) {
    str[i]++;
    if (str[i] > '9') str[i] = '0';
  }
  solve(str);
  tmp = tmp.back() + tmp;
  tmp.pop_back();
  solve(tmp);
}
int main() {
  file();
  fast();
  string str;
  cin >> n >> str;
  solve(str);
  cout << mp.begin()->first << "\n";
  return 0;
}
