N = int(input()) R = list(map(int,input().split())) G = list(map(int,input().split())) B = list(map(int,input().split())) Cr = [0]*(3000+1) Cg = [0]*(3000+1) Cb = [0]*(3000+1) for i in range(N): Cr[R[i]] += 1 Cg[G[i]] += 1 Cb[B[i]] += 1 cumb = [0]*(3000+1) for i in range(1,3000+1): cumb[i] = cumb[i-1]+Cb[i] ans = 0 for r in range(1,3000+1): for g in range(1,r+1): ans += Cr[r]*Cg[g]*(cumb[r]-cumb[r-g]) print(ans)