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:

    na = bisect.bisect_left(A, b)

    nb = N - bisect.bisect_right(C, b)

    ans += na * nb



print(ans)

import bisect

import sys



sys.setrecursionlimit(10 ** 6)

INF = float("inf")

MOD = 10 ** 9 + 7





def input():

    return sys.stdin.readline().strip()





def main():

    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:

        upper = bisect.bisect_left(A, b)

        bottom = N - bisect.bisect_right(C, b)

        ans += upper * bottom



    print(ans)





if __name__ == "__main__":

    main()

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:
    na = bisect.bisect_left(A, b)
    nb = N - bisect.bisect_right(C, b)
    ans += na * nb
print(ans)

import bisect
import sys

sys.setrecursionlimit(10**6)
INF = float("inf")
MOD = 10**9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    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:
        upper = bisect.bisect_left(A, b)
        bottom = N - bisect.bisect_right(C, b)
        ans += upper * bottom
    print(ans)


if __name__ == "__main__":
    main()

+import sys -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: -    na = bisect.bisect_left(A, b) -    nb = N - bisect.bisect_right(C, b) -    ans += na * nb -print(ans) +sys.setrecursionlimit(10**6) +INF = float("inf") +MOD = 10**9 + 7 + + +def input(): +    return sys.stdin.readline().strip() + + +def main(): +    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: +        upper = bisect.bisect_left(A, b) +        bottom = N - bisect.bisect_right(C, b) +        ans += upper * bottom +    print(ans) + + +if __name__ == "__main__": +    main()