from bisect import bisect

from itertools import accumulate

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

    ainb = [bisect(b, ea) for ea in a]

    bc = [n - bisect(c, eb) for eb in b]

    bcaccum = tuple(accumulate(bc))

    tr = 0

    for eainb in ainb:

        if eainb != 0:

            tr += bcaccum[eainb - 1]

    r = bcaccum[-1] * n - tr



    print(r)



if __name__ == '__main__':

    main()

import sys

read = sys.stdin.read

#readlines = sys.stdin.readlines

from bisect import bisect, bisect_left

from itertools import accumulate

def main():

    data = list(map(int, read().split()))

    n = data[0]

    a = data[1:n + 1]

    b = data[n + 1: n * 2 + 1]

    c = data[n * 2 + 1:]

    a.sort()

    b.sort()

    c.sort()

    b2 = [bisect_left(a, be) for be in b]

    b2a = list(accumulate(b2))

    b2a = [0] + b2a

    ans = sum([b2a[bisect_left(b, ce)] for ce in c])

    print(ans)



if __name__ == '__main__':

    main()
from bisect import bisect
from itertools import accumulate


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()
    ainb = [bisect(b, ea) for ea in a]
    bc = [n - bisect(c, eb) for eb in b]
    bcaccum = tuple(accumulate(bc))
    tr = 0
    for eainb in ainb:
        if eainb != 0:
            tr += bcaccum[eainb - 1]
    r = bcaccum[-1] * n - tr
    print(r)


if __name__ == "__main__":
    main()

import sys

read = sys.stdin.read
# readlines = sys.stdin.readlines
from bisect import bisect, bisect_left
from itertools import accumulate


def main():
    data = list(map(int, read().split()))
    n = data[0]
    a = data[1 : n + 1]
    b = data[n + 1 : n * 2 + 1]
    c = data[n * 2 + 1 :]
    a.sort()
    b.sort()
    c.sort()
    b2 = [bisect_left(a, be) for be in b]
    b2a = list(accumulate(b2))
    b2a = [0] + b2a
    ans = sum([b2a[bisect_left(b, ce)] for ce in c])
    print(ans)


if __name__ == "__main__":
    main()

-from bisect import bisect +import sys + +read = sys.stdin.read +# readlines = sys.stdin.readlines +from bisect import bisect, bisect_left -    n = int(eval(input())) -    a = list(map(int, input().split())) -    b = list(map(int, input().split())) -    c = list(map(int, input().split())) +    data = list(map(int, read().split())) +    n = data[0] +    a = data[1 : n + 1] +    b = data[n + 1 : n * 2 + 1] +    c = data[n * 2 + 1 :] -    ainb = [bisect(b, ea) for ea in a] -    bc = [n - bisect(c, eb) for eb in b] -    bcaccum = tuple(accumulate(bc)) -    tr = 0 -    for eainb in ainb: -        if eainb != 0: -            tr += bcaccum[eainb - 1] -    r = bcaccum[-1] * n - tr -    print(r) +    b2 = [bisect_left(a, be) for be in b] +    b2a = list(accumulate(b2)) +    b2a = [0] + b2a +    ans = sum([b2a[bisect_left(b, ce)] for ce in c]) +    print(ans)