public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  int N = sc . nextInt ( ) ;
  PriorityQueue < Integer > mae = new PriorityQueue < Integer > ( ) ;
  PriorityQueue < Integer > ato = new PriorityQueue < Integer > ( ( Integer x1 , Integer x2 ) -> x2 - x1 ) ;
  long [ ] maeSum = new long [ N + 1 ] ;
  long [ ] atoSum = new long [ N + 1 ] ;
  long ans = Long . MIN_VALUE ;
  int [ ] A = new int [ N * 3 ] ;
  for ( int i = 0 ;
  i < N * 3 ;
  i ++ ) {
    int a = sc . nextInt ( ) ;
    A [ i ] = a ;
    if ( i < N ) {
      mae . add ( a ) ;
      maeSum [ 0 ] += a ;
    }
    else if ( i >= N * 2 ) {
      ato . add ( a ) ;
      atoSum [ N ] += a ;
    }
  }
  for ( int i = N ;
  i < N * 2 ;
  i ++ ) {
    int k = i - ( N - 1 ) ;
    if ( A [ i ] > mae . peek ( ) ) {
      maeSum [ k ] = maeSum [ k - 1 ] - mae . poll ( ) + A [ i ] ;
      mae . add ( A [ i ] ) ;
    }
    else {
      maeSum [ k ] = maeSum [ k - 1 ] ;
    }
  }
  for ( int i = N * 2 - 1 ;
  i >= N ;
  i -- ) {
    int k = i - N ;
    if ( A [ i ] < ato . peek ( ) ) {
      atoSum [ k ] = atoSum [ k + 1 ] - ato . poll ( ) + A [ i ] ;
      ato . add ( A [ i ] ) ;
    }
    else {
      atoSum [ k ] = atoSum [ k + 1 ] ;
    }
  }
  for ( int i = 0 ;
  i <= N ;
  i ++ ) {
    ans = Math . max ( ans , maeSum [ i ] - atoSum [ i ] ) ;
  }
  System . out . println ( ans ) ;
  sc . close ( ) ;
}

public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; PriorityQueue < Integer > mae = new PriorityQueue < Integer > ( ) ; PriorityQueue < Integer > ato = new PriorityQueue < Integer > ( ( Integer x1 , Integer x2 ) -> x2 - x1 ) ; long [ ] maeSum = new long [ N + 1 ] ; long [ ] atoSum = new long [ N + 1 ] ; long ans = Long . MIN_VALUE ; int [ ] A = new int [ N * 3 ] ; for ( int i = 0 ; i < N * 3 ; i ++ ) { int a = sc . nextInt ( ) ; A [ i ] = a ; if ( i < N ) { mae . add ( a ) ; maeSum [ 0 ] += a ; } else if ( i >= N * 2 ) { ato . add ( a ) ; atoSum [ N ] += a ; } } for ( int i = N ; i < N * 2 ; i ++ ) { int k = i - ( N - 1 ) ; if ( A [ i ] > mae . peek ( ) ) { maeSum [ k ] = maeSum [ k - 1 ] - mae . poll ( ) + A [ i ] ; mae . add ( A [ i ] ) ; } else { maeSum [ k ] = maeSum [ k - 1 ] ; } } for ( int i = N * 2 - 1 ; i >= N ; i -- ) { int k = i - N ; if ( A [ i ] < ato . peek ( ) ) { atoSum [ k ] = atoSum [ k + 1 ] - ato . poll ( ) + A [ i ] ; ato . add ( A [ i ] ) ; } else { atoSum [ k ] = atoSum [ k + 1 ] ; } } for ( int i = 0 ; i <= N ; i ++ ) { ans = Math . max ( ans , maeSum [ i ] - atoSum [ i ] ) ; } System . out . println ( ans ) ; sc . 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: (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 (type_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 (type_identifier))) arguments: (argument_list (lambda_expression parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier)) (formal_parameter type: (type_identifier) name: (identifier))) body: (binary_expression left: (identifier) right: (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 (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (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)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (field_access object: (identifier) field: (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 (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) 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)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (decimal_integer_literal)) right: (identifier)))) alternative: (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 (identifier)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier)))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) right: (array_access array: (identifier) index: (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)))))) alternative: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))))))) (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 (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (binary_expression left: (binary_expression left: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) right: (array_access array: (identifier) index: (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)))))) alternative: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))))))) (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: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))