import sys

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



def main():

    N = int(eval(input()))

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

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

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



    ans = 0

    for b in B:

        sum_v = 1

        l = -1

        r = N

        while r - l > 1:

            m = (l + r) // 2

            if b > A[m]:

                l = m

            else:

                r = m

        sum_v *= l + 1



        l = -1

        r = N

        while r - l > 1:

            m = (l + r) // 2

            if b < C[m]:

                r = m

            else:

                l = m

        sum_v *= N - r

        ans += sum_v

    print(ans)



if __name__ == '__main__':

    main()

import sys

import bisect

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



def main():

    N = int(eval(input()))

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

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

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



    ans = 0

    for b in B:

        ans += bisect.bisect_left(A, b) * (N - bisect.bisect_right(C, b))

    print(ans)



if __name__ == '__main__':

    main()

import sys


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


def main():
    N = int(eval(input()))
    A = sorted(map(int, input().split()))
    B = sorted(map(int, input().split()))
    C = sorted(map(int, input().split()))
    ans = 0
    for b in B:
        sum_v = 1
        l = -1
        r = N
        while r - l > 1:
            m = (l + r) // 2
            if b > A[m]:
                l = m
            else:
                r = m
        sum_v *= l + 1
        l = -1
        r = N
        while r - l > 1:
            m = (l + r) // 2
            if b < C[m]:
                r = m
            else:
                l = m
        sum_v *= N - r
        ans += sum_v
    print(ans)


if __name__ == "__main__":
    main()

import sys
import bisect


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


def main():
    N = int(eval(input()))
    A = sorted(map(int, input().split()))
    B = sorted(map(int, input().split()))
    C = sorted(map(int, input().split()))
    ans = 0
    for b in B:
        ans += bisect.bisect_left(A, b) * (N - bisect.bisect_right(C, b))
    print(ans)


if __name__ == "__main__":
    main()

+import bisect -        sum_v = 1 -        l = -1 -        r = N -        while r - l > 1: -            m = (l + r) // 2 -            if b > A[m]: -                l = m -            else: -                r = m -        sum_v *= l + 1 -        l = -1 -        r = N -        while r - l > 1: -            m = (l + r) // 2 -            if b < C[m]: -                r = m -            else: -                l = m -        sum_v *= N - r -        ans += sum_v +        ans += bisect.bisect_left(A, b) * (N - bisect.bisect_right(C, b))