#include <bits/stdc++.h>
using namespace std;
string ans;
int n;
char l(char p) {
  if (p == '0') return '1';
  if (p == '1') return '2';
  if (p == '2') return '3';
  if (p == '3') return '4';
  if (p == '4') return '5';
  if (p == '5') return '6';
  if (p == '6') return '7';
  if (p == '7') return '8';
  if (p == '8') return '9';
  if (p == '9') return '0';
}
int main() {
  cin >> n;
  string word;
  cin >> word;
  ans = word;
  for (int i = 0; i <= 10; i++) {
    if (i > 0) {
      for (int j = 0; j < n; j++) {
        word[j] = l(word[j]);
      }
    }
    if (word < ans) ans = word;
    for (int j = 0; j < n; j++) {
      char first = word[n - 1];
      char prev = word[0];
      for (int k = 1; k < n; k++) {
        char aux = word[k];
        word[k] = prev;
        prev = aux;
      }
      word[0] = first;
      if (word < ans) ans = word;
    }
  }
  cout << ans << endl;
  return 0;
}
