n=int(input()) L=3*10**3 l=list(map(int,input().split())) lc=[0]*(L+1) for v in l: lc[v]+=1 rc=lc l=list(map(int,input().split())) lc=[0]*(L+1) for v in l: lc[v]+=1 gc=lc l=list(map(int,input().split())) lc=[0]*(L+1) for v in l: lc[v]+=1 bc=lc for i in range(1,L+1): bc[i]+=bc[i-1] a=0 for i in range(1,L+1): for j in range(1,i+1): a+=rc[i]*gc[j]*(bc[i]-bc[i-j]) print(a)