import heapq



def calc(front_sum, back_sum):

    heapq.heapify(a_front)

    heapq.heapify(a_back)

    front_sums = [front_sum]

    back_sums = [back_sum]

    for i in range(n):

        front_sum += a_center[i] - heapq.heappushpop(a_front, a_center[i])

        front_sums += [front_sum]

        back_sum += a_center[-i - 1] + heapq.heappushpop(a_back, -a_center[-i - 1])

        back_sums += [back_sum]

    return max([front_sums[i] - back_sums[-i-1] for i in range(n+1)])







if __name__ == "__main__":

    n = int(eval(input()))

    a = [int(i) for i in input().split()]

    k = 0

    a_front = []

    a_center = []

    a_back = []

    front_sum = 0

    back_sum = 0



    for i in a:

        k += 1

        if k <= n:

            a_front += [i]

            front_sum += i

        elif k <= 2 * n:

            a_center += [i]

        else:

            a_back += [-i]

            back_sum += i



    print((calc(front_sum, back_sum)))



import heapq



def calc(front_sum, back_sum):

    heapq.heapify(a_front)

    heapq.heapify(a_back)

    front_sums = [front_sum]

    back_sums = [back_sum]

    for i in a_center:

        front_sum += i - heapq.heappushpop(a_front, i)

        front_sums += [front_sum]

    a_center.reverse()

    for i in a_center:

        back_sum += i + heapq.heappushpop(a_back, -i)

        back_sums += [back_sum]

    return max([front_sums[i] - back_sums[-i-1] for i in range(n+1)])







if __name__ == "__main__":

    n = int(eval(input()))

    a = [int(i) for i in input().split()]

    k = 0

    a_front = []

    a_center = []

    a_back = []

    front_sum = 0

    back_sum = 0



    for i in a:

        k += 1

        if k <= n:

            a_front += [i]

            front_sum += i

        elif k <= 2 * n:

            a_center += [i]

        else:

            a_back += [-i]

            back_sum += i



    print((calc(front_sum, back_sum)))



import heapq


def calc(front_sum, back_sum):
    heapq.heapify(a_front)
    heapq.heapify(a_back)
    front_sums = [front_sum]
    back_sums = [back_sum]
    for i in range(n):
        front_sum += a_center[i] - heapq.heappushpop(a_front, a_center[i])
        front_sums += [front_sum]
        back_sum += a_center[-i - 1] + heapq.heappushpop(a_back, -a_center[-i - 1])
        back_sums += [back_sum]
    return max([front_sums[i] - back_sums[-i - 1] for i in range(n + 1)])


if __name__ == "__main__":
    n = int(eval(input()))
    a = [int(i) for i in input().split()]
    k = 0
    a_front = []
    a_center = []
    a_back = []
    front_sum = 0
    back_sum = 0
    for i in a:
        k += 1
        if k <= n:
            a_front += [i]
            front_sum += i
        elif k <= 2 * n:
            a_center += [i]
        else:
            a_back += [-i]
            back_sum += i
    print((calc(front_sum, back_sum)))

import heapq


def calc(front_sum, back_sum):
    heapq.heapify(a_front)
    heapq.heapify(a_back)
    front_sums = [front_sum]
    back_sums = [back_sum]
    for i in a_center:
        front_sum += i - heapq.heappushpop(a_front, i)
        front_sums += [front_sum]
    a_center.reverse()
    for i in a_center:
        back_sum += i + heapq.heappushpop(a_back, -i)
        back_sums += [back_sum]
    return max([front_sums[i] - back_sums[-i - 1] for i in range(n + 1)])


if __name__ == "__main__":
    n = int(eval(input()))
    a = [int(i) for i in input().split()]
    k = 0
    a_front = []
    a_center = []
    a_back = []
    front_sum = 0
    back_sum = 0
    for i in a:
        k += 1
        if k <= n:
            a_front += [i]
            front_sum += i
        elif k <= 2 * n:
            a_center += [i]
        else:
            a_back += [-i]
            back_sum += i
    print((calc(front_sum, back_sum)))

-    for i in range(n): -        front_sum += a_center[i] - heapq.heappushpop(a_front, a_center[i]) +    for i in a_center: +        front_sum += i - heapq.heappushpop(a_front, i) -        back_sum += a_center[-i - 1] + heapq.heappushpop(a_back, -a_center[-i - 1]) +    a_center.reverse() +    for i in a_center: +        back_sum += i + heapq.heappushpop(a_back, -i)