local mfl, mce, mmi, mma = math.floor, math.ceil, math.min, math.max
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    for j = 1, self.cnt[i] do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, ary, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.cnt, self.stage, self.size = {1}, {{}}, {}
  while mul < #ary do
    mul, stagenum = mul * 2, stagenum + 1
    self.cnt[stagenum], self.stage[stagenum] = mul, {}
  end
  for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end
  self.stagenum = stagenum
  for i = 1, #ary do self.stage[stagenum][i] = ary[i] end
  for i = #ary + 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.addValue = function(self, idx, val)
  self.stage[self.stagenum][idx] = self.stage[self.stagenum][idx] + val
  for i = self.stagenum - 1, 1, -1 do
    local dst = mce(idx / 2)
    local rem = dst * 4 - 1 - idx
    self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
    idx = dst
  end
end
SegTree.new = function(ary, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(ary, func, emptyvalue)
  return obj
end

SegTree.takeLeft = function(self)
  local ret, retpos = self.emptyvalue, 0
  local t1, t2, t3 = {1}, {1}, {self.size[1]}
  while 0 < #t1 do
    local stage, l, r = t1[#t1], t2[#t1], t3[#t1]
    table.remove(t1) table.remove(t2) table.remove(t3)
    local sz = self.size[stage]
    if sz <= r + 1 - l then
      local tmp = self.func(ret, self.stage[stage][mce(l / sz)])
      if tmp < 1 then
        ret, retpos = tmp, l + sz - 1
        if sz ~= 1 then table.insert(t1, stage + 1) table.insert(t2, l + sz) table.insert(t3, r) end
      else
        if sz ~= 1 then table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, l + sz - 2) end
      end
    else
      table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)
    end
  end
  retpos = retpos + 1
  self:addValue(retpos, -1)
  return retpos
end

local n = io.read("*n", "*l")
local a = {}
local str = io.read()
for v in str:gmatch("%d+") do
  table.insert(a, tonumber(v))
end
local value_list, value_to_idx = {}, {}
for i = 1, n * 2 do
  if not value_to_idx[a[i]] then
    value_to_idx[a[i]] = true
    table.insert(value_list, a[i])
  end
end
table.sort(value_list)
value_to_idx = {}
for i = 1, #value_list do value_to_idx[value_list[i]] = i end
local st = nil
local leftsum = 0
do
  local stary = {}
  for i = 1, #value_list do stary[i] = 0 end
  for i = 1, n do
    stary[value_to_idx[a[i]]] = stary[value_to_idx[a[i]]] + 1
    leftsum = leftsum + a[i]
  end
  st = SegTree.new(stary, function(a,b)return a+b end, 0)
end
leftsum = {leftsum}
for i = 1, n do
  st:addValue(value_to_idx[a[n + i]], 1)
  local pos = st:takeLeft()
  leftsum[i + 1] = leftsum[i] + a[n + i] - value_list[pos]
end
-- r
value_list, value_to_idx = {}, {}
for i = n + 1, n * 3 do
  if not value_to_idx[-a[i]] then
    value_to_idx[-a[i]] = true
    table.insert(value_list, -a[i])
  end
end
table.sort(value_list)
value_to_idx = {}
for i = 1, #value_list do value_to_idx[value_list[i]] = i end
local st = nil
local rightsum = 0
do
  local stary = {}
  for i = 1, #value_list do stary[i] = 0 end
  for i = 2 * n + 1, n * 3 do
    stary[value_to_idx[-a[i]]] = stary[value_to_idx[-a[i]]] + 1
    rightsum = rightsum - a[i]
  end
  st = SegTree.new(stary, function(a,b)return a+b end, 0)
end
rightsum = {rightsum}
for i = n, 1, -1 do
  st:addValue(value_to_idx[-a[n + i]], 1)
  local pos = st:takeLeft()
  rightsum[n + 2 - i] = rightsum[n + 1 - i] - a[n + i] - value_list[pos]
end
local ret = leftsum[1] + rightsum[n + 1]
for i = 2, n + 1 do
  ret = mma(ret, leftsum[i] + rightsum[n + 2 - i])
end
print(ret)
