#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 5;
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;
string get_min(int n, string a, string b) {
  for (int i = 0; i < n; i++) {
    if (a[i] > b[i])
      return b;
    else if (a[i] < b[i])
      return a;
  }
  return a;
}
void solve() {
  int n;
  cin >> n;
  string s, cur_min, temp = "";
  cin >> s;
  int diff = 10 - (s[0] - '0');
  for (int i = 0; i < n; i++) temp += ('0' + (s[i] - '0' + diff) % 10);
  cur_min = temp;
  for (int i = 1; i < n; i++) {
    temp = "";
    diff = 10 - (s[i] - '0');
    for (int j = 0; j < n; j++) {
      temp += ('0' + (s[(j + i) % n] - '0' + diff) % 10);
    }
    cur_min = get_min(n, temp, cur_min);
  }
  cout << cur_min << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  solve();
}
