import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main() {
  int n = readln.chomp.to!int;
  long[] a = readln.chomp.split.map!(to!long).array;
  long left = 0;
  foreach (v; a[0..n]) {
    left += v;
  }
  long right = 0;
  foreach (v; a[2*n..$]) {
    right += v;
  }
  alias Node = Tuple!(long, "value", ulong, "index");
  alias MinRBT = RedBlackTree!(Node, (a, b) => a < b);
  alias MaxRBT = RedBlackTree!(Node, (a, b) => a > b);
  MinRBT minRBT = new MinRBT();
  foreach (i, v; a[0..n]) {
    minRBT.insert(Node(v, i));
  }
  MaxRBT maxRBT = new MaxRBT();
  foreach (i, v; a[2*n..$]) {
    maxRBT.insert(Node(v, i));
  }
  long ans = left - right;
  // stderr.writeln("init : ", ans, ", ", left, ", ", right);
  int leftIndex = n;
  int rightIndex = 2 * n - 1;
  foreach (i; 0..n) {
    Node minNode = minRBT.front;
    Node maxNode = maxRBT.front;
    // stderr.writeln(i);
    // stderr.writeln("\tmin : ", minNode);
    // stderr.writeln("\tmax : ", maxNode);
    long tryLeft = (left - minNode.value + a[leftIndex]) - right;
    long tryRight = left - (right - maxNode.value + a[rightIndex]);
    // stderr.writeln("\tleft : ", tryLeft, ", right : ", tryRight);
    if (tryLeft > tryRight) {
      // stderr.writeln("\t\tremove min : ", minNode);
      left -= minNode.value;
      left += a[leftIndex];
      ++leftIndex;
      minRBT.removeFront;
    } else {
      // stderr.writeln("\t\tremove max : ", maxNode);
      right -= maxNode.value;
      right += a[rightIndex];
      --rightIndex;
      maxRBT.removeFront;
    }
    ans = max(ans, left - right);
  }
  ans.writeln;
}
