#include "bits/stdc++.h"
using namespace std;
using     ll=long long;
using    vll=vector<   ll>;
using   vvll=vector<  vll>;
using  vvvll=vector< vvll>;
using vvvvll=vector<vvvll>;
constexpr ll INF = 1LL << 60;
struct Fast{ Fast(){ cin.tie(0); ios::sync_with_stdio(false); cout<<fixed<<setprecision(numeric_limits<double>::max_digits10); } } fast;
#define REPS(i, S, E) for (ll i = (S); i <= (E); i++)
#define REP(i, N) REPS(i, 0, (N)-1)
#define DEPS(i, S, E) for (ll i = (E); i >= (S); i--)
#define DEP(i, N) DEPS(i, 0, (N)-1)
#define rep(i, S, E)  for (ll i = (S); i <= (E); i++)
#define dep(i, E, S)  for (ll i = (E); i >= (S); i--)
#define each(e, v) for (auto&& e : v)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }
template<class T> inline T MaxE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmax(m,v[i]); return m; }
template<class T> inline T MinE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmin(m,v[i]); return m; }
template<class T> inline T MaxE(vector<T> &v) { return MaxE(v,0,(ll)v.size()-1); }
template<class T> inline T MinE(vector<T> &v) { return MinE(v,0,(ll)v.size()-1); }
template<class T> inline T Sum(vector<T> &v,ll S,ll E){ T s=T(); rep(i,S,E)s+=v[i]; return s; }
template<class T> inline T Sum(vector<T> &v) { return Sum(v,0,v.size()-1); }
template<class T> inline ll sz(T &v){ return (ll)v.size(); }
inline ll CEIL(ll a,ll b){ return (a<0) ? -(-a/b) : (a+b-1)/b; }
inline ll FLOOR(ll a,ll b){ return -CEIL(-a,b); }

//vector用テンプレート
template<class T> inline vector<T>& operator+=(vector<T> &a,const vector<T> &b){ for (ll i=0; i<(ll)a.size(); i++) a[i]+=b[i];  return a; }
template<class T> inline vector<T>& operator-=(vector<T> &a,const vector<T> &b){ for (ll i=0; i<(ll)a.size(); i++) a[i]-=b[i];  return a; }
template<class T> inline vector<T>& operator*=(vector<T> &a,const vector<T> &b){ for (ll i=0; i<(ll)a.size(); i++) a[i]*=b[i];  return a; }
template<class T> inline vector<T>& operator/=(vector<T> &a,const vector<T> &b){ for (ll i=0; i<(ll)a.size(); i++) a[i]/=b[i];  return a; }
template<class T> inline vector<T>& operator%=(vector<T> &a,const vector<T> &b){ for (ll i=0; i<(ll)a.size(); i++) a[i]%=b[i];  return a; }
template<class T,class S> inline vector<T>& operator+=(vector<T> &a,S b){ for (T &e: a) e+=b;  return a; }
template<class T,class S> inline vector<T>& operator-=(vector<T> &a,S b){ for (T &e: a) e-=b;  return a; }
template<class T,class S> inline vector<T>& operator*=(vector<T> &a,S b){ for (T &e: a) e*=b;  return a; }
template<class T,class S> inline vector<T>& operator/=(vector<T> &a,S b){ for (T &e: a) e/=b;  return a; }
template<class T,class S> inline vector<T>& operator%=(vector<T> &a,S b){ for (T &e: a) e%=b;  return a; }
template<class T,class S> inline vector<T> operator+(const vector<T> &a,S b){ vector<T> c=a; return c+=b; }
template<class T,class S> inline vector<T> operator-(const vector<T> &a,S b){ vector<T> c=a; return c-=b; }
template<class T,class S> inline vector<T> operator*(const vector<T> &a,S b){ vector<T> c=a; return c*=b; }
template<class T,class S> inline vector<T> operator/(const vector<T> &a,S b){ vector<T> c=a; return c/=b; }
template<class T,class S> inline vector<T> operator%(const vector<T> &a,S b){ vector<T> c=a; return c%=b; }
template<class T,class S> inline vector<T> operator-(S b,const vector<T> &a){ vector<T> c=-a; return c+=b; }
template<class T> inline vector<T> operator-(const vector<T> &a){ vector<T> c=a; return c*=(-1); }
template<class T> inline ostream &operator<<(ostream &os,const vector<T> &a){ for (ll i=0; i<(ll)a.size(); i++) os<<(i>0?" ":"")<<a[i];  return os; }

