import itertools n = int(input()) R = list(map(int,input().split())) G = list(map(int,input().split())) B = list(map(int,input().split())) RL = [0]*(3*10**3+10) GL = [0]*(3*10**3+10) BL = [0]*(3*10**3+10) for r in R: RL[r]+=1 for g in G: GL[g]+=1 for b in B: BL[b]+=1 BLAC = list(itertools.accumulate(BL)) + [0] ans = 0 for i in range(1,3001): for j in range(1,i+1): l = i-j+1 r = i ans+=RL[i]*GL[j]*(BLAC[r]-BLAC[l-1]) print(ans)