#include <bits/stdc++.h>
using namespace std;
vector<long long int> indexOf(char* str, char* pattern) {
  vector<long long int> v;
  long long int slen = strlen(str);
  long long int patlen = strlen(pattern);
  for (long long int i = 0; i < slen; i++) {
    bool match = true;
    for (long long int j = 0; j < patlen; j++) {
      if (str[i + j] != pattern[j]) {
        match = false;
      }
    }
    if (match) {
      v.push_back(i);
    }
  }
  return v;
}
long long int maxBorder(char* a) {
  long long int len = strlen(a);
  char* pref = new char[len];
  char* suff = new char[len];
  long long int max = 0;
  for (long long int i = 0; i < len; i++) {
    copy(a, a + i, pref);
    pref[i] = '\0';
    copy(a + len - i, a + len, suff);
    suff[i] = '\0';
    if (!strcmp(pref, suff)) {
      max = strlen(pref);
    }
  }
  delete[] pref;
  delete[] suff;
  return max;
}
long long int* getBordersArray(char* str) {
  long long int len = strlen(str);
  long long int* res = new long long int[len]();
  char* buf = new char[len];
  for (long long int i = 0; i < len; i++) {
    copy(str, str + i + 1, buf);
    buf[i + 1] = '\0';
    long long int max = maxBorder(buf);
    res[i] = max;
  }
  return res;
}
long long int* getBordersArrayDP(char* str) {
  long long int len = strlen(str);
  long long int* dp = new long long int[len]();
  for (long long int i = 1; i < len; i++) {
    long long int index = dp[i - 1];
    while (1) {
      if (str[index] == str[i]) {
        dp[i] = index + 1;
        break;
      }
      if (index > 0) {
        index = dp[index - 1];
      } else {
        break;
      }
    }
  }
  return dp;
}
ostream_iterator<long long int> oi(cout, " ");
class Pair;
class Item {
  friend ostream& operator<<(ostream& out, const Pair& c);
  friend istream& operator>>(istream& out, Pair& c);

 public:
  Item(string des) { description = des; }
  long long int keyF() {
    key = description.length();
    return key;
  }
  string toString() { return description; }
  long long int key;
  string description;
};
ostream& operator<<(ostream& out, const Item& c) {
  out << c.description;
  return out;
}
istream& operator>>(istream& in, Item& c) {
  in >> c.description;
  return in;
}
ostream& operator<<(ostream& out, pair<long long int, long long int>& c) {
  out << "<" << c.first << ", ";
  out << c.second << ">" << endl;
  return out;
}
istream& operator>>(istream& in, pair<long long int, long long int>& c) {
  in >> c.first;
  in >> c.second;
  return in;
}
void print() { std::cout << endl; }
template <typename A>
void print(A value) {
  std::cout << value;
}
template <typename A, typename B>
void print(A value1, B value2) {
  cout << value1 << " " << value2;
}
template <typename A, typename B, typename C>
void print(A value1, B value2, C value3) {
  cout << value1 << " " << value2 << " " << value3;
}
template <typename A, typename B, typename C, typename D>
void print(A value1, B value2, C value3, D value4) {
  cout << value1 << " " << value2 << " " << value3 << " " << value4;
}
template <typename E>
E read() {
  E value;
  cin >> value;
  return value;
}
string readString() {
  char* s = new char[1000];
  fgets(s, 1000, stdin);
  return string(s);
}
template <typename A>
void println(A value) {
  std::cout << value << endl;
}
template <typename A, typename B>
void println(A value1, B value2) {
  cout << value1 << " " << value2 << endl;
}
template <typename A, typename B, typename C>
void println(A value1, B value2, C value3) {
  cout << value1 << " " << value2 << " " << value3 << endl;
}
template <typename A, typename B, typename C, typename D>
void println(A value1, B value2, C value3, D value4) {
  cout << value1 << " " << value2 << " " << value3 << " " << value4 << endl;
}
long long int randomint(long long int min, long long int max) {
  if (max == min) {
    return max;
  }
  return rand() % (max - min + 1) + min;
}
class Pair {
  friend ostream& operator<<(ostream& out, const Pair& c);
  friend istream& operator>>(istream& out, Pair& c);

