#include <bits/stdc++.h>
using namespace std;
int sizeOfInput;
const int maxLen = 1005;
char input[maxLen];
void addOne(char input[], int in) {
  for (int i = 0; i < sizeOfInput; i++) {
    int temp = (input[i] - '0' + in) % 10;
    input[i] = temp + '0';
  }
}
void shift(char input[]) {
  char temp = input[0];
  for (int i = 1; i < sizeOfInput; i++) {
    input[i - 1] = input[i];
  }
  input[sizeOfInput - 1] = temp;
}
int main() {
  scanf("%d", &sizeOfInput);
  getchar();
  char b[maxLen] = {'0'};
  char ans[maxLen] = {'9'};
  for (int i = 0; i < maxLen; i++) {
    scanf("%c", &input[i]);
  }
  for (int i = 0; i <= 9; i++) {
    strcpy(b, input);
    addOne(input, i);
    for (int j = 0; j < maxLen; j++) {
      if (strcmp(ans, input) > 0) strcpy(ans, input);
      shift(input);
    }
    strcpy(input, b);
  }
  cout << ans << endl;
  return 0;
}
