#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 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() { sm=T(); s.clear(); }
	void insert(const T &x){ sm+=x; it=s.insert(x); }
	template <class It> void insert(It b, It e){ sm=accumulate(b,e,sm); s.insert(b, e); }
	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){ std::swap(sm,b.sm); s.swap(b.s); }
	ll count(const T &x) const { return (ll)s.count(x); }
	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 << "\nsm=" << sm << "\n";
	}
#endif
};

template<class T> struct MULTISETS{
	vector<MULTISET<T>> v;
	vll mxsz;//v[i]の最大size,先頭か末尾が-1 先頭-1→末尾詰め、末尾-1→先頭詰め
	MULTISETS(){}
	MULTISETS(const vll &mxsz_){ init(mxsz_); }
	void init(const vll &mxsz_){ mxsz=mxsz_; v.resize(mxsz.size()); }
	ll size() const { return (ll)v.size(); }//MULTISETの数
	bool empty() const { bool a=true; each(e,v) a=a&&e.empty(); return a; }
	ll elemnum() const { ll a=0; each(e,v) a+=e.size();  return a; }//全MULTISET内要素数
	void insert(const T &x,vll &mxsz_){ mxsz=mxsz_; insert(x); }
	void insert(const T &x){ //xを順序が崩れない位置に挿入
		if (empty()){
			if (mxsz[0]!=-1) v.front().insert(x); else v.back().insert(x);
			return;
		}
		rep(i,0,size()-1){
			if (v[i].empty()) continue;
			bool l = (i==0        || v[i-1].empty() || v[i-1].back()<=x);
			bool r = (i==size()-1 || v[i+1].empty() || x<=v[i+1].front());
			if (l && r) { v[i].insert(x); break; }
		}
		resize();
	}
	void erase(const T &x){//要件:xは必ず存在すること
		rep(i,0,size()-1){
			if (!v[i].empty() && x<=v[i].back()) { v[i].erase1(x); break; }
		}
		resize();
	}
	void resize(){ if (mxsz[0]==-1) resizeR(); else resizeL(); }
	void resizeL(){
		rep(i,0,size()-2){
			ll d=v[i].size()-mxsz[i];
			if (d>0){
				rep(k,0,d-1) v[i].push_out(v[i+1]);
			}
			else{
				for (ll k=0; !v[i+1].empty() && k<-d; k++) v[i].pull_in(v[i+1]);
			}
		}
	}
	void resizeR(){
		dep(i,size()-1,1){
			ll d=v[i].size()-mxsz[i];
			if (d>0){
				rep(k,0,d-1) v[i-1].pull_in(v[i]);
			}
			else{
				for (ll k=0; !v[i-1].empty() && k<-d; k++) v[i-1].push_out(v[i]);
			}
		}
	}
	MULTISET<T> &operator[](ll i) { return v[i]; }
};


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;
	MULTISETS<ll> rgs({n,-1});
	lf.insert(a.begin(),a.begin()+n);
	rep(i,n,3*n-1){
		rgs.insert(a[i]);
	}

	ll ans=-INF;
	rep(i,n,2*n){
		chmax(ans,lf.sm-rgs[0].sm);

		if (i==2*n)break;

		ll v=a[i];
		lf.insert(v);
		lf.pop_front();

		rgs.erase(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: 19564