#pragma GCC optimize("Ofast") #pragma GCC target("avx2") char*mmap(); #define rd(v) long v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} #define wt(v) {long _z=v;do*--wp=_z%10+48;while(_z/=10);} #define rep(v,e) for(long v=0;v=b?a:b) #define M 3001 long rh[M],gh[M],bh[M]; long d[M+M]; main(){ char*rp=mmap(0l,1l<<25,1,2,0,0ll); rd(n); rep(i,n){rd(r);rh[r]+=1;} rep(i,n){rd(g);gh[g]+=1;} rep(i,n){rd(b);bh[b]+=1;} rep(g,M){ rep(b,M){ long a=gh[g]*bh[b]; d[max(g,b)]+=a; d[g+b]-=a; } } long y=0,z=0; rep(r,M){ y+=d[r]; z+=y*rh[r]; } char wbuf[64],*wp=wbuf+sizeof wbuf; wt(z); write(1,wp,wbuf+sizeof wbuf-wp); _exit(0); }