from itertools import accumulate n = int(input()) r = list(map(int, input().split())) g = list(map(int, input().split())) b = list(map(int, input().split())) rr = [0] * 3001 for i in r: rr[i] += 1 gg = [0] * 3001 for i in g: gg[i] += 1 bb = [0] * 3001 for i in b: bb[i] += 1 a = list(accumulate(rr)) result = 0 for i in range(1, 3001): x = gg[i] if x == 0: continue for j in range(1, 3001): y = bb[j] if y == 0: continue result += (a[min(i + j - 1, 3000)] - a[max(i, j) - 1]) * (x * y) print(result)