import Control.Arrow
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.IntSet as IS
main=print.solve.unfoldr(B.readInt.B.dropWhile isSpace)=<<B.getContents
solve(n:as)=maximum$zipWith(-)bs$reverse cs where
  (a1s,(a2s,a3s))=second(splitAt n).splitAt n$as
  bs=f IS.deleteFindMin max a1s a2s
  cs=f IS.deleteFindMax min a3s$reverse a2s
f f1 f2 as bs=(s:).snd.mapAccumL(g f1 f2)(s,IS.fromList as)$bs where s=sum as
g f1 f2(s,q)a=((t,IS.insert c p),t)where
  (b,p)=f1$q
  c=f2 a b
  t=s-b+c