// Slower C++ solution:
#include<cmath>

#include<queue>

#include<cstdio>

#include<cstring>

#include<iostream>

#include<algorithm>

#define mod 1000000007

using namespace std;



int n;

long long dp1[300010],dp2[300010],a[300010],sum1,sum2;



priority_queue<long long,vector<long long>,greater<long long> > q;

priority_queue<long long> q2;



int main()

{

	//fuck!!!

	scanf("%d",&n);

	memset(dp1,0,sizeof(dp1));

	memset(dp2,0x3f,sizeof(dp2));

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

	{

		scanf("%lld",&a[i]);

	}

	for(int i=1;i<=n;i++)

	{

		q.push(a[i]);

		sum1+=a[i];

	}

	dp1[n]=sum1;

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

	{

		if(q.top()<a[i])

		{

			sum1-=q.top();

			sum1+=a[i];

			q.pop();

			q.push(a[i]);

		}

		dp1[i]=sum1;

	}

	for(int i=3*n;i>2*n;i--)

	{

		q2.push(a[i]);

		sum2+=a[i];

	}

	dp2[2*n+1]=sum2;

	for(int i=2*n;i>=1;i--)

	{

		if(q2.top()>a[i])

		{

			sum2-=q2.top();

			sum2+=a[i];

			q2.pop();

			q2.push(a[i]);

		}

		dp2[i]=sum2;

	}

	long long ans=-0x3f3f3f3f3f3f3f3f;

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

	{

//		printf("%d %lld %lld\n",i,dp1[i],dp2[i]);

		ans=max(ans,dp1[i]-dp2[i+1]);

	}

	printf("%lld\n",ans);

}

// Faster C++ solution for the same problem (measured speedup: 5.895918038624999x):
#include<bits/stdc++.h>



using namespace std;

inline void read(long long &x) {

    char ch;

    bool flag = false;

    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;

    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());

    x = flag ? -x : x;

}

inline void write(long long x) {

    static const long long maxlen = 100;

    static char s[maxlen];

    if (x < 0) {   putchar('-'); x = -x;}

    if (!x) { putchar('0'); return; }

    long long len = 0; for (; x; x /= 10) s[len++] = x % 10 + '0';

    for (long long i = len - 1; i >= 0; --i) putchar(s[i]);

}



inline void read(int &x){

    char ch;

    bool flag = false;

    for (ch = getchar(); !isdigit(ch); ch = getchar())if (ch == '-') flag = true;

    for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());

    x = flag ? -x : x;

}



const long long MAXN =1001000;



long long n;

long long a[ MAXN ];

long long f[ MAXN ];

long long g[ MAXN ];



priority_queue<long long,vector<long long>,greater<long long> > Q;



priority_queue<long long,vector<long long>,less<long long> > P;



int main(){

    read(n);

    for (long long i=1;i<=3*n;i++)

        read(a[i]);



    for (long long i=1;i<=n;i++)

    {

        Q.push(a[i]);

        f[n]+=a[i];

    }



    for (long long i=n+1;i<=n*2;i++)

        if ( a[i]>Q.top() )

            {

                f[i]=f[i-1]+a[i]-Q.top();

                Q.pop();

                Q.push(a[i]);

            }

        else

            f[i]=f[i-1];



    for (long long i=2*n+1;i<=3*n;i++)

    {

        P.push(a[i]);

        g[2*n+1]+=a[i];

    }



    for (long long i=2*n;i>=n+1;i--)

        if ( a[i]<P.top() )

            {

                g[i]=g[i+1]+a[i]-P.top();

                P.pop();

                P.push(a[i]);

            }

        else

            g[i]=g[i+1];

    long long ans=-1e15;

    for (long long i=n;i<=2*n;i++)

        ans=max(ans,f[i]-g[i+1]);

    cout<<ans<<endl;

    return 0;

}