N = int(input()) r = list(map(int, input().split())) g = list(map(int, input().split())) b = list(map(int, input().split())) M = 3005 R, G, B = [0] * M, [0] * M, [0] * M for ri in r: R[ri] += 1 for gi in g: G[gi] += 1 for bi in b: B[bi] += 1 Ac = [0] * (M + 1) for i in range(M): Ac[i + 1] = Ac[i] + B[i] ans = 0 for i in range(M-1): for j in range(i + 1): ind = max(0, i - j) ans += R[i] * G[j] * (Ac[i + 1] - Ac[ind + 1]) # if R[i] * G[j]: # print(i, j, R[i] * G[j] * (Ac[i+1] - Ac[ind + 1])) print(ans) # print(R, G, B, Ac)