//pair用テンプレート
using   pll=pair<ll,ll>;
using  vpll=vector< pll>;
using vvpll=vector<vpll>;
template<class T,class S> inline pair<T,S>& operator+=(pair<T,S> &a,const pair<T,S> &b){ a.first+=b.first; a.second+=b.second; return a; }
template<class T,class S> inline pair<T,S>& operator-=(pair<T,S> &a,const pair<T,S> &b){ a.first-=b.first; a.second-=b.second; return a; }
template<class T,class S> inline pair<T,S>& operator*=(pair<T,S> &a,const pair<T,S> &b){ a.first*=b.first; a.second*=b.second; return a; }
template<class T,class S> inline pair<T,S>& operator/=(pair<T,S> &a,const pair<T,S> &b){ a.first/=b.first; a.second/=b.second; return a; }
template<class T,class S> inline pair<T,S>& operator%=(pair<T,S> &a,const pair<T,S> &b){ a.first%=b.first; a.second%=b.second; return a; }
template<class T,class S,class R> inline pair<T,S>& operator+=(pair<T,S> &a,R b){ a.first+=b; a.second+=b; return a; }
template<class T,class S,class R> inline pair<T,S>& operator-=(pair<T,S> &a,R b){ a.first-=b; a.second-=b; return a; }
template<class T,class S,class R> inline pair<T,S>& operator*=(pair<T,S> &a,R b){ a.first*=b; a.second*=b; return a; }
template<class T,class S,class R> inline pair<T,S>& operator/=(pair<T,S> &a,R b){ a.first/=b; a.second/=b; return a; }
template<class T,class S,class R> inline pair<T,S>& operator%=(pair<T,S> &a,R b){ a.first%=b; a.second%=b; return a; }
template<class T,class S,class R> inline pair<T,S> operator+(const pair<T,S> &a,R b){ pair<T,S> c=a; return c+=b; }
template<class T,class S,class R> inline pair<T,S> operator-(const pair<T,S> &a,R b){ pair<T,S> c=a; return c-=b; }
template<class T,class S,class R> inline pair<T,S> operator*(const pair<T,S> &a,R b){ pair<T,S> c=a; return c*=b; }
template<class T,class S,class R> inline pair<T,S> operator/(const pair<T,S> &a,R b){ pair<T,S> c=a; return c/=b; }
template<class T,class S,class R> inline pair<T,S> operator%(const pair<T,S> &a,R b){ pair<T,S> c=a; return c%=b; }
template<class T,class S,class R> inline pair<T,S> operator-(R b,const pair<T,S> &a){ pair<T,S> c=-a; return c+=b; }
template<class T,class S> inline pair<T,S> operator-(const pair<T,S> &a){ pair<T,S> c=a; return c*=(-1); }
template<class T,class S> inline ostream &operator<<(ostream &os,const pair<T,S> &a){ return os << a.first << ' ' << a.second; }

