public static String solve ( ) {
  String out = "" ;
  int n = in . nextInt ( ) ;
  int [ ] count = new int [ n ] ;
  int remaining = 0 ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    count [ i ] = in . nextInt ( ) ;
    remaining += count [ i ] ;
  }
  while ( remaining > 0 ) {
    out += " " ;
    int maxIdx = - 1 ;
    for ( int i = 0 ;
    i < n ;
    i ++ ) {
      if ( count [ i ] > 0 && ( maxIdx == - 1 || count [ i ] > count [ maxIdx ] ) ) {
        maxIdx = i ;
      }
    }
    out += ( char ) ( maxIdx + 'A' ) ;
    count [ maxIdx ] -- ;
    remaining -- ;
    if ( remaining <= 0 ) break ;
    maxIdx = - 1 ;
    int gT0 = 0 ;
    boolean tie = false ;
    for ( int i = 0 ;
    i < n ;
    i ++ ) {
      if ( count [ i ] > 0 ) {
        gT0 ++ ;
      }
      if ( count [ i ] > 0 && ( maxIdx == - 1 || count [ i ] > count [ maxIdx ] ) ) {
        maxIdx = i ;
      }
      else if ( count [ i ] > 0 && gT0 == 2 && count [ i ] == count [ maxIdx ] ) {
        tie = true ;
      }
    }
    boolean skip = tie && gT0 == 2 ;
    if ( ! skip ) {
      out += ( char ) ( maxIdx + 'A' ) ;
      count [ maxIdx ] -- ;
      remaining -- ;
    }
  }
  return out ;
}

public static String solve ( ) { String out = " " ; int n = in . nextInt ( ) ; int [ ] count = new int [ n ] ; int remaining = 0 ; for ( int i = 0 ; i < n ; i ++ ) { count [ i ] = in . nextInt ( ) ; remaining += count [ i ] ; } while ( remaining > 0 ) { out += " ▁ " ; int maxIdx = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( count [ i ] > 0 && ( maxIdx == - 1 || count [ i ] > count [ maxIdx ] ) ) { maxIdx = i ; } } out += ( char ) ( maxIdx + ' A ' ) ; count [ maxIdx ] -- ; remaining -- ; if ( remaining <= 0 ) break ; maxIdx = - 1 ; int gT0 = 0 ; boolean tie = false ; for ( int i = 0 ; i < n ; i ++ ) { if ( count [ i ] > 0 ) { gT0 ++ ; } if ( count [ i ] > 0 && ( maxIdx == - 1 || count [ i ] > count [ maxIdx ] ) ) { maxIdx = i ; } else if ( count [ i ] > 0 && gT0 == 2 && count [ i ] == count [ maxIdx ] ) { tie = true ; } } boolean skip = tie && gT0 == 2 ; if ( ! skip ) { out += ( char ) ( maxIdx + ' A ' ) ; count [ maxIdx ] -- ; remaining -- ; } } return out ; }
(method_declaration (modifiers) type: (type_identifier) name: (identifier) parameters: (formal_parameters) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (string_literal))) (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: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_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 (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (expression_statement (assignment_expression left: (identifier) right: (string_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_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 (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)) right: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))))))) (expression_statement (assignment_expression left: (identifier) right: (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal)))))) (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))) (expression_statement (update_expression (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (break_statement)) (expression_statement (assignment_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (false))) (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 (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (update_expression (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)) right: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier)))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (decimal_integer_literal)) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (true)))))))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (unary_expression operand: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (identifier) right: (character_literal)))))) (expression_statement (update_expression (array_access array: (identifier) index: (identifier)))) (expression_statement (update_expression (identifier))))))) (return_statement (identifier))))