from bisect import bisect_left, bisect_right 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())) rs = Counter(R) gs = Counter(G) B.sort() ans = 0 for r in rs: for g in range(1, r+1): if gs[g] == 0: continue lo = bisect_left(B, r - g + 1) hi = bisect_right(B, r) ans += (hi - lo) * rs[r] * gs[g] print(ans)