#include <bits/stdc++.h>
using namespace std;
string shiftRight(string expr) {
  string newexpr;
  newexpr.push_back(expr[expr.size() - 1]);
  for (int i = 0; i < expr.size() - 1; i++) {
    newexpr.push_back(expr[i]);
  }
  return newexpr;
}
string upWithOne(string expr) {
  string newexpr;
  char b;
  for (int i = 0; i < expr.size(); i++) {
    b = expr[i];
    if (b == '9') {
      b = '0';
    } else {
      b = b + 1;
    }
    newexpr.push_back(b);
  }
  return newexpr;
}
bool first_bigger(string first, string second) {
  for (int i = 0; i < first.size(); i++) {
    if (int(first[i]) == int(second[i])) {
      continue;
    } else if (int(first[i]) > int(second[i])) {
      return true;
    } else if (int(first[i]) < int(second[i])) {
      return false;
    }
  }
}
string getSmaller(string expr) {
  string one, two, temp, result;
  int n = expr.size();
  two = expr;
  result = expr;
  for (int i = 0; i < n; i++) {
    one = shiftRight(two);
    if (first_bigger(one, result)) {
      two = one;
    } else {
      result = one;
      two = one;
    }
  }
  return result;
}
int main() {
  int n;
  cin >> n;
  string numbers;
  cin >> numbers;
  string one, two, res;
  string temp;
  two = numbers;
  bool first_time = true;
  string first_c, second_c;
  temp = numbers;
  for (int i = 0; i < 10; i++) {
    if (first_time == true) {
      first_c = getSmaller(temp);
      first_time = false;
    } else {
      temp = upWithOne(temp);
      second_c = getSmaller(temp);
      if (first_bigger(first_c, second_c) == true) {
        first_c = second_c;
      }
    }
  }
  cout << first_c;
  return 0;
}
