#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  string s;
  cin >> s;
  string min = s, temp = s;
  for (int i = 0; i < n; ++i) {
    int t = 10 - (temp[n - 1] - '0');
    for (int j = 0; j < n; ++j) {
      int k = temp[j] - '0';
      k = (k + t) % 10;
      temp[j] = k + '0';
    }
    char c = temp[n - 1];
    for (int j = n - 1; j > 0; --j) {
      temp[j] = temp[j - 1];
    }
    temp[0] = c;
    if (temp < min) {
      min = temp;
    }
  }
  cout << min << endl;
}
