#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool read(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c < '0' || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
int X[] = {-1, -1, -1, 0, 1, 1, 1, 0};
int Y[] = {-1, 0, +1, 1, 1, 0, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
string arr;
int main() {
  int n;
  cin >> n;
  cin >> arr;
  string minStr = arr;
  for (int i = 0; i < n; i++) {
    string tmp;
    tmp.push_back('0');
    for (int j = i + 1; j < n; j++) {
      int a = arr[i] - '0';
      int b = arr[j] - '0';
      int dif = (a > b) ? (10 - a) + b : b - a;
      tmp.push_back(char(dif + '0'));
    }
    for (int j = 0; j < i; j++) {
      int a = arr[i] - '0';
      int b = arr[j] - '0';
      int dif = (a > b) ? (10 - a) + b : b - a;
      tmp.push_back(char(dif + '0'));
    }
    if (tmp < minStr) minStr = tmp;
  }
  cout << minStr << endl;
  return 0;
}
