from collections import Counter n = int(input()) r = list(map(int, input().split())) g = list(map(int, input().split())) b = list(map(int, input().split())) r = Counter(r) g = Counter(g) b = Counter(b) acc = [0]*(3*10**3+1) for i in range(1, 3*10**3+1): acc[i] += acc[i-1] + r[i] ans = 0 for gg, gr in g.items(): for bb, vb in b.items(): ans += gr*vb*(acc[min(3*10**3, gg+bb-1)] - acc[max(gg-1, bb-1)]) print(ans)