 public:
  Pair(Item* p);
  long long int key;
  Item* value;
};
Pair::Pair(Item* b) {
  key = b->key;
  value = b;
}
ostream& operator<<(ostream& out, const Pair& c) {
  out << "(" << c.value->key << " -> " << (c.value->toString()) << ")";
  return out;
}
template <typename E>
class Array {
 public:
  long long int size;
  Array<E>(long long int _capacity) {
    capacity = _capacity;
    array = new E[capacity];
    size = capacity;
    for (long long int i = 0; i < size; i++) {
      array[i] = 0;
    }
  }
  void sort() { std::sort(&array[0], &array[size]); }
  Array() {
    capacity = 1024;
    array = new E[capacity];
    size = 0;
  }
  Array(vector<E>& vect) {
    long long int _size = vect.size();
    capacity = _size * 2;
    size = _size;
    array = new E[capacity];
    for (long long int i = 0; i < size; i++) {
      array[i] = vect[i];
    }
  }
  Array(long long int minBound, long long int maxBound, long long int _size) {
    srand(_size);
    capacity = _size * 2;
    size = _size;
    array = new E[capacity];
    for (long long int i = 0; i < size; i++) {
      array[i] = randomint(minBound, maxBound);
    }
  }
  void add(E item);
  long long int leftBinarySearch(E& item);
  long long int rightBinarySearch(E& item);
  pair<long long int, long long int> equalRange(E& item);
  bool binarySearch(E& item);
  E* begin();
  E* end();
  vector<E> toVector();
  void toString();
  E& operator[](long long int i);
  E& index(long long int i);
  E* array;
  void null(void) {
    for (long long int i = 0; i < size; i++) {
      array[i] = 0;
    }
  }

 private:
  long long int capacity;
  void ensureCapacity(long long int cap);
};
template <typename E>
void Array<E>::ensureCapacity(long long int cap) {
  capacity = capacity * 2;
  E* newArray = new E[capacity];
  memcpy(newArray, array, sizeof(E) * size);
  delete[] array;
  array = newArray;
}
template <typename E>
void Array<E>::toString() {
  long long int i = 0;
  E* begin = array;
  cout << "[";
  while (i < size) {
    if (i == size - 1) {
      cout << *array;
    } else {
      cout << *array << " ";
    }
    array++;
    i++;
  }
  cout << "]";
  cout << endl;
  array = begin;
}
template <typename E>
void Array<E>::add(E item) {
  if (capacity < size + 1) {
    ensureCapacity(size + 1);
  }
  array[size] = item;
  size++;
}
template <typename E>
E* Array<E>::begin() {
  return array;
}
template <typename E>
E* Array<E>::end() {
  return array + size;
}
template <typename E>
long long int Array<E>::leftBinarySearch(E& item) {
  return lower_bound(array, array + size, item) - array;
}
template <typename E>
long long int Array<E>::rightBinarySearch(E& item) {
  return upper_bound(array, array + size, item) - array;
}
template <typename E>
pair<long long int, long long int> Array<E>::equalRange(E& item) {
  pair<long long int*, long long int*> p(0, 0);
  p = equal_range(array, array + size, item);
  return make_pair(p.first - array, p.second - array);
}
template <typename E>
bool Array<E>::binarySearch(E& item) {
  return binary_search(array, array + size, item);
}
template <typename E>
vector<E> Array<E>::toVector() {
  vector<E> res = vector<E>(size);
  for (long long int i = 0; i < res.size(); i++) {
    res[i] = array[i];
  }
  return res;
}
template <typename T>
ostream& operator<<(ostream& out, Array<T>& c) {
  for (long long int i = 0; i < c.size; i++) {
    out << c[i] << " ";
  }
  return out;
}
ostream& operator<<(ostream& out,
                    Array<pair<long long int, long long int> >& c) {
  for (long long int i = 0; i < c.size; i++) {
    out << c[i];
  }
  return out;
}
template <typename T>
istream& operator>>(istream& in, Array<T>& c) {
  for (long long int i = 0; i < c.size; i++) {
    in >> c[i];
  }
  return in;
}
ostream& operator<<(ostream& out, map<long long int, long long int>& c) {
  map<long long int, long long int>::iterator it = c.begin();
  while (it != c.end()) {
    pair<long long int, long long int> entry = *it;
    out << entry;
    it++;
  }
  return out;
}
template <typename E>
E& Array<E>::operator[](long long int i) {
  if (i < size && i >= 0) {
    return array[i];
  } else {
    cout << "Array index out of bounds, index is " << i << ", size is " << size
         << endl;
    cout << "Array is " << endl;
    toString();
    assert(0);
  }
}
template <typename E>
class Matrix {
 public:
  long long int rows;
  long long int columns;
  Array<E> array;
  E& get(long long int x, long long int y);
  void set(long long int x, long long int y, E& value);
  E& operator()(long long int x, long long int y);
  Matrix<E> transpose();
  pair<E*, E*> getRow(long long int y);
  Matrix<E>(long long int c, long long int r) {
    rows = r;
    columns = c;
    array = Array<E>(rows * columns);
    array.null();
  }
  void swap(Matrix<E>& other) {
    std::swap(array, other.array);
    std::swap(rows, other.rows);
    std::swap(columns, other.columns);
  }
  Matrix<E>(long long int _columns, long long int _rows, long long int minBound,
            long long int maxBound) {
    rows = _rows;
    columns = _columns;
    long long int size = _rows * _columns;
    array = Array<E>(minBound, maxBound, size);
  }

