public static void main ( String [ ] args ) {
  FastReader in = new FastReader ( ) ;
  PrintWriter o = new PrintWriter ( System . out ) ;
  int n = in . nextInt ( ) ;
  char [ ] ch = in . next ( ) . toCharArray ( ) ;
  char [ ] ans = new char [ ch . length ] ;
  Arrays . fill ( ans , '9' ) ;
  for ( int i = 0 ;
  i <= 9 ;
  i ++ ) {
    char [ ] ch1 = new char [ ch . length ] ;
    for ( int j = 0 ;
    j < n ;
    j ++ ) {
      int val = ch [ j ] - '0' ;
      val = ( val + i ) % 10 ;
      ch1 [ j ] = ( char ) ( val + '0' ) ;
    }
    for ( int j = 0 ;
    j < n ;
    j ++ ) {
      char [ ] ch2 = new char [ ch . length ] ;
      for ( int k = 0 ;
      k < n ;
      k ++ ) {
        ch2 [ ( k + j ) % n ] = ch1 [ k ] ;
      }
      ans = compare ( ans , ch2 ) ;
    }
  }
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    o . print ( ans [ i ] ) ;
  }
  o . println ( ) ;
  o . close ( ) ;
  o . flush ( ) ;
  return ;
}

public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; PrintWriter o = new PrintWriter ( System . out ) ; int n = in . nextInt ( ) ; char [ ] ch = in . next ( ) . toCharArray ( ) ; char [ ] ans = new char [ ch . length ] ; Arrays . fill ( ans , '9' ) ; for ( int i = 0 ; i <= 9 ; i ++ ) { char [ ] ch1 = new char [ ch . length ] ; for ( int j = 0 ; j < n ; j ++ ) { int val = ch [ j ] - '0' ; val = ( val + i ) % 10 ; ch1 [ j ] = ( char ) ( val + '0' ) ; } for ( int j = 0 ; j < n ; j ++ ) { char [ ] ch2 = new char [ ch . length ] ; for ( int k = 0 ; k < n ; k ++ ) { ch2 [ ( k + j ) % n ] = ch1 [ k ] ; } ans = compare ( ans , ch2 ) ; } } for ( int i = 0 ; i < n ; i ++ ) { o . print ( ans [ i ] ) ; } o . println ( ) ; o . close ( ) ; o . flush ( ) ; return ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (field_access object: (identifier) field: (identifier)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (character_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (field_access object: (identifier) field: (identifier)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (character_literal)))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal)))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (field_access object: (identifier) field: (identifier)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier))) right: (array_access array: (identifier) index: (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier))))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (return_statement)))