public static void main ( String [ ] $ ) {
  int n = sc . nextInt ( ) ;
  ArrayList < Integer > list = new ArrayList < > ( ) ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    list . add ( sc . nextInt ( ) ) ;
  }
  ArrayDeque < Integer > ans = new ArrayDeque < > ( ) ;
  int c = 1 ;
  while ( c == 1 && ! list . isEmpty ( ) ) {
    for ( int i = list . size ( ) - 1 ;
    i > - 1 ;
    i -- ) {
      if ( list . get ( i ) == i + 1 ) {
        ans . push ( list . get ( i ) ) ;
        list . remove ( i ) ;
        c = 1 ;
        break ;
      }
      else c = 0 ;
    }
  }
  if ( list . size ( ) > 0 ) {
    out . println ( - 1 ) ;
  }
  else {
    while ( ! ans . isEmpty ( ) ) {
      out . println ( ans . pop ( ) ) ;
    }
  }
  out . close ( ) ;
}

public static void main ( String [ ] $ ) { int n = sc . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } ArrayDeque < Integer > ans = new ArrayDeque < > ( ) ; int c = 1 ; while ( c == 1 && ! list . isEmpty ( ) ) { for ( int i = list . size ( ) - 1 ; i > - 1 ; i -- ) { if ( list . get ( i ) == i + 1 ) { ans . push ( list . get ( i ) ) ; list . remove ( i ) ; c = 1 ; break ; } else c = 0 ; } } if ( list . size ( ) > 0 ) { out . println ( - 1 ) ; } else { while ( ! ans . isEmpty ( ) ) { out . println ( ans . pop ( ) ) ; } } out . close ( ) ; }
(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 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)))) (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: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) body: (block (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: (unary_expression operand: (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 (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (break_statement)) alternative: (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal)))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (unary_expression operand: (decimal_integer_literal)))))) alternative: (block (while_statement condition: (parenthesized_expression (unary_expression operand: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))