#include <bits/stdc++.h>
using namespace std;
int num[1005];
char num0[1005];
int res1[1005];
int N;
int query() {
  int res = 0;
  for (int i = 0; i < N; i++) {
    if (num[i] != 0) {
      res *= 10;
      res += num[i];
    } else if (num[i] == 0) {
      res *= 10;
    }
  }
  return res >= 0 ? res : -res;
}
int move_1() {
  int t = num[0];
  for (int i = 0; i < N - 1; i++) {
    num[i] = num[i + 1];
  }
  num[N - 1] = t;
  return 0;
}
int up1() {
  for (int i = 0; i < N; i++) {
    if (num[i] == 9) {
      num[i] = 0;
    } else {
      num[i] += 1;
    }
  }
  return 0;
}
void print() {
  printf(" num = ");
  for (int i = 0; i < N; i++) {
    printf("%d", num[i]);
  }
  puts("");
}
void printres() {
  for (int i = 0; i < N; i++) {
    printf("%d", res1[i]);
  }
  puts("");
}
int panduan() {
  char temp1[1005], temp2[1005];
  for (int i = 0; i < N; i++) {
    temp1[i] = num[i] + '0';
  }
  for (int i = 0; i < N; i++) {
    temp2[i] = res1[i] + '0';
  }
  if (strcmp(temp1, temp2) < 0) {
    return 1;
  } else
    return 0;
}
int copy1() {
  for (int i = 0; i < N; i++) {
    num[i] = num0[i] - '0';
  }
  return 0;
}
int copy2() {
  for (int i = 0; i < N; i++) {
    res1[i] = num[i];
  }
  return 0;
}
int main() {
  while (scanf("%d", &N) != EOF) {
    getchar();
    for (int i = 0; i < N; i++) {
      scanf("%c", &num0[i]);
    }
    int res = 1e9;
    copy1();
    copy2();
    for (int i = 0; i < 10; i++) {
      for (int j = 1; j <= N; j++) {
        move_1();
        if (panduan() > 0) {
          copy2();
        }
      }
      up1();
    }
    printres();
  }
  return 0;
}
