import sys from itertools import accumulate sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) n = I() R = LI() G = LI() B = LI() count_R = [0]*(3*10**3+1) count_G = [0]*(3*10**3+1) count_B = [0]*(3*10**3+1) for r in R: count_R[r] += 1 for g in G: count_G[g] += 1 for b in B: count_B[b] += 1 S_count_B = list(accumulate(count_B)) ans = 0 for i in range(1,3*10**3+1): cr = count_R[i] if not cr: continue for j in range(1,i+1): cg = count_G[j] if not cg: continue ans += cr*cg*(S_count_B[i]-S_count_B[i-j]) print(ans)