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 PriorityQueue2<long, int>();
            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, int> pair = sDictH.Dequeue();
                headSums[i] -= pair.Key;
            }
            var tailSums = new long[n + 1];
            tailSums[0] = 0;
            var sDictT = new PriorityQueue2<long, int>();
            for (int i = 0; i < n; i++)
            {
                tailSums[0] += array[3 * n - i - 1];
                sDictT.Add(-array[3 * n - i - 1], i);
            }
            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, int> pair = sDictT.Dequeue();
                tailSums[i] += pair.Key;
            }

            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 PriorityQueue2<TKey, TValue>
        {
            SortedDictionary<TKey, Queue<TValue>> dict
                = new SortedDictionary<TKey, Queue<TValue>>();

            public int Count { get; private set; } = 0;

            public void Add(TKey key, TValue value)
            {
                if (!dict.ContainsKey(key))
                {
                    dict[key] = new Queue<TValue>();
                }

                dict[key].Enqueue(value);
                Count++;
            }

            public KeyValuePair<TKey, TValue> Dequeue(bool reverse = false)
            {
                KeyValuePair<TKey, Queue<TValue>> queue;
                if (reverse)
                {
                    queue = dict.Last();
                }
                else
                {
                    queue = dict.First();
                }
                if (queue.Value.Count <= 1)
                {
                    dict.Remove(queue.Key);
                }
                Count--;
                return new KeyValuePair<TKey, TValue>(
                    queue.Key, queue.Value.Dequeue());
            }
        }
    }
}


Measured memory_bytes: 62292