#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e18;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n;
  cin >> n;
  vector<int> a(3 * n);
  rep(i, 3 * n) cin >> a[i];
  int ans = -INF;
  map<int, int> f;
  int s_max = INF, First = 0, Second = 0;

  rep(i, n) f[a[i]]++, First += a[i];
  vector<int> res;
  loop(i, n, 3 * n) res.push_back(a[i]);
  sort(all(res));
  map<int, int> s, rem;
  rep(i, n) s[res[i]]++, Second += res[i];
  loop(i, n, 2 * n) rem[res[i]]++;
  cmax(ans, First - Second);
  // cout << "sum=" << First - Second << endl << endl;

  loop(i, n, 2 * n) {
    int change = a[i];
    // cout << "a[i]=" << a[i] << endl;
    //
    // for (auto x : f) rep(i, x.second) cout << x.first << ' ';
    // cout << endl << "First=" << First << endl;
    // for (auto x : s) rep(i, x.second) cout << x.first << ' ';
    // cout << endl << "Second=" << Second << endl;

    if ((*f.begin()).first < change) {
      First += change - (*f.begin()).first;
      f[(*f.begin()).first]--;
      if (f[(*f.begin()).first] == 0) f.erase((*f.begin()).first);
      f[change]++;

      // cout << "*f.begin() < change" << endl;
      // for (auto x : f) rep(i, x.second) cout << x.first << ' ';
      // cout << endl << "First=" << First << endl;
      // for (auto x : s) rep(i, x.second) cout << x.first << ' ';
      // cout << endl << "Second=" << Second << endl;
    }
    if (s.count(change)) {
      Second += (*rem.begin()).first - change;
      s[(*rem.begin()).first]++;
      s[change]--;
      if (s[change] == 0) s.erase(change);
      rem[(*rem.begin()).first]--;
      if (rem[(*rem.begin()).first] == 0) rem.erase((*rem.begin()).first);

      // cout << "s.count(change)" << endl;
      // for (auto x : f) rep(i, x.second) cout << x.first << ' ';
      // cout << endl << "First=" << First << endl;
      // for (auto x : s) rep(i, x.second) cout << x.first << ' ';
      // cout << endl << "Second=" << Second << endl;

    } else {
      rem[change]--;
      if (rem[change] == 0) rem.erase(change);

      // cout << "else" << endl;
      // for (auto x : f) rep(i, x.second) cout << x.first << ' ';
      // cout << endl << "First=" << First << endl;
      // for (auto x : s) rep(i, x.second) cout << x.first << ' ';
      // cout << endl << "Second=" << Second << endl;
    }

    // cout << "last status" << endl;
    // for (auto x : f) rep(i, x.second) cout << x.first << ' ';
    // cout << endl << "First=" << First << endl;
    // for (auto x : s) rep(i, x.second) cout << x.first << ' ';
    // cout << endl << "Second=" << Second << endl;

    cmax(ans, First - Second);
    // cout << "sum=" << First - Second << endl << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 22900