#include <bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
//#define int long long 
#define ll            long long 
#define sz(a)         int((a).size())
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define tr(c,i)       for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)  ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define endl          '\n'
#define MOD           1000000007
#define INF           10000000000000000

bool comp(const pair<int, string> &a, const pair<int, string> &b) {
    if (a.first == b.first) {
        return a.second < b.second;
    } else {
        return a.first > b.first;
    }
}

int GCD(int A, int B) {
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}

bool IsPowerOfTwo(ll x)
{
    return (x != 0) && ((x & (x - 1)) == 0);
}
/*bool pdt(ll mid){
    c=s;
    for(ll i=0;i<mid;i++){
        c[a[i]-1]='0';
    }
    ll cnt=0;
    for(ll i=0;i<n;i++){
        if(c[i]==p[cnt]) cnt++;
        
        if(cnt>=m) return true;
    }
    return false;
}*/

ll modularExponentiation(int x,int n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%MOD,n/2);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%MOD,(n-1)/2))%MOD;

}

ll fct(ll n)
{
    if (n > 1)
        return (n%MOD*fct(n-1)%MOD)%MOD;
    else
        return 1;
}

ll nCrmodp(ll n, ll r, ll p)
{
  ll c[r+1];
  memset(c, 0, sizeof(c)); 
  c[0]=1;
  
  for(ll i=1;i<=n;i++)
  {
    for(ll j=min(i,r);j>0;j--){
      c[j]=(c[j]+c[j-1])%p;
      //cout << c[j] << endl;
    }
  }
  return c[r];
}

//https://arc074.contest.atcoder.jp/tasks/arc074_b
// Using priority_queue as max and min heap.

int main(){
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll i,j,k,n,x,mid,sum1=0,sum2=0,ans,l[300005],r[300005];
  vector<ll> v(300005);
  cin >>n;
  for(i=0;i<3*n;i++) cin >> v[i];
  
  priority_queue <int> pq; //max heap for first half
  priority_queue <int,vector<int>,greater<int> > pq2;  //min heap for second half
  
  ll csum=0;
  for(i=0;i<3*n;i++){
    pq2.push(v[i]);
    csum+=v[i];
    if(pq2.size()>n){
      csum-=pq2.top();
      pq2.pop();
    }
    if(pq2.size()==n) l[i]=csum;
    else              l[i]=-INF;  //maximum  possible sumof n numbers till ith index so, 
	}											//if i<n or pq2.size<n set it to -inf cause it is not favourable
  
  csum=0;
  for(i=3*n-1;i>=0;i--){
    pq.push(v[i]);
    csum+=v[i];
    
    if(pq.size()>n){
      csum-=pq.top();
      pq.pop();
    }
    if(pq.size()==n) r[i]=csum;
    else             r[i]=INF;   //minimum  possible sumof n numbers till ith index from back so, 
	}											//if i<2*n or pq2.size<n set it to inf cause it is not favourable
  
  ans=-INF;
  for(i=0;i<3*n-1;i++){
    ans=std::max(ans,l[i]-r[i+1]);  //checking at where the partition would be for maximum ans
								// u can also loop from n to 2*n because l[i]is -inf before n and r[i]is inf after 2*n
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 8440