#include <bits/stdc++.h>
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int exp(long long int x, long long int y, long long int mod) {
  long long int res = 1;
  x = x % mod;
  while (y > 0) {
    if (y & 1) res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res;
}
long long int modinverse(long long int x, long long int mod) {
  return exp(x, mod - 2, mod);
}
using namespace std;
const long long int inf = 0x3f3f3f3f3f3f3f3fll;
long long int dp[26][26];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, d;
  cin >> n;
  set<string> ans;
  string s;
  cin >> s;
  char y;
  for (long long int i = 0; i < n; i++) {
    string res = "";
    for (long long int j = i; j < n; j++) {
      if (s[j] >= s[i])
        y = (s[j] - s[i]) + '0';
      else
        y = (10 + '0') - (s[i] - s[j]);
      res += y;
    }
    for (long long int j = 0; j < i; j++) {
      if (s[j] >= s[i])
        y = (s[j] - s[i]) + '0';
      else
        y = (10 + '0') - (s[i] - s[j]);
      res += y;
    }
    ans.insert(res);
  }
  cout << *(ans.begin());
  return 0;
}
