using System;
using System.Collections.Generic;
using System.Linq;

namespace AtTest.D_Challenge
{
    class ABC_062
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            long[] array = ReadLongs();
            var headSums = new long[n+1];
            headSums[0] = 0;
            var sDictH = new PriorityQueueNum();
            for(int i = 0; i < n; i++)
            {
                headSums[0] += array[i];
                sDictH.Add(array[i], i);
            }
            for(int i = 1; i <= n; i++)
            {
                headSums[i] = headSums[i - 1] + array[n + i - 1];
                sDictH.Add(array[n + i - 1],i+n);
                KeyValuePair<long, long> pair = sDictH.Dequeue();
                headSums[i] -= pair.Key;
            }
            var tailSums = new long[n + 1];
            tailSums[0] = 0;
            var sDictT = new PriorityQueueNum(true);
            for (int i = 0; i < n; i++)
            {
                tailSums[0] += array[3 * n - i - 1];
                sDictT.Add(array[3 * n - i - 1], i);
            }
            //Console.WriteLine(tailSums[0]);
            for (int i = 1; i <= n; i++)
            {
                tailSums[i] = tailSums[i - 1] + array[2 * n - i];
                sDictT.Add(array[2 * n - i], i + n);
                KeyValuePair<long, long> pair = sDictT.Dequeue();
                tailSums[i] -= pair.Key;
                //Console.WriteLine(pair.Key + " " + tailSums[i]);
            }

            long res = long.MinValue;
            for(int i = 0; i <= n; i++)
            {
                res = Math.Max(res, headSums[i] - tailSums[n - i]);
            }
            Console.WriteLine(res);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles()
        {
            return Array.ConvertAll(Read().Split(), double.Parse);
        }

        public class PriorityQueueNum
        {
            SortedDictionary<long, Queue<long>> dict
                = new SortedDictionary<long, Queue<long>>();

            public int Count { get; private set; } = 0;
            bool reverse = false;

            public PriorityQueueNum(bool reverse = false)
            {
                this.reverse = reverse;
            }

            public void Add(long key, long value)
            {
                if (reverse) key = -key;
                if (!dict.ContainsKey(key))
                {
                    dict[key] = new Queue<long>();
                }
                dict[key].Enqueue(value);
                Count++;
            }

            public KeyValuePair<long, long> Dequeue()
            {
                KeyValuePair<long, Queue<long>> queue = dict.First();
                if (queue.Value.Count <= 1)
                {
                    dict.Remove(queue.Key);
                }
                Count--;
                long key = queue.Key;
                if (reverse) key = -key;
                return new KeyValuePair<long, long>(
                    key, queue.Value.Dequeue());
            }
        }
    }
}


Measured memory_bytes: 67976