#include <bits/stdc++.h>
using namespace std;
int n;
char ini;
string s = "", t, temporal = "";
vector<string> v;
void start() {
  cin >> n;
  int times = 0;
  cin >> t;
  while (times <= s.size()) {
    s = "";
    temporal = "";
    int dist = 0;
    for (int i = 0; i < t.size(); i++) {
      if (i == 0) {
        s = s + '0';
        dist = (t.at(i) - '0' == '0') ? 0 : 10 - (t.at(i) - '0');
        ini = t.at(i);
      } else {
        s += (((t.at(i) - '0') + dist) >= 10)
                 ? (char)((((t.at(i) - '0') + dist) - 10) + '0')
                 : (char)(((t.at(i) - '0') + dist) + '0');
        temporal = temporal + t.at(i);
      }
    }
    v.push_back(s);
    temporal = temporal + ini;
    t = temporal;
    times++;
  }
  sort(v.begin(), v.end());
  cout << v[0] << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  start();
  return 0;
}
