// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define int long long

int a[3*114514];

int b[3*114514];

int c[3*114514];

signed main(){

  int n;

  cin>>n;

  for(int i=0;i<n*3;i++) cin>>a[i];

  priority_queue<int,vector<int>,greater<int> > q1;

  priority_queue<int> q2;

  memset(b,0,sizeof(b));

  memset(c,0,sizeof(c));

  int tmp1=0,tmp2=0;

  for(int i=0;i<n;i++){

    q1.push(a[i]);

    tmp1+=a[i];

    b[i]=tmp1;

    q2.push(a[3*n-1-i]);

    tmp2+=a[3*n-1-i];

    c[3*n-1-i]=tmp2;

  }

  for(int i=n;i<n*3;i++){

    q1.push(a[i]);

    tmp1+=a[i];

    int k=q1.top();q1.pop();

    tmp1-=k;

    b[i]=tmp1;

    q2.push(a[3*n-1-i]);

    tmp2+=a[3*n-1-i];

    k=q2.top();q2.pop();

    tmp2-=k;

    c[3*n-1-i]=tmp2;

  }

  int ans=-(1LL<<55LL);

  for(int i=n-1;i<2*n;i++){

    ans=max(ans,b[i]-c[i+1]);

  }

  cout<<ans<<endl;

  return 0;

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

using Int = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}

template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//BEGIN CUT HERE

// return sum of top K element (default: maximum)

template<typename T, T identity, typename V=vector<T>,

         typename C1=less<T>, typename C2=greater<T> >

struct PrioritySum{

  size_t num;

  T sum;  

  priority_queue<T, V, C1> pq1;

  priority_queue<T, V, C2> pq2;

  PrioritySum():num(0),sum(identity){}

  PrioritySum(size_t num):num(num),sum(identity){}



  void resolve(){

    assert(pq1.size()+pq2.size()>=num);

    while(pq2.size()<num){

      sum+=pq1.top();

      pq2.emplace(pq1.top());

      pq1.pop();

    }

    while(pq2.size()>num){

      sum-=pq2.top();

      pq1.emplace(pq2.top());

      pq2.pop();

    }

    if(pq1.empty()||pq2.empty()) return;

    while(C2()(pq1.top(),pq2.top())){

      T t1=pq1.top();pq1.pop();

      T t2=pq2.top();pq2.pop();

      sum+=t1;

      sum-=t2;

      pq1.emplace(t2);

      pq2.emplace(t1);

    }

  }



  T query(){resolve();return sum;}

  

  void push(const T &x){pq1.emplace(x);}

  void expand(){num++;}

  void shrink(){assert(num);num--;}

};

//END CUT HERE



struct FastIO{

  FastIO(){

    cin.tie(0);

    ios::sync_with_stdio(0);

  }

}fastio_beet;



//INSERT ABOVE HERE

signed ARC074_D(){

  using ll = long long;

  using PS1 = PrioritySum<ll, ll(0), vector<ll>, less<ll>, greater<ll> >;

  using PS2 = PrioritySum<ll, ll(0), vector<ll>, greater<ll>, less<ll> >;

  

  int n;

  cin>>n;

  vector<ll> a(3*n);

  for(int i=0;i<3*n;i++) cin>>a[i];



  PS1 ps1(n);

  vector<ll> dp1(3*n);

  for(int i=0;i<3*n;i++){

    if(i>=n) dp1[i]=ps1.query();

    ps1.push(a[i]);

  }

  

  PS2 ps2(n);

  vector<ll> dp2(3*n);

  for(int i=3*n-1;i>=0;i--){

    ps2.push(a[i]);

    if(i<=2*n) dp2[i]=ps2.query();

  }



  ll ans=dp1[n]-dp2[n];  

  for(int i=n;i<=2*n;i++) chmax(ans,dp1[i]-dp2[i]);

  

  cout<<ans<<endl;

  return 0;

}

/*

  verified on 2019/04/09

  https://atcoder.jp/contests/arc074/tasks/arc074_b 

*/



signed main(){

  ARC074_D(); 

  return 0;

}


// Fastest known solution for this problem: