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=l l=list(map(int,input().split())) lc=[0]*(L+1) for v in l: lc[v]+=1 gc=l l=list(map(int,input().split())) lc=[0]*(L+1) for v in l: lc[v]+=1 bc=l ll=[0]*(L*2+1) for i in range(L+1): for j in range(L+1): ll[i+j]+=gc[i]*bc[j] ll+=[0] for i in range(L*2+1): ll[i]+=ll[i-1] a=0 for i in range(L+1): a+=rc[i]*(ll[2*L]-ll[i]) print(a)