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 for g,cg in Counter(G).items(): for b,cb in Counter(B).items(): ans+=(cnt[g+b]-cnt[max(g,b)])*cg*cb print(ans)