← Home
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)

	best := ""

	for i := 0; i < n; i++ {
		shifted := s[i:] + s[:i]
		diff := (10 - int(shifted[0]-'0')) % 10

		current := make([]byte, n)
		for j := 0; j < n; j++ {
			current[j] = byte((int(shifted[j]-'0')+diff)%10 + '0')
		}

		strCurrent := string(current)
		if best == "" || strCurrent < best {
			best = strCurrent
		}
	}

	fmt.Println(best)
}