"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

class priorityQueue{
  constructor(){
    this.a=[];
  }
  push(x){
    const a = this.a;
    for(var i = a.length, j; i; i = j){
      j = i - 1 >> 1;
      if(a[j] <= x)break;
      a[i] = a[j];
    }
    a[i] = x;
  }
  pop(){
    const a = this.a, r = a[0], x = a.pop(), k = a.length >> 1;
    for(var i = 0, j; i < k; i = j){
      j = (i << 1) + 1;
      if(a[j+1] < a[j])j++;
      if(x <= a[j])break;
      a[i] = a[j];
    }
    if(a.length)a[i] = x;
    return r;
  }
  get size(){
    return this.a.length;
  }
  get top(){
    return this.a[0];
  }
}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next();
  var a = nexts(n*3);
  var pq = new priorityQueue();
  var lt = Array(3*n+1);
  lt[0] = 0;
  for(var i = 0; i < 2*n; i++){
    lt[i+1] = lt[i]+a[i];
    pq.push(a[i]);
    if(i >= n){
      lt[i+1] -= pq.pop();
    }
  }
  pq = new priorityQueue();
  var rt = Array(3*n+1);
  rt[3*n] = 0;
  for(var i = 3*n-1; i >= n; i--){
    rt[i] = rt[i+1]-a[i];
    pq.push(-a[i]);
    if(i < 2*n){
      rt[i] -= pq.pop();
    }
  }
  var ans = -1e18;
  for(var i = n; i <= 2*n; i++){
    var t = lt[i] + rt[i];
    if(ans < t)ans = t;
  }
  return ans;
}