#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"from heapq import heappush, heappop\n"
"n=int(input())\n"
"a=list(map(int,input().split()))\n"
"l=[]\n"
"for v in a[:n]:\n"
"  heappush(l,v)\n"
"suml=[sum(a[:n])]\n"
"for i in range(n):\n"
"  suml.append(suml[i]+a[n+i])\n"
"  heappush(l,a[n+i])\n"
"  suml[i+1]-=heappop(l)\n"
"r=[]\n"
"for v in a[2*n:]:\n"
"  heappush(r,(10**10-v,v))\n"
"sumr=[sum(a[2*n:])]\n"
"for i in range(n):\n"
"  sumr.append(sumr[i]+a[2*n-i-1])\n"
"  heappush(r,(10**10-a[2*n-i-1],a[2*n-i-1]))\n"
"  _,t=heappop(r)\n"
"  sumr[i+1]-=t\n"
"ans=-10**20\n"
"for i in range(n+1):\n"
"  ans=max(ans,suml[i]-sumr[n-i])\n"
"print(ans)\n"
"\"";
  system(s);
  return 0;
}            