You got a box with a combination lock. The lock has a display showing *n* digits. There are two buttons on the box, each button changes digits on the display. You have quickly discovered that the first button adds 1 to all the digits (all digits 9 become digits 0), and the second button shifts all the digits on the display one position to the right (the last digit becomes the first one). For example, if the display is currently showing number 579, then if we push the first button, the display will show 680, and if after that we push the second button, the display will show 068.

You know that the lock will open if the display is showing the smallest possible number that can be obtained by pushing the buttons in some order. The leading zeros are ignored while comparing numbers. Now your task is to find the desired number.
The first line contains a single integer *n* (1 ≤ *n* ≤ 1000) — the number of digits on the display.

The second line contains *n* digits — the initial state of the display.
from __future__ import print_function # for PyPy2
from collections import Counter, OrderedDict
from itertools import permutations as perm
from fractions import Fraction
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
from math import *

g   = lambda : stdin.readline().strip()
gl  = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1e9)+7

n, = gil()
s = g()
ans = s

def solve(s):
	ans = s
	t = []
	for i in range(10):
		for c in s :
			v = int(c)+i
			if v > 9 : v -= 10
			t.append(str(v))
		# print(t)
		ans = min(ans, ''.join(t))
		t.clear()
	return ans


for i in range(n):
	ans = min(ans, solve(s[i:] + s[:i]))

print(ans)
