#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000010;
template <typename T>
inline T sqr(T x) {
  return (x * x);
}
int ans[1001];
int n;
int a[1001];
bool comp(int t[]) {
  for (int i = 0; i < n; i++) {
    if (t[i] < ans[i]) return true;
    if (t[i] > ans[i]) return false;
  }
  return false;
}
void calc(int pos) {
  int temp[1001], j = 0;
  for (int i = pos; i < n; i++, j++) temp[j] = a[i];
  for (int i = 0; i < pos; i++, j++) temp[j] = a[i];
  while (temp[0] != 0) {
    for (int i = 0; i < n; i++) {
      temp[i] = (temp[i] + 1) % 10;
    }
  }
  if (comp(temp)) {
    for (int i = 0; i < n; i++) ans[i] = temp[i];
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    char ch;
    cin >> ch;
    a[i] = ch - '0';
    ans[i] = 9;
  }
  for (int i = 0; i < n; i++) {
    calc(i);
  }
  for (int i = 0; i < n; i++) cout << ans[i];
  return 0;
}
