import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from collections import defaultdict from itertools import accumulate def main(): n = int(input()) R = list(map(int, input().split())) G = list(map(int, input().split())) B = list(map(int, input().split())) GC = defaultdict(lambda: 0) BC = defaultdict(lambda: 0) N = 3*10**3 RC = [0]*(N+1) for g in G: GC[g] += 1 for b in B: BC[b] += 1 for r in R: RC[r] += 1 RC = list(accumulate(RC)) ans = 0 for g, gc in GC.items(): for b, bc in BC.items(): x = min(N+1, max(g, b)) y = min(N+1, g+b) cnt = RC[y-1]-RC[x-1] ans += max(0, cnt)*gc*bc print(ans) if __name__ == '__main__': main()