from heapq import heapify, heappushpop



N, *A = list(map(int, open(0).read().split()))



L, C, R = A[:N], A[N:2 * N], A[2 * N:]



heapify(L)

red = [sum(L)]

for c in C:

    red.append(red[-1] + c - heappushpop(L, c))



R = [-r for r in R]

heapify(R)

blue = [sum(R)]

for c in reversed(C):

    blue.append(blue[-1] - c - heappushpop(R, -c))



print((max(r + b for r, b in zip(red, reversed(blue)))))

from heapq import heapify, heappushpop

from itertools import accumulate



N, *A = list(map(int, open(0).read().split()))



L, C, R = A[:N], A[N:2 * N], A[2 * N:]



heapify(L)

F = accumulate([sum(L)] + [c - heappushpop(L, c) for c in C])



R = [-r for r in R]

heapify(R)

B = reversed(list(accumulate([sum(R)] + [- c - heappushpop(R, -c) for c in reversed(C)])))



print((max(f + b for f, b in zip(F, B))))
from heapq import heapify, heappushpop

N, *A = list(map(int, open(0).read().split()))
L, C, R = A[:N], A[N : 2 * N], A[2 * N :]
heapify(L)
red = [sum(L)]
for c in C:
    red.append(red[-1] + c - heappushpop(L, c))
R = [-r for r in R]
heapify(R)
blue = [sum(R)]
for c in reversed(C):
    blue.append(blue[-1] - c - heappushpop(R, -c))
print((max(r + b for r, b in zip(red, reversed(blue)))))

from heapq import heapify, heappushpop
from itertools import accumulate

N, *A = list(map(int, open(0).read().split()))
L, C, R = A[:N], A[N : 2 * N], A[2 * N :]
heapify(L)
F = accumulate([sum(L)] + [c - heappushpop(L, c) for c in C])
R = [-r for r in R]
heapify(R)
B = reversed(
    list(accumulate([sum(R)] + [-c - heappushpop(R, -c) for c in reversed(C)]))
)
print((max(f + b for f, b in zip(F, B))))

+from itertools import accumulate -red = [sum(L)] -for c in C: -    red.append(red[-1] + c - heappushpop(L, c)) +F = accumulate([sum(L)] + [c - heappushpop(L, c) for c in C]) -blue = [sum(R)] -for c in reversed(C): -    blue.append(blue[-1] - c - heappushpop(R, -c)) -print((max(r + b for r, b in zip(red, reversed(blue))))) +B = reversed( +    list(accumulate([sum(R)] + [-c - heappushpop(R, -c) for c in reversed(C)])) +) +print((max(f + b for f, b in zip(F, B))))