public static void solve ( ) {
  int n = s . nextInt ( ) ;
  int y = s . nextInt ( ) ;
  long arr [ ] = new long [ n ] ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) arr [ i ] = s . nextLong ( ) ;
  Arrays . sort ( arr ) ;
  long med = arr [ n / 2 ] ;
  if ( med < y ) {
    long sum = ( long ) ( y - med ) ;
    arr [ n / 2 ] = y ;
    for ( int i = n / 2 + 1 ;
    i < n ;
    i ++ ) {
      if ( arr [ i ] < y ) {
        sum += ( y - arr [ i ] ) ;
      }
      else break ;
    }
    System . out . println ( sum ) ;
  }
  else {
    long sum = med - y ;
    arr [ n / 2 ] = y ;
    for ( int i = n / 2 - 1 ;
    i >= 0 ;
    i -- ) {
      if ( arr [ i ] > y ) {
        sum += ( arr [ i ] - y ) ;
      }
      else break ;
    }
    System . out . println ( sum ) ;
  }
}

public static void solve ( ) { int n = s . nextInt ( ) ; int y = s . nextInt ( ) ; long arr [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = s . nextLong ( ) ; Arrays . sort ( arr ) ; long med = arr [ n / 2 ] ; if ( med < y ) { long sum = ( long ) ( y - med ) ; arr [ n / 2 ] = y ; for ( int i = n / 2 + 1 ; i < n ; i ++ ) { if ( arr [ i ] < y ) { sum += ( y - arr [ i ] ) ; } else break ; } System . out . println ( sum ) ; } else { long sum = med - y ; arr [ n / 2 ] = y ; for ( int i = n / 2 - 1 ; i >= 0 ; i -- ) { if ( arr [ i ] > y ) { sum += ( arr [ i ] - y ) ; } else break ; } System . out . println ( sum ) ; } }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters) 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: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (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: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (cast_expression type: (integral_type) value: (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (identifier))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (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: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))))) alternative: (break_statement)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))) alternative: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (identifier))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) 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: (array_access array: (identifier) index: (identifier)) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier)))))) alternative: (break_statement)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))))