N = int(input()) A = sorted(list(map(int,input().split()))) B = sorted(list(map(int,input().split()))) C = sorted(list(map(int,input().split()))) Amax = A[-1] CC = [0] * (Amax+1) j = 0 temp = 0 for c in C: if c > Amax: break while j < c: j += 1 CC[j] = CC[j-1] temp += 1 CC[j] = temp while j < Amax: j += 1 CC[j] = CC[j-1] ans = 0 for a in A: for b in B: if b > a: break ans += CC[a] - CC[a - b] #print(a,b,CC[a],CC[a-b+1],CC[a] - CC[a - b]) print(ans)