using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC_D
{
    class D062
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToList();

            //境目がk=N,N+1,...,2N
            long[] sumH = new long[N+1];
            long[] sumT = new long[N+1];
            PriorityQueue<int> headQueue = new PriorityQueue<int>();
            PriorityQueue<int> tailQueue = new PriorityQueue<int>();

            long sh = 0, st = 0;
            for (int i = 0; i < N; i++)
            {
                sh += a[i]; st += a[i + 2 * N];
                headQueue.Enqueue(a[i], -a[i]); //小さい順
                tailQueue.Enqueue(a[i + 2 * N], a[i + 2 * N]); //大きい順                
            }

            sumH[0] = sh; sumT[N] = st;
            for (int i = 0; i < N; i++)
            {
                int nextH = a[N + i];
                headQueue.Enqueue(nextH, -nextH);
                int throwH = headQueue.Dequeue();
                sh += nextH - throwH;
                sumH[i + 1] = sh;

                int nextT = a[2 * N - i - 1];
                tailQueue.Enqueue(nextT, nextT);
                int throwT = tailQueue.Dequeue();
                st += nextT - throwT;
                sumT[N - i - 1] = st;
            }

            long difMax = long.MinValue;
            for(int i = 0; i <= N; i++)
            {
                long dif = sumH[i] - sumT[i];
                if (dif > difMax) difMax = dif;
            }
            Console.WriteLine(difMax);
        }
    }

    //優先度付きキュー（実装はヒープ)
    class PriorityQueue<T>
    {
        private List<HeapNode> heap = new List<HeapNode>();

        public int Count
        {
            get
            {
                return heap.Count;
            }
        }

        public void Enqueue(T item, double priority)
        {
            HeapNode node = new HeapNode(item, priority);
            heap.Add(node);

            int index = heap.Count - 1;

            while (index > 0)
            {
                int indexParent = (index - 1) / 2;
                HeapNode parent = heap[indexParent];
                if (priority > parent.Priority)
                {
                    Swap(index, indexParent);
                    index = indexParent;
                }
                else
                {
                    break;
                }
            }
        }

        public T Dequeue()
        {
            if (heap.Count == 0)
            {
                throw new Exception("No item in priorityQueue");
            }

            T item = heap[0].Node;
            heap[0] = heap[heap.Count - 1];
            heap.RemoveAt(heap.Count - 1);
            if (heap.Count > 0)
            {
                HeapNode node = heap[0];
                int index = 0;
                while (true)
                {
                    int indexL = 2 * index + 1;
                    int indexR = 2 * index + 2;
                    if (indexL >= heap.Count) //子なし(Leaf)
                    {
                        break;
                    }
                    else //子が存在
                    {
                        HeapNode childBetter = heap[indexL];
                        int indexBetter = indexL;
                        if (indexR < heap.Count && heap[indexL].Priority < heap[indexR].Priority)
                        {
                            childBetter = heap[indexR];
                            indexBetter = indexR;
                        }

                        if (node.Priority < childBetter.Priority)
                        {
                            Swap(index, indexBetter);
                            //node = childBetter; 参照なのでスワップで自動的に子を参照してる
                            index = indexBetter;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            return item;
        }

        public T Peek()
        {
            if (heap.Count == 0)
            {
                throw new Exception("No item in priorityQueue");
            }
            return heap[0].Node;
        }

        private void Swap(int i, int j)
        {
            HeapNode hn = heap[i];
            heap[i] = heap[j];
            heap[j] = hn;
        }


        class HeapNode
        {
            public T Node { get; }
            public double Priority { get; }
            public HeapNode(T item, double priority)
            {
                Node = item;
                Priority = priority;
            }
        }

    }

}


Measured memory_bytes: 52100