package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

func sm(k PriorityQueue) int {
	sm := 0
	for i := 0; i < len(k); i++ {
		sm += k[i].value
	}
	return sm
}
func main() {

	sc := NewScanner()
	N := sc.NextInt()
	a := sc.NextIntArray()

	pq1 := make(PriorityQueue, 0)
	pq2 := make(PriorityQueue, 0)

	heap.Init(&pq1)
	heap.Init(&pq2)

	for i := 0; i < N; i++ {
		item := &Item{value: a[i], priority: -a[i]}
		heap.Push(&pq1, item)
	}

	Q := make([]int, N+1)

	A := sm(pq1)
	B := 0
	for i := 2 * N; i < 3*N; i++ {
		item := &Item{value: a[i], priority: a[i]}
		heap.Push(&pq2, item)
		B += a[i]
	}
	Q[0] += A
	Q[N] -= B

	for k := N; k < 2*N; k++ {
		A += a[k]
		heap.Push(&pq1, &Item{value: a[k], priority: -a[k]})

		item := heap.Pop(&pq1)
		A -= item.(*Item).value

		B += a[3*N-k-1]
		heap.Push(&pq2, &Item{value: a[3*N-k-1], priority: a[3*N-k-1]})
		item2 := heap.Pop(&pq2)

		B -= item2.(*Item).value
		Q[k-N+1] += A
		Q[2*N-k-1] -= B

	}

	Amax := Q[0]
	for i := 0; i <= N; i++ {
		if Amax < Q[i] {
			Amax = Q[i]
		}
	}

	fmt.Println(Amax)
}

// https://golang.org/pkg/container/heap/

// An Item is something we manage in a priority queue.
type Item struct {
	value    int // The value of the item; arbitrary.
	priority int // The priority of the item in the queue.
	// The index is needed by update and is maintained by the heap.Interface methods.
	index int // The index of the item in the heap.
}

// A PriorityQueue implements heap.Interface and holds Items.
type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	// We want Pop to give us the highest, not lowest, priority so we use greater than here.
	return pq[i].priority > pq[j].priority
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *PriorityQueue) Push(value interface{}) {
	n := len(*pq)
	item := value.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

// update modifies the priority and value of an Item in the queue.
func (pq *PriorityQueue) update(item *Item, value int, priority int) {
	item.value = value
	item.priority = priority
	heap.Fix(pq, item.index)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 24960