 private:
};
template <typename E>
Matrix<E> Matrix<E>::transpose() {
  Matrix<long long int> b(rows, columns);
  for (long long int x = 0; x < columns; x++) {
    for (long long int y = 0; y < rows; y++) {
      b(y, x) = array.array[x + y * columns];
    }
  }
  return b;
}
template <typename E>
E& Matrix<E>::operator()(long long int x, long long int y) {
  if (x >= columns || x < 0) {
    cout << "x must be in range [0; " << columns - 1 << "], but it is " << x
         << endl;
    assert(0);
  }
  if (y >= rows || y < 0) {
    cout << "y must be in range [0; " << rows - 1 << "], but it is " << y
         << endl;
    assert(0);
  }
  return array.array[x + y * columns];
}
template <typename T>
istream& operator>>(istream& in, Matrix<T>& c) {
  for (long long int y = 0; y < c.rows; y++) {
    for (long long int x = 0; x < c.columns; x++) {
      in >> c(x, y);
    }
  }
  return in;
}
template <typename E>
pair<E*, E*> Matrix<E>::getRow(long long int y) {
  E* f = array.array + y * columns;
  E* s = array.array + (y + 1) * columns;
  pair<E*, E*> p(f, s);
  return p;
}
template <typename T>
ostream& operator<<(ostream& out, Matrix<T>& c) {
  for (size_t y = 0; y < c.rows; y++) {
    for (size_t x = 0; x < c.columns; x++) {
      out << c(x, y) << " ";
    }
    out << endl;
  }
}
long long int bpow(long long int a, long long int b) {
  if (b == 0) {
    return 1;
  } else {
    if (b % 2 == 0) {
      long long int half = bpow(a, b / 2);
      return half * half;
    } else {
      return bpow(a, b - 1) * a;
    }
  }
}
long long int fact(long long int n) {
  if (n == 1) {
    return 1;
  } else {
    return n * fact(n - 1);
  }
}
long long int gcd(long long int a, long long int b) {
  if (!b) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}
