from collections import defaultdict from bisect import bisect_right, bisect_left N = int(input()) R = list(map(int, input().split())) G = list(map(int, input().split())) B = list(map(int, input().split())) B.sort() rdd = defaultdict(int) gdd = defaultdict(int) for i in range(N): rdd[R[i]] += 1 gdd[G[i]] += 1 #print(rdd, gdd) ans = 0 for r, rv in rdd.items(): for g, gv in gdd.items(): #print(r, rv, g, gv) if r < g: continue add = rv*gv*(bisect_right(B, r) - bisect_right(B, r-g)) # print(add) ans += max(0, add) print(ans)