public static void main ( String [ ] args ) {
  int N = ni ( ) ;
  List < Integer > b = new ArrayList < > ( ) ;
  for ( int i = 0 ;
  i < N ;
  i ++ ) {
    b . add ( sc . nextInt ( ) ) ;
  }
  List < Integer > seq = new ArrayList < > ( ) ;
  boolean canPick = true ;
  while ( canPick ) {
    canPick = false ;
    for ( int i = b . size ( ) - 1 ;
    i >= 0 ;
    i -- ) {
      if ( b . get ( i ) == i + 1 ) {
        b . remove ( i ) ;
        seq . add ( i + 1 ) ;
        canPick = true ;
        break ;
      }
    }
  }
  if ( b . isEmpty ( ) ) {
    Collections . reverse ( seq ) ;
    for ( int s : seq ) {
      out . println ( s ) ;
    }
  }
  else {
    out . println ( - 1 ) ;
  }
}

public static void main ( String [ ] args ) { int N = ni ( ) ; List < Integer > b = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { b . add ( sc . nextInt ( ) ) ; } List < Integer > seq = new ArrayList < > ( ) ; boolean canPick = true ; while ( canPick ) { canPick = false ; for ( int i = b . size ( ) - 1 ; i >= 0 ; i -- ) { if ( b . get ( i ) == i + 1 ) { b . remove ( i ) ; seq . add ( i + 1 ) ; canPick = true ; break ; } } } if ( b . isEmpty ( ) ) { Collections . reverse ( seq ) ; for ( int s : seq ) { out . println ( s ) ; } } else { out . println ( - 1 ) ; } }
(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: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (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 (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (true))) (while_statement condition: (parenthesized_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (false))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal))))) (expression_statement (assignment_expression left: (identifier) right: (true))) (break_statement))))))) (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (enhanced_for_statement type: (integral_type) name: (identifier) value: (identifier) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))) alternative: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (unary_expression operand: (decimal_integer_literal)))))))))