from collections import Counter N=int(input()) R=list(map(int,input().split())) G=list(map(int,input().split())) B=list(map(int,input().split())) le=max(max(G)+max(B),max(R))+1 cnt=[0]*le for r in R: cnt[r]+=1 cnt=[0]+cnt for r in range(1,le+1): cnt[r]+=cnt[r-1] ans=0 CG=Counter(G) CB=Counter(B) for g,cg in CG.items(): for b,cb in CB.items(): ans+=(cnt[g+b]-cnt[max(g,b)])*cg*cb print(ans)