from bisect import bisect_left

from collections import defaultdict



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())))

num_a = 0

num_c = 0

res = 0

pre_b = -1



dict_C = defaultdict(int)





for b in B:

    if b == pre_b:

        res += num_a * num_c

        continue

    num_a = bisect_left(A, b) # a < b となるAの要素数

    pre_num_c = bisect_left(C, b)

    num_c = N - pre_num_c # c > b となるAの要素数

    if pre_num_c != N and C[pre_num_c] == b:

        num_c = N - bisect_left(C, b+1)

    res += num_a * num_c

    pre_b = b

print(res)



from bisect import bisect_left

from bisect import bisect_right



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())))

num_a = 0

num_c = 0

res = 0

pre_b = -1





for b in B:

    if b == pre_b:

        res += num_a * num_c

        continue

    num_a = bisect_left(A, b) # a < b となるAの要素数

    pre_num_c = bisect_right(C, b)

    num_c = N - pre_num_c # c > b となるAの要素数

    res += num_a * num_c

    pre_b = b

print(res)



from bisect import bisect_left
from collections import defaultdict

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())))
num_a = 0
num_c = 0
res = 0
pre_b = -1
dict_C = defaultdict(int)
for b in B:
    if b == pre_b:
        res += num_a * num_c
        continue
    num_a = bisect_left(A, b)  # a < b となるAの要素数
    pre_num_c = bisect_left(C, b)
    num_c = N - pre_num_c  # c > b となるAの要素数
    if pre_num_c != N and C[pre_num_c] == b:
        num_c = N - bisect_left(C, b + 1)
    res += num_a * num_c
    pre_b = b
print(res)

from bisect import bisect_left
from bisect import bisect_right

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())))
num_a = 0
num_c = 0
res = 0
pre_b = -1
for b in B:
    if b == pre_b:
        res += num_a * num_c
        continue
    num_a = bisect_left(A, b)  # a < b となるAの要素数
    pre_num_c = bisect_right(C, b)
    num_c = N - pre_num_c  # c > b となるAの要素数
    res += num_a * num_c
    pre_b = b
print(res)

-from collections import defaultdict +from bisect import bisect_right -dict_C = defaultdict(int) -    pre_num_c = bisect_left(C, b) +    pre_num_c = bisect_right(C, b) -    if pre_num_c != N and C[pre_num_c] == b: -        num_c = N - bisect_left(C, b + 1)