public static void main ( String [ ] args ) {
  final Scanner sc = new Scanner ( System . in ) ;
  int n = sc . nextInt ( ) ;
  PriorityQueue < Long > left = new PriorityQueue < > ( n ) ;
  long [ ] center = new long [ n ] ;
  PriorityQueue < Long > right = new PriorityQueue < > ( ( l1 , l2 ) -> {
    return l2 . compareTo ( l1 ) ;
  }
  ) ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    left . add ( sc . nextLong ( ) ) ;
  }
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    center [ i ] = sc . nextLong ( ) ;
  }
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    right . add ( sc . nextLong ( ) ) ;
  }
  long [ ] lmove = new long [ n + 1 ] ;
  lmove [ 0 ] = left . stream ( ) . mapToLong ( i -> i ) . sum ( ) ;
  long [ ] rmove = new long [ n + 1 ] ;
  rmove [ 0 ] = right . stream ( ) . mapToLong ( i -> i ) . sum ( ) ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    left . add ( center [ i ] ) ;
    lmove [ i + 1 ] = lmove [ i ] - left . poll ( ) + center [ i ] ;
  }
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    right . add ( center [ n - 1 - i ] ) ;
    rmove [ i + 1 ] = rmove [ i ] - right . poll ( ) + center [ n - 1 - i ] ;
  }
  long ans = Long . MIN_VALUE ;
  for ( int i = 0 ;
  i <= n ;
  i ++ ) {
    long temp = lmove [ i ] - rmove [ n - i ] ;
    ans = Math . max ( temp , ans ) ;
  }
  System . out . println ( ans ) ;
}

public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; PriorityQueue < Long > left = new PriorityQueue < > ( n ) ; long [ ] center = new long [ n ] ; PriorityQueue < Long > right = new PriorityQueue < > ( ( l1 , l2 ) -> { return l2 . compareTo ( l1 ) ; } ) ; for ( int i = 0 ; i < n ; i ++ ) { left . add ( sc . nextLong ( ) ) ; } for ( int i = 0 ; i < n ; i ++ ) { center [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { right . add ( sc . nextLong ( ) ) ; } long [ ] lmove = new long [ n + 1 ] ; lmove [ 0 ] = left . stream ( ) . mapToLong ( i -> i ) . sum ( ) ; long [ ] rmove = new long [ n + 1 ] ; rmove [ 0 ] = right . stream ( ) . mapToLong ( i -> i ) . sum ( ) ; for ( int i = 0 ; i < n ; i ++ ) { left . add ( center [ i ] ) ; lmove [ i + 1 ] = lmove [ i ] - left . poll ( ) + center [ i ] ; } for ( int i = 0 ; i < n ; i ++ ) { right . add ( center [ n - 1 - i ] ) ; rmove [ i + 1 ] = rmove [ i ] - right . poll ( ) + center [ n - 1 - i ] ; } long ans = Long . MIN_VALUE ; for ( int i = 0 ; i <= n ; i ++ ) { long temp = lmove [ i ] - rmove [ n - i ] ; ans = Math . max ( temp , ans ) ; } System . out . println ( ans ) ; }
(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 (modifiers) type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (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 (identifier))))) (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: (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 (lambda_expression parameters: (inferred_parameters (identifier) (identifier)) body: (block (return_statement (method_invocation object: (identifier) 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: (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))))))) (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)))))) (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: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (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 (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (lambda_expression parameters: (identifier) body: (identifier)))) name: (identifier) 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 (array_access array: (identifier) index: (identifier))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) right: (array_access array: (identifier) index: (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: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (identifier)))))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) right: (array_access array: (identifier) index: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (identifier)))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (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: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))