# -*- coding: utf-8 -*-

"""

https://beta.atcoder.jp/contests/abc077/tasks/arc084_a



"""

import sys

from sys import stdin

from bisect import bisect_left, bisect_right

input = stdin.readline





def main(args):

    N = int(eval(input()))

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

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

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

    A.sort()

    B.sort()

    C.sort()



    lut_A = {}

    lut_C = {}

    for b in B:

        i = bisect_left(A, b)

        lut_A[b] = i

        j = bisect_right(C, b)

        lut_C[b] = N - j





    ans = 0

    for b in B:

        i = lut_A[b]

        j = lut_C[b]

        ans += i * j



    print(ans)





if __name__ == '__main__':

    main(sys.argv[1:])

# -*- coding: utf-8 -*-

"""

https://beta.atcoder.jp/contests/abc077/tasks/arc084_a



"""

import sys

from sys import stdin

from bisect import bisect_left, bisect_right

input = stdin.readline





def main(args):

    N = int(eval(input()))

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

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

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

    A.sort()

#    B.sort()

    C.sort()



#    lut_A = {}

#    lut_C = {}

#    for b in B:

#        i = bisect_left(A, b)

#        lut_A[b] = i

#        j = bisect_right(C, b)

#        lut_C[b] = N - j

    lut_A = {b:bisect_left(A, b) for b in B}

    lut_C = {b:(N - bisect_right(C, b)) for b in B}



    ans = 0

    for b in B:

        i = lut_A[b]

        j = lut_C[b]

        ans += i * j



    print(ans)





if __name__ == '__main__':

    main(sys.argv[1:])

# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc077/tasks/arc084_a
"""
import sys
from sys import stdin
from bisect import bisect_left, bisect_right

input = stdin.readline


def main(args):
    N = int(eval(input()))
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]
    C = [int(x) for x in input().split()]
    A.sort()
    B.sort()
    C.sort()
    lut_A = {}
    lut_C = {}
    for b in B:
        i = bisect_left(A, b)
        lut_A[b] = i
        j = bisect_right(C, b)
        lut_C[b] = N - j
    ans = 0
    for b in B:
        i = lut_A[b]
        j = lut_C[b]
        ans += i * j
    print(ans)


if __name__ == "__main__":
    main(sys.argv[1:])

# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc077/tasks/arc084_a
"""
import sys
from sys import stdin
from bisect import bisect_left, bisect_right

input = stdin.readline


def main(args):
    N = int(eval(input()))
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]
    C = [int(x) for x in input().split()]
    A.sort()
    #    B.sort()
    C.sort()
    #    lut_A = {}
    #    lut_C = {}
    #    for b in B:
    #        i = bisect_left(A, b)
    #        lut_A[b] = i
    #        j = bisect_right(C, b)
    #        lut_C[b] = N - j
    lut_A = {b: bisect_left(A, b) for b in B}
    lut_C = {b: (N - bisect_right(C, b)) for b in B}
    ans = 0
    for b in B:
        i = lut_A[b]
        j = lut_C[b]
        ans += i * j
    print(ans)


if __name__ == "__main__":
    main(sys.argv[1:])

-    B.sort() +    #    B.sort() -    lut_A = {} -    lut_C = {} -    for b in B: -        i = bisect_left(A, b) -        lut_A[b] = i -        j = bisect_right(C, b) -        lut_C[b] = N - j +    #    lut_A = {} +    #    lut_C = {} +    #    for b in B: +    #        i = bisect_left(A, b) +    #        lut_A[b] = i +    #        j = bisect_right(C, b) +    #        lut_C[b] = N - j +    lut_A = {b: bisect_left(A, b) for b in B} +    lut_C = {b: (N - bisect_right(C, b)) for b in B}