#include <bits/stdc++.h>
using namespace std;
const int N = 1234567;
const long long inf = 1e9;
const long double eps = 1e-9;
const long double pi = acos(-1);
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  string ip;
  cin >> ip;
  string mn;
  for (int i = 0; i < 1000; i++) mn.push_back('9');
  for (int i = 0; i < n; i++) {
    string ans = ip;
    string copy = ip;
    int val = 10 - (ip[i] - '0');
    for (int j = 0; j < n; j++) {
      copy[j] += val;
      if (copy[j] > 57) copy[j] -= 10;
    }
    for (int j = 0; j < n; j++) ans[(j + (n - i)) % n] = copy[j];
    mn = min(ans, mn);
  }
  cout << mn << '\n';
  return 0;
}
