import sys input = sys.stdin.readline from collections import Counter n=int(input()) R=Counter(map(int,input().split())) G=Counter(map(int,input().split())) B=Counter(map(int,input().split())) S=[0]*(7*10**3+5) for r in R: S[r]+=R[r] for i in range(1,3*10**3+5): S[i]+=S[i-1] ANS=0 for g in G: for b in B: ANS+=G[g]*B[b]*(S[g+b-1]-S[max(g,b)-1]) print(ANS)