template<class T> struct SET{
	set<T> s;
	typename set<T>::iterator it;
	bool empty() const { return s.empty(); }
	ll size() const { return (ll)s.size(); }
	void clear() { return s.clear(); }
	bool insert(const T &x){ bool r; tie(it,r)=s.insert(x); return r; }
	template <class Iter> void insert(Iter b, Iter e){ s.insert(b, e); }
	void erase(const T &x){ s.erase(x); }
	void eraseit(){ s.erase(it); }//////////////////////動作確認する
	void swap(SET &b){ s.swap(b.s); }
	//bool contains(const T &x) { return s.find(x) != s.end(); }
	bool contains(const T &x){ find(x); return it != s.end(); }//////////////////////動作確認する
	void find(const T &x){ it=s.find(x); }
	T next() { return *(++it); }
	T prev() { return *(--it); }
	pair<T, bool> Next(){
		if (it!=s.end()) it++;
		if (it!=s.end()) return {*it,true};
		else return {T(),false};
	}
	pair<T, bool> Prev(){
		if (it!=s.begin()) return {*(--it), true};
		else return {T(),false};
	}
	T front() const{ return *s.begin(); }
	T back() const{ return *(--s.end()); }
	void pop_front(){ s.erase(s.begin()); }
	void pop_back(){ s.erase(--s.end()); }
	void push_front(const T &x){ it=s.insert(s.begin(), x); }
	void push_back(const T &x){ it=s.insert(s.end(), x); }
	void push_out(SET &b){ b.push_front(back()); pop_back(); }
	void pull_in(SET &b){ push_back(b.front()); b.pop_front(); }
#ifdef _DEBUG
	void dump(){
		each(e, s) cout << e << " ";
		cout << '\n';
	}
#endif
};

/////////////// smの動作確認する
template<class T> struct MULTISET{
	multiset<T> s;
	T sm=T();
	typename multiset<T>::iterator it;
	bool empty() const { return s.empty(); }
	ll size() const { return (ll)s.size(); }
	void clear() { s.clear(); sm=T(); }
	void insert(const T &x){ it=s.insert(x); sm+=x; }
	template <class It> void insert(It b, It e){ s.insert(b, e); sm=accumulate(b,e,sm); }
	void eraseall(const T &x){ sm-=x*s.erase(x); } //erase all of x
	void erase1(const T &x){ sm-=x; find(x); s.erase(it); } //erase one of x
	void eraseit() { sm-=*it; s.erase(it); }//////////////////////動作確認する
	void swap(MULTISET &b){ s.swap(b.s); std::swap(sm,b.sm); }
	ll count(const T &x) const { return (ll)s.count(x); }
	//bool contains(const T &x) const { return s.find(x) != s.end(); }
	bool contains(const T &x){ find(x); return it != s.end(); }
	void find(const T &x){ it=s.find(x); }
	T next() { return *(++it); }
	T prev() { return *(--it); }
	pair<T, bool> Next(){
		if (it!=s.end()) it++;
		if (it!=s.end()) return {*it,true};
		else return {T(),false};
	}
	pair<T, bool> Prev(){
		if (it!=s.begin()) return {*(--it), true};
		else return {T(),false};
	}
	T front() const{ return *s.begin(); }
	T back() const{ return *(--s.end()); }
	void pop_front(){ sm-=front(); s.erase(s.begin()); }
	void pop_back(){ sm-=back(); s.erase(--s.end()); }
	void push_front(const T &x){ sm+=x; it=s.insert(s.begin(),x); }
	void push_back(const T &x){ sm+=x; it=s.insert(s.end(),x); }
	void push_out(MULTISET &b){ b.push_front(back()); pop_back(); }
	void pull_in(MULTISET &b){ push_back(b.front()); b.pop_front(); }
#ifdef _DEBUG
	void dump(){
		each(e, s) cout << e << " ";
		cout << '\n';
	}
#endif
};

void solve()
{
	ll n;  cin >> n;
	vector<ll> a(3*n);  rep(i,0,3*n-1){ ll a_; cin>>a_; a[i]=a_; }

	MULTISET<ll> lf,rg,rg2;
	lf.insert(a.begin(),a.begin()+n);
	rep(i,n,3*n-1){
		rg.insert(a[i]);
		if (sz(rg)>=n+1){
			rg.push_out(rg2);
		}
	}

	ll ans=-INF;
	rep(i,n,2*n){
		chmax(ans,lf.sm-rg.sm);

		if (i==2*n)break;

		ll v=a[i];
		lf.insert(v);
		lf.pop_front();
		if (rg.contains(v)){
			rg.eraseit();
			rg.pull_in(rg2);
		}
		else{
			rg2.erase1(v);
		}
	}
	cout << ans << '\n';
}


int main(){
#if 1
	solve();
#else
	ll t;  cin >> t;
	rep(i, 0, t-1){
		solve();
	}
#endif
	return 0;
}


Measured memory_bytes: 19572