#include <bits/stdc++.h>
using namespace std;
long long int pow1(long long int n, long long int p) {
  if (p == 0) return 1;
  long long int x = pow1(n, p / 2);
  x = (x * x) % 1000000007;
  if (p % 2 == 0)
    return x;
  else
    return (x * n) % 1000000007;
}
bool sortbysec(const pair<long long int, long long int> &a,
               const pair<long long int, long long int> &b) {
  return (a.second < b.second);
}
bool compare(const pair<long long int, long long int> &p1,
             const pair<long long int, long long int> &p2) {
  if (p1.first < p2.first) return true;
  if (p1.first == p2.first) return p1.first < p2.second;
  return false;
}
long long int const maxn = 200007;
long long int nxt[maxn];
void seive() {
  for (long long int i = 2; i < maxn; ++i) {
    if (nxt[i] == 0) {
      nxt[i] = i;
      for (long long int j = i * i; j < maxn; j += i) {
        if (j >= maxn) {
          break;
        }
        if (nxt[j] == 0) nxt[j] = i;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i, j, k, e, f, n, c = 0, x = 0;
  string s;
  cin >> n;
  cin >> s;
  string r = "";
  r = s;
  if (n == 1) {
    cout << "0";
    return 0;
  }
  long long int ji;
  for (long long int ji = 0; ji < 1000; ji++) {
    e = (long long int)s[n - 1] - '0';
    f = 10 - e;
    for (long long int j = 0; j < n; j++) {
      e = (long long int)s[j] - '0';
      k = f + e;
      k = k % 10;
      s[j] = (char)k + '0';
    }
    for (j = n - 1; j > 0; j--) {
      swap(s[j], s[j - 1]);
    }
    string t = "";
    long long int tl = 0;
    for (long long int i = 0; i < n; i++) {
      if (s[i] != '0') {
        for (j = i; j < n; j++) {
          t = t + s[j];
        }
        break;
      } else {
        t = t + "0";
      }
    }
    long long int ct = t.compare(r);
    if (ct < 0) {
      r = t;
    }
  }
  cout << r;
  cout << "\n";
  return 0;
}
