import sys

import itertools

sys.setrecursionlimit(1000000000)

from heapq import heapify,heappop,heappush,heappushpop

import math

import collections

import copy

import bisect



n = int(eval(input()))

A = list(map(int,input().split()))

B = list(map(int,input().split()))

C = list(map(int,input().split()))

A.sort()

B.sort()

C.sort()

ans = 0

for b in B:

    a = bisect.bisect_left(A,b)

    c = n - bisect.bisect_left(C,b+1)

    ans += a*c

print(ans)
import sys

import itertools

sys.setrecursionlimit(1000000000)

from heapq import heapify,heappop,heappush,heappushpop

import math

import collections

import copy

import bisect

mod = 10**9+7



if __name__ == "__main__":

    n = int(eval(input()))

    A = sorted(list(map(int,input().split())))

    B = sorted(list(map(int,input().split())))

    C = sorted(list(map(int,input().split())))

    ans = 0

    for b in B:

        a = bisect.bisect_left(A,b)

        c = n - bisect.bisect_left(C,b+1)

        ans += a*c

    print(ans)
import sys
import itertools

sys.setrecursionlimit(1000000000)
from heapq import heapify, heappop, heappush, heappushpop
import math
import collections
import copy
import bisect

n = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    a = bisect.bisect_left(A, b)
    c = n - bisect.bisect_left(C, b + 1)
    ans += a * c
print(ans)

import sys
import itertools

sys.setrecursionlimit(1000000000)
from heapq import heapify, heappop, heappush, heappushpop
import math
import collections
import copy
import bisect

mod = 10**9 + 7
if __name__ == "__main__":
    n = int(eval(input()))
    A = sorted(list(map(int, input().split())))
    B = sorted(list(map(int, input().split())))
    C = sorted(list(map(int, input().split())))
    ans = 0
    for b in B:
        a = bisect.bisect_left(A, b)
        c = n - bisect.bisect_left(C, b + 1)
        ans += a * c
    print(ans)

-n = int(eval(input())) -A = list(map(int, input().split())) -B = list(map(int, input().split())) -C = list(map(int, input().split())) -A.sort() -B.sort() -C.sort() -ans = 0 -for b in B: -    a = bisect.bisect_left(A, b) -    c = n - bisect.bisect_left(C, b + 1) -    ans += a * c -print(ans) +mod = 10**9 + 7 +if __name__ == "__main__": +    n = int(eval(input())) +    A = sorted(list(map(int, input().split()))) +    B = sorted(list(map(int, input().split()))) +    C = sorted(list(map(int, input().split()))) +    ans = 0 +    for b in B: +        a = bisect.bisect_left(A, b) +        c = n - bisect.bisect_left(C, b + 1) +        ans += a * c +    print(ans)