n = int(eval(input()))

a = sorted(list(map(int, input().split())))

b = sorted(list(map(int, input().split())))

c = sorted(list(map(int, input().split())))



def check_a(a_num, b_num):

    res = False

    if a_num < b_num:

        res = True

    return res



def check_c(c_num, b_num):

    res = False

    if b_num < c_num:

        res = True

    return res



ans = 0

cnt_a = 0

cnt_c = 0

for bi in range(len(b)):

    left = 0

    right = len(a)-1

    if check_a(a[0], b[bi]) is False:

        cnt_a = 0

    elif check_a(a[-1], b[bi]) is True:

        cnt_a = len(a)

    else:

        while right-left > 1:

            mid = (left + right) // 2

            if check_a(a[mid], b[bi]):

                left = mid

            else:

                right = mid

        cnt_a = left + 1



    left = 0

    right = len(c) - 1

    if check_c(c[0], b[bi]) is True:

        cnt_c = len(c)

    elif check_c(c[-1], b[bi]) is False:

        cnt_c = 0

    else:

        while right - left > 1:

            mid = (left + right) // 2

            if check_c(c[mid], b[bi]):

                right = mid

            else:

                left = mid

        cnt_c = len(c) - right

    ans += cnt_a * cnt_c

print(ans)



n = int(eval(input()))

a = list(map(int, input().split()))

b = list(map(int, input().split()))

c = list(map(int, input().split()))



cnt = [0] * len(b)

a = sorted(a)

c = sorted(c)



for i in range(len(b)):

    target = b[i]



    # decide a cnt

    l = 0

    r = len(a) - 1

    if a[l] >= target:

        cnt[i] += 0

    elif a[r] < target: 

        cnt[i] += len(a)

    else:

        while r - l > 1:

            mid = (l + r) // 2

            if a[mid] >= target:

                r = mid

            else:

                l = mid

        cnt[i] += l + 1



    # decide c cnt

    l = 0

    r = len(c) - 1

    if c[l] > target:

        cnt[i] *= len(c)

    elif c[r] <= target: 

        cnt[i] *= 0

    else:

        while r - l > 1:

            mid = (l + r) // 2

            if c[mid] > target:

                r = mid

            else:

                l = mid

        cnt[i] *= len(c) - (l + 1)

print((sum(cnt)))















n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))


def check_a(a_num, b_num):
    res = False
    if a_num < b_num:
        res = True
    return res


def check_c(c_num, b_num):
    res = False
    if b_num < c_num:
        res = True
    return res


ans = 0
cnt_a = 0
cnt_c = 0
for bi in range(len(b)):
    left = 0
    right = len(a) - 1
    if check_a(a[0], b[bi]) is False:
        cnt_a = 0
    elif check_a(a[-1], b[bi]) is True:
        cnt_a = len(a)
    else:
        while right - left > 1:
            mid = (left + right) // 2
            if check_a(a[mid], b[bi]):
                left = mid
            else:
                right = mid
        cnt_a = left + 1
    left = 0
    right = len(c) - 1
    if check_c(c[0], b[bi]) is True:
        cnt_c = len(c)
    elif check_c(c[-1], b[bi]) is False:
        cnt_c = 0
    else:
        while right - left > 1:
            mid = (left + right) // 2
            if check_c(c[mid], b[bi]):
                right = mid
            else:
                left = mid
        cnt_c = len(c) - right
    ans += cnt_a * cnt_c
print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
cnt = [0] * len(b)
a = sorted(a)
c = sorted(c)
for i in range(len(b)):
    target = b[i]
    # decide a cnt
    l = 0
    r = len(a) - 1
    if a[l] >= target:
        cnt[i] += 0
    elif a[r] < target:
        cnt[i] += len(a)
    else:
        while r - l > 1:
            mid = (l + r) // 2
            if a[mid] >= target:
                r = mid
            else:
                l = mid
        cnt[i] += l + 1
    # decide c cnt
    l = 0
    r = len(c) - 1
    if c[l] > target:
        cnt[i] *= len(c)
    elif c[r] <= target:
        cnt[i] *= 0
    else:
        while r - l > 1:
            mid = (l + r) // 2
            if c[mid] > target:
                r = mid
            else:
                l = mid
        cnt[i] *= len(c) - (l + 1)
print((sum(cnt)))

-a = sorted(list(map(int, input().split()))) -b = sorted(list(map(int, input().split()))) -c = sorted(list(map(int, input().split()))) - - -def check_a(a_num, b_num): -    res = False -    if a_num < b_num: -        res = True -    return res - - -def check_c(c_num, b_num): -    res = False -    if b_num < c_num: -        res = True -    return res - - -ans = 0 -cnt_a = 0 -cnt_c = 0 -for bi in range(len(b)): -    left = 0 -    right = len(a) - 1 -    if check_a(a[0], b[bi]) is False: -        cnt_a = 0 -    elif check_a(a[-1], b[bi]) is True: -        cnt_a = len(a) +a = list(map(int, input().split())) +b = list(map(int, input().split())) +c = list(map(int, input().split())) +cnt = [0] * len(b) +a = sorted(a) +c = sorted(c) +for i in range(len(b)): +    target = b[i] +    # decide a cnt +    l = 0 +    r = len(a) - 1 +    if a[l] >= target: +        cnt[i] += 0 +    elif a[r] < target: +        cnt[i] += len(a) -        while right - left > 1: -            mid = (left + right) // 2 -            if check_a(a[mid], b[bi]): -                left = mid +        while r - l > 1: +            mid = (l + r) // 2 +            if a[mid] >= target: +                r = mid -                right = mid -        cnt_a = left + 1 -    left = 0 -    right = len(c) - 1 -    if check_c(c[0], b[bi]) is True: -        cnt_c = len(c) -    elif check_c(c[-1], b[bi]) is False: -        cnt_c = 0 +                l = mid +        cnt[i] += l + 1 +    # decide c cnt +    l = 0 +    r = len(c) - 1 +    if c[l] > target: +        cnt[i] *= len(c) +    elif c[r] <= target: +        cnt[i] *= 0 -        while right - left > 1: -            mid = (left + right) // 2 -            if check_c(c[mid], b[bi]): -                right = mid +        while r - l > 1: +            mid = (l + r) // 2 +            if c[mid] > target: +                r = mid -                left = mid -        cnt_c = len(c) - right -    ans += cnt_a * cnt_c -print(ans) +                l = mid +        cnt[i] *= len(c) - (l + 1) +print((sum(cnt)))