#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
bool iseven(long long int n) {
  if ((n & 1) == 0) return true;
  return false;
}
void print(long long int t) { cout << t; }
void print(int t) { cout << t; }
void print(string t) { cout << t; }
void print(char t) { cout << t; }
void print(double t) { cout << t; }
void print(long double t) { cout << t; }
template <class T, class V>
void print(pair<T, V> p);
template <class T>
void print(vector<T> v);
template <class T>
void print(set<T> v);
template <class T, class V>
void print(map<T, V> v);
template <class T>
void print(multiset<T> v);
template <class T, class V>
void print(pair<T, V> p) {
  cout << "{";
  print(p.first);
  cout << ",";
  print(p.second);
  cout << "}";
}
template <class T>
void print(vector<T> v) {
  cout << "[ ";
  for (T i : v) {
    print(i);
    cout << " ";
  }
  cout << "]";
}
template <class T>
void print(set<T> v) {
  cout << "[ ";
  for (T i : v) {
    print(i);
    cout << " ";
  }
  cout << "]";
}
template <class T>
void print(multiset<T> v) {
  cout << "[ ";
  for (T i : v) {
    print(i);
    cout << " ";
  }
  cout << "]";
}
template <class T, class V>
void print(map<T, V> v) {
  cout << "[ ";
  for (auto i : v) {
    print(i);
    cout << " ";
  }
  cout << "]";
}
void solve() {
  long long int n;
  cin >> n;
  string s;
  cin >> s;
  string original = s;
  string ans = "";
  for (long long int i = 0; i < n; ++i) {
    ans += "9";
  }
  for (long long int i = 0; i < n; ++i) {
    s = original;
    long long int toincrease = 10 - (s[i] - '0');
    for (auto &ch : s) {
      long long int temp = (ch - '0' + toincrease) % 10;
      ch = '0' + temp;
    }
    string tempans = "";
    tempans += s[i];
    long long int ptr = (i + 1) % n;
    while (ptr != i) {
      tempans += s[ptr];
      ptr = (ptr + 1) % n;
    }
    ans = min(ans, tempans);
  }
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
