local PairingHeap={}

PairingHeap.meld=function(self,a,b)
    if not a then
        return b
    elseif not b then
        return a
    elseif a[1]<b[1] then
        b[4]=a[3]
        a[3]=b
        return a
    else
        a[4]=b[3]
        b[3]=a
        return b
    end
end

PairingHeap.pair=function(self,a)
    local b,c,d,e
    while a do
        c=false
        b=a
        a=a[4]
        b[4]=false
        if a then
            c=a
            a=a[4]   
            c[4]=false
        end
        b=self:meld(b,c)
        b[4]=d
        d=b
    end
    while d do
        e=d
        d=d[4]
        a=self:meld(a,e)
    end
    return a
end

PairingHeap.empty=function(self)
    return not self.root
end

PairingHeap.push=function(self,key,value)
    local root=self.root
    if root and root[1]<key then
        root[3]={
            key,
            value,
            false,
            root[3],
        }
    else
        self.root={
            key,
            value,
            root,
            false,
        }
    end
end

PairingHeap.pop=function(self)
    local root=self.root
    local value=root[2]
    self.root=self:pair(root[3])
    for i=1,4 do
        root[i]=false
    end
    table.insert(self,root)
    return value
end

PairingHeap.join=function(self,other)
    local a=self.root
    local b=other.root
    if a[1]<b[1]then
        b[4]=a[3]
        a[3]=b
    else
        a[4]=b[3]
        b[3]=a
        self.root=b
    end
    return self
end

PairingHeap.new=function(self)
    local obj={}
    setmetatable(obj,{__index=PairingHeap})
    return obj
end

----------

local n=io.read("n")
local a={}
for i=1,3*n do
    a[i]=io.read("n")
end

local lsum={[0]=0}
local minq=PairingHeap:new()
for i=1,n do
    local A=a[i]
    lsum[i]=lsum[i-1]+A
    minq:push(A,A)
end
for i=n+1,2*n do
    local P=minq:pop()
    local A=a[i]
    if A>P then
        lsum[i]=lsum[i-1]+A-P
        minq:push(A,A)
    else
        lsum[i]=lsum[i-1]
        minq:push(P,P)
    end
end

local rsum={[0]=0}
local maxq=PairingHeap:new()
for i=1,n do
    local A=a[3*n-i+1]
    rsum[i]=rsum[i-1]+A
    maxq:push(-A,A)
end
for i=n+1,2*n do
    local P=maxq:pop()
    local A=a[3*n-i+1]
    if A<P then
        rsum[i]=rsum[i-1]+A-P
        maxq:push(-A,A)
    else
        rsum[i]=rsum[i-1]
        maxq:push(-P,P)
    end
end
local max=math.mininteger
for i=n,2*n do
    max=math.max(max,lsum[i]-rsum[3*n-i])
end
print(max)