#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        n: usize,
        a: [i64; 3 * n]
    }

    let mut left_heap = std::collections::BinaryHeap::new();
    let mut left_sums = vec![0;n+1];
    let mut left_sum = 0;
    for i in 0..n {
        left_heap.push(Rev(a[i]));
        left_sum += a[i];
    }
    for i in 0..n {
        let j = i + n;
        left_sums[i] = left_sum;
        let tmp = left_heap.peek().cloned();
        match tmp { None => (), Some(Rev(v)) if v < a[j] => {
            left_sum += a[j] - v;
            left_heap.pop();
            left_heap.push(Rev(a[j]));
        }, _ => ()};
    }
    left_sums[n] = left_sum;
    let mut right_heap = std::collections::BinaryHeap::new();
    let mut right_sums = vec![0;n+1];
    let mut right_sum = 0;
    for i in 2*n..3*n {
        right_heap.push(a[i]);
        right_sum += a[i];
    }
    for i in 0..n {
        let j =  2*n - i - 1;
        right_sums[i] = right_sum;
        let tmp = right_heap.peek().cloned();
        match tmp { None => (), Some(v) if v > a[j] => {
            right_sum += a[j] - v;
            right_heap.pop();
            right_heap.push(a[j]);
        }, _ => ()};
    }
    right_sums[n] = right_sum;
    right_sums.reverse();
    println!("{}", left_sums.into_iter().zip(right_sums.into_iter()).map(|(a, b)| a - b).max().unwrap());
}

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);
impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<std::cmp::Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> std::cmp::Ordering {
        other.0.cmp(&self.0)
    }
}


Measured memory_bytes: 14588