Array<pair<long long int, long long int> > factorize(long long int n) {
  Array<pair<long long int, long long int> > res;
  for (long long int i = 2; i < sqrt((double)n) + 1; i++) {
    if (n % i == 0) {
      pair<long long int, long long int> comp = make_pair(i, 1);
      n /= i;
      while (n % i == 0) {
        comp.second++;
        n /= i;
      }
      res.add(comp);
    }
  }
  if (n > 1) {
    res.add(make_pair(n, 1));
  }
  return res;
}
long long int euler(long long int n) {
  Array<pair<long long int, long long int> > fact = factorize(n);
  long long int res = 1;
  for (unsigned long long int i = 0; i < fact.size; i++) {
    long long int factor =
        pow((double)fact[i].first, (double)fact[i].second) -
        pow((double)fact[i].first, (double)fact[i].second - 1);
    res *= factor;
  }
  return res;
}
long long int inversePrime(long long int a, long long int m) {
  return bpow(a, m - 2) % m;
}
long long int inverseCoprimes(long long int a, long long int m) {
  return bpow(a, euler(m) - 1) % m;
}
long long int inverse(long long int a, long long int m) {
  if (gcd(a, m) == 1) {
    return inverseCoprimes(a, m);
  } else {
    assert(0);
    return -1;
  }
}
Array<long long int> enumerateDivisors(long long int n) {
  Array<pair<long long int, long long int> > divs = factorize(n);
  vector<long long int> totals = vector<long long int>(divs.size + 1);
  totals[0] = 1;
  for (unsigned long long int i = 1; i < divs.size + 1; i++) {
    totals[i] = totals[i - 1] * (divs[i - 1].second + 1);
  }
  Array<long long int> res;
  for (long long int i = 0; i < totals[totals.size() - 1]; i++) {
    vector<long long int> values = vector<long long int>(divs.size);
    for (unsigned long long int j = 0; j < values.size(); j++) {
      values[j] = (i / totals[j]) % (divs[j].second + 1);
    }
    long long int r = 1;
    for (unsigned long long int i = 0; i < values.size(); i++) {
      r *= bpow(divs[i].first, values[i]);
    }
    res.add(r);
  }
  return res;
}
istream& operator>>(istream& in, Pair& c) {
  in >> c.value->description;
  c.value->key = c.value->keyF();
  return in;
}
void reverse(char* str) {
  char temp;
  size_t len = strlen(str) - 1;
  size_t i;
  size_t k = len;
  for (i = 0; i < len; i++) {
    temp = str[k];
    str[k] = str[i];
    str[i] = temp;
    k--;
    if (k == (len / 2)) {
      break;
    }
  }
}
map<long long int, long long int> count(Array<long long int> a) {
  map<long long int, long long int> res;
  for (long long int i = 0; i < a.size; i++) {
    res[a[i]]++;
  }
  return res;
}
void itoa(long long int n, char s[]) {
  long long int radix = 10;
  long long int i, sign;
  if ((sign = n) < 0) n = -n;
  i = 0;
  do {
    s[i++] = n % radix + '0';
  } while ((n /= radix) > 0);
  if (sign < 0) s[i++] = '-';
  s[i] = '\0';
  reverse(s);
}
long long int* vectorToArray(vector<long long int> v) {
  long long int* a = new long long int[v.size()];
  for (unsigned long long int i = 0; i < v.size(); i++) {
    a[i] = v[i];
  }
  return a;
}
char* stringToNumber(long long int number) {
  char* res = new char[100];
  itoa(number, res);
  return res;
}
long long int numberToString(char* str) { return atoi(str); }
long long int booleanAnswerBinarySearch(Array<long long int> params,
                                        long long int left, long long int right,
                                        bool (*f)(Array<long long int> params,
                                                  long long int v)) {
  if (f(params, left) && !f(params, left - 1)) {
    return left;
  }
  if (f(params, right) && !f(params, right + 1)) {
    return right;
  }
  long long int middle = (left + right) / 2;
  long long int g = f(params, middle);
  if (g) {
    return booleanAnswerBinarySearch(params, left, middle, f);
  } else {
    return booleanAnswerBinarySearch(params, middle + 1, right, f);
  }
}
Array<Array<long long int> > enumerarePermutations(long long int n) {
  long long int fac = fact(n);
  Array<long long int> v;
  for (long long int i = 0; i < n; i++) {
    v.add(i + 1);
  }
  Array<Array<long long int> > res;
  for (long long int i = 0; i < fac - 1; i++) {
    Array<long long int> c(n);
    copy(v.array, v.array + v.size, c.array);
    res.add(c);
    next_permutation(v.array, v.array + v.size);
  }
  Array<long long int> c(n);
  copy(v.array, v.array + v.size, c.array);
  res.add(c);
  return res;
}
Array<Array<long long int> > enumerarePermutations(Array<long long int> array) {
  long long int n = array.size;
  long long int fac = fact(n);
  Array<long long int> v;
  for (long long int i = 0; i < n; i++) {
    v.add(array[i]);
  }
  Array<Array<long long int> > res;
  for (long long int i = 0; i < fac - 1; i++) {
    Array<long long int> c(n);
    copy(v.array, v.array + v.size, c.array);
    res.add(c);
    next_permutation(v.array, v.array + v.size);
  }
  Array<long long int> c(n);
  copy(v.array, v.array + v.size, c.array);
  res.add(c);
  return res;
}
Array<Array<long long int> > enumerareTuples(long long int n, long long int k) {
  long long int q = bpow(k, n);
  Array<Array<long long int> > res(q);
  for (long long int i = 0; i < q; i++) {
    Array<long long int> tuple(n);
    for (long long int j = 0; j < n; j++) {
      tuple[j] = (i / bpow(k, j)) % k;
    }
    res[i] = tuple;
  }
  return res;
}
Array<Array<long long int> > enumerareTuples(long long int n,
                                             Array<long long int> array) {
  long long int k = array.size;
  long long int q = bpow(k, n);
  Array<Array<long long int> > res(q);
  for (long long int i = 0; i < q; i++) {
    Array<long long int> tuple(n);
    for (long long int j = 0; j < n; j++) {
      tuple[j] = array[(i / bpow(k, j)) % k];
    }
    res[i] = tuple;
  }
  return res;
}
Array<long long int> sieve(long long int bound) {
  bool* array = new bool[bound + 1]();
  for (long long int i = 2; i * i <= bound; i++) {
    if (!array[i]) {
      for (long long int j = i + i; j <= bound; j += i) {
        array[j] = 1;
      }
    }
  }
  Array<long long int> res;
  for (long long int i = 2; i <= bound; i++) {
    if (!array[i]) {
      res.add(i);
    }
  }
  return res;
}
long long int f(long long int k) { return k & (k + 1); }
string alignLeft(string a, long long int length, char ch) {
  if (a.length() < length) {
    a = string(length - a.length(), ch) + a;
  }
  return a;
}
string decToRadix(long long int n, long long int radix) {
  string res("");
  if (n == 0) {
    res.push_back('0');
    return res;
  }
  while (n) {
    long long int digit = n % radix;
    res.push_back((char)(digit + '0'));
    n /= radix;
  }
  reverse(res.begin(), res.end());
  return res;
}
long long int radixToDec(string s, long long int radix) {
  long long int res = 0;
  reverse(s.begin(), s.end());
  for (long long int i = 0; i < s.length(); i++) {
    res += (s[i] - '0') * bpow(radix, i);
  }
  return res;
}
class F {
 public:
  long long int (*f)(long long int, long long int);
  long long int (*inverse)(long long int, long long int);
  long long int NEUTRAL;
  F(long long int (*pf)(long long int, long long int),
    long long int (*pinverse)(long long int, long long int), long long int n) {
    f = pf;
    inverse = pinverse;
    NEUTRAL = n;
  }
  F() {}
  long long int operator()(long long int a, long long int b) { return f(a, b); }
  long long int inversed(long long int a, long long int b) {
    return inverse(a, b);
  }
};
class BIT {
 public:
  F f;
  Array<long long int> tree;
  Array<long long int> array;
  BIT(F func, Array<long long int> source) {
    Array<long long int> arr(source.size);
    copy(source.begin(), source.end(), arr.begin());
    array = arr;
    f = func;
    Array<long long int> tr(source.size);
    tree = tr;
    for (long long int i = 0; i < source.size; i++) {
      add(i, array[i]);
    }
  }
  void add(long long int i, long long int delta) {
    for (long long int u = i; u < tree.size; u = u | (u + 1)) {
      tree[u] = f(tree[u], delta);
    }
  }
  long long int value(long long int l, long long int r) {
    return f.inversed(p(r), p(l - 1));
  }
  long long int p(long long int v) {
    if (v < 0) {
      return 0;
    }
    if (v == 0) {
      return tree[0];
    } else {
      return f(tree[v], p((v & (v + 1)) - 1));
    }
  }
};
int main(void) {
  string s;
  string copy;
  long long int n;
  cin >> n;
  cin >> s;
  string good = "";
  for (long long int i = 0; i < n; i++) {
    good.append("9");
  }
  copy = s;
  for (long long int q = 0; q < n; q++) {
    rotate(s.begin(), s.begin() + q, s.end());
    for (long long int j = 0; j <= 10; j++) {
      string ffff = s;
      for (long long int i = 0; i < n; i++) {
        if (s[i] - '0' + j > 9) {
          ffff[i] = '0' + (s[i] - '0' + j) % 10;
        } else {
          ffff[i] = s[i] + j;
        }
      }
      if (ffff < good) {
        good = ffff;
      }
    }
    s = copy;
  }
  print(good);
}
