#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int *a;
  int *b;
  a = new int[2002];
  b = new int[2002];
  for (int i = 0; i < s.size(); i++) {
    a[n - i - 1] = s[i] - '0';
    b[n - i - 1] = s[i] - '0';
  }
  for (int i = 0; i < n; i++) {
    a++;
    a[n - 1] = a[-1];
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < n; k++) {
        if (a[k] != 9)
          a[k]++;
        else
          a[k] = 0;
      }
      bool check = false;
      for (int k = n - 1; k > -1; k--) {
        if (a[k] < b[k]) {
          check = false;
          break;
        } else if (a[k] > b[k]) {
          check = true;
          break;
        }
      }
      if (!check)
        for (int k = n - 1; k > -1; k--) b[k] = a[k];
    }
  }
  for (int i = n - 1; i > -1; i--) cout << b[i];
}
