#include <bits/stdc++.h>
using namespace std;
int n;
string str;
string bestResult;
void p() {
  for (int j = 0; j < n; j++) {
    if (str[j] == '9') {
      str[j] = '0';
    } else {
      str[j] += 1;
    }
  }
}
void s() {
  int a;
  a = str[0];
  for (int j = 0; j < n - 1; j++) {
    str[j] = str[j + 1];
  }
  str[n - 1] = a;
}
void result() {
  if (str < bestResult) {
    bestResult = str;
  }
}
int main() {
  cin >> n;
  char a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    str += a;
  }
  bestResult = str;
  for (int i = 0; i <= 9; i++) {
    for (int j = 0; j < n; j++) {
      s();
      result();
    }
    p();
    result();
  }
  cout << bestResult;
  return EXIT_SUCCESS;
}
