public static int count ( List < Integer > data ) {
  int min = min ( data ) ;
  for ( int i = 0 ;
  i < data . size ( ) ;
  i ++ ) {
    Integer value = data . get ( i ) ;
    data . set ( i , value - min ) ;
  }
  boolean zero = true ;
  List < List > a = new ArrayList < > ( ) ;
  for ( int i = 0 ;
  i < data . size ( ) ;
  i ++ ) {
    int value = data . get ( i ) ;
    if ( zero && value > 0 ) {
      a . add ( new ArrayList < Integer > ( ) ) ;
      a . get ( a . size ( ) - 1 ) . add ( value ) ;
      zero = false ;
    }
    else if ( ! zero ) {
      if ( value > 0 ) {
        a . get ( a . size ( ) - 1 ) . add ( value ) ;
      }
      else {
        zero = true ;
      }
    }
  }
  int answer = min ;
  for ( int i = 0 ;
  i < a . size ( ) ;
  i ++ ) {
    answer += count ( a . get ( i ) ) ;
  }
  return answer ;
}

public static int count ( List < Integer > data ) { int min = min ( data ) ; for ( int i = 0 ; i < data . size ( ) ; i ++ ) { Integer value = data . get ( i ) ; data . set ( i , value - min ) ; } boolean zero = true ; List < List > a = new ArrayList < > ( ) ; for ( int i = 0 ; i < data . size ( ) ; i ++ ) { int value = data . get ( i ) ; if ( zero && value > 0 ) { a . add ( new ArrayList < Integer > ( ) ) ; a . get ( a . size ( ) - 1 ) . add ( value ) ; zero = false ; } else if ( ! zero ) { if ( value > 0 ) { a . get ( a . size ( ) - 1 ) . add ( value ) ; } else { zero = true ; } } } int answer = min ; for ( int i = 0 ; i < a . size ( ) ; i ++ ) { answer += count ( a . get ( i ) ) ; } return answer ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (generic_type (type_identifier) (type_arguments (type_identifier))) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation name: (identifier) arguments: (argument_list (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (identifier))))))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (true))) (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier))) arguments: (argument_list))))) (expression_statement (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (false)))) alternative: (if_statement condition: (parenthesized_expression (unary_expression operand: (identifier))) consequence: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) name: (identifier) arguments: (argument_list (identifier))))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (true)))))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))))) (return_statement (identifier))))