#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
void dout() { cerr << endl; }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
  cerr << H << ' ';
  dout(T...);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  string s;
  cin >> s;
  string ans = "ans";
  for (int i = 0; i < n; i++) {
    string t = "0";
    for (int j = 1; j < n; j++) {
      t += (char)((s[j] - s[0] + 10) % 10 + '0');
    }
    ans = min(ans, t);
    rotate(s.begin(), s.begin() + 1, s.end());
  }
  cout << ans;
  return 0;
}
