N = int(eval(input()))

A = [int(i) for i in input().split()]

B = [int(i) for i in input().split()]

C = [int(i) for i in input().split()]

A.sort();C.sort()

M = 0

for i in range(N):

    low = 0

    high = N - 1

    t = (low + high) // 2

    if A[N-1] < B[i]:

        t = N-1

    elif A[0] >= B[i]:

        t = -1

    else:

        while (low <= high):

            if A[t] < B[i] <= A[t+1]:

                break

            elif B[i] <= A[t]:

                high = t

            elif A[t+1] < B[i]:

                low = t+1

            t = (low + high) // 2

    low = 0

    high = N - 1

    s = (low + high) // 2

    if C[N-1] <= B[i]:

        s = N-1

    elif B[i] < C[0]:

        s = -1

    else:

        while (low <= high):

            if C[s] <= B[i] < C[s+1]:

                break

            elif B[i] < C[s]:

                high = s

            elif C[s+1] <= B[i]:

                low = s + 1

            s = (low + high) // 2

    M += (t+1)*(N-s-1)

print(M)

from bisect import bisect_left,bisect_right

N=int(eval(input()))

A=[int(i) for i in input().split()]

B=[int(i) for i in input().split()]

C=[int(i) for i in input().split()]

A.sort()

C.sort()

ans=0

for i in range(N):

    ans+=bisect_left(A,B[i])*(N-bisect_right(C,B[i]))

print(ans)

N = int(eval(input()))
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A.sort()
C.sort()
M = 0
for i in range(N):
    low = 0
    high = N - 1
    t = (low + high) // 2
    if A[N - 1] < B[i]:
        t = N - 1
    elif A[0] >= B[i]:
        t = -1
    else:
        while low <= high:
            if A[t] < B[i] <= A[t + 1]:
                break
            elif B[i] <= A[t]:
                high = t
            elif A[t + 1] < B[i]:
                low = t + 1
            t = (low + high) // 2
    low = 0
    high = N - 1
    s = (low + high) // 2
    if C[N - 1] <= B[i]:
        s = N - 1
    elif B[i] < C[0]:
        s = -1
    else:
        while low <= high:
            if C[s] <= B[i] < C[s + 1]:
                break
            elif B[i] < C[s]:
                high = s
            elif C[s + 1] <= B[i]:
                low = s + 1
            s = (low + high) // 2
    M += (t + 1) * (N - s - 1)
print(M)

from bisect import bisect_left, bisect_right

N = int(eval(input()))
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A.sort()
C.sort()
ans = 0
for i in range(N):
    ans += bisect_left(A, B[i]) * (N - bisect_right(C, B[i]))
print(ans)

+from bisect import bisect_left, bisect_right + -M = 0 +ans = 0 -    low = 0 -    high = N - 1 -    t = (low + high) // 2 -    if A[N - 1] < B[i]: -        t = N - 1 -    elif A[0] >= B[i]: -        t = -1 -    else: -        while low <= high: -            if A[t] < B[i] <= A[t + 1]: -                break -            elif B[i] <= A[t]: -                high = t -            elif A[t + 1] < B[i]: -                low = t + 1 -            t = (low + high) // 2 -    low = 0 -    high = N - 1 -    s = (low + high) // 2 -    if C[N - 1] <= B[i]: -        s = N - 1 -    elif B[i] < C[0]: -        s = -1 -    else: -        while low <= high: -            if C[s] <= B[i] < C[s + 1]: -                break -            elif B[i] < C[s]: -                high = s -            elif C[s + 1] <= B[i]: -                low = s + 1 -            s = (low + high) // 2 -    M += (t + 1) * (N - s - 1) -print(M) +    ans += bisect_left(A, B[i]) * (N - bisect_right(C, B[i])) +print(ans)