def solve(string):

    n, *abc = list(map(int, string.split()))

    a = sorted(abc[:n], reverse=True)

    b = sorted(abc[n:2 * n], reverse=True)

    c = sorted(abc[2 * n:], reverse=True)

    ab = [0] * n

    j = 0

    for i, _a in enumerate(a):

        while j <= n - 1 and _a < b[j]:

            j += 1

        ab[i] = j

    bc = [0] * (n + 1)

    j = 0

    for i, _b in enumerate(b, start=1):

        while j <= n - 1 and _b < c[j]:

            j += 1

        bc[i] = j



    for i in range(1, len(bc)):

        bc[i] += bc[i - 1]

    return str(sum([bc[_ab] for _ab in ab]))





if __name__ == '__main__':

    n = int(eval(input()))

    print((solve('{}\n'.format(n) + '\n'.join([eval(input()) for _ in range(3)]))))

def solve(string):

    n, *abc = list(map(int, string.split()))

    a, b, c = sorted(abc[:n]), sorted(abc[n:2 * n]), sorted(abc[2 * n:])

    ai = ci = ans = 0

    for _b in b:

        while ai < n and a[ai] < _b:

            ai += 1

        while ci < n and c[ci] <= _b:

            ci += 1

        ans += ai * (n - ci)

    return str(ans)





if __name__ == '__main__':

    n = int(eval(input()))

    print((solve('{}\n'.format(n) + '\n'.join([eval(input()) for _ in range(3)]))))

def solve(string):
    n, *abc = list(map(int, string.split()))
    a = sorted(abc[:n], reverse=True)
    b = sorted(abc[n : 2 * n], reverse=True)
    c = sorted(abc[2 * n :], reverse=True)
    ab = [0] * n
    j = 0
    for i, _a in enumerate(a):
        while j <= n - 1 and _a < b[j]:
            j += 1
        ab[i] = j
    bc = [0] * (n + 1)
    j = 0
    for i, _b in enumerate(b, start=1):
        while j <= n - 1 and _b < c[j]:
            j += 1
        bc[i] = j
    for i in range(1, len(bc)):
        bc[i] += bc[i - 1]
    return str(sum([bc[_ab] for _ab in ab]))


if __name__ == "__main__":
    n = int(eval(input()))
    print((solve("{}\n".format(n) + "\n".join([eval(input()) for _ in range(3)]))))

def solve(string):
    n, *abc = list(map(int, string.split()))
    a, b, c = sorted(abc[:n]), sorted(abc[n : 2 * n]), sorted(abc[2 * n :])
    ai = ci = ans = 0
    for _b in b:
        while ai < n and a[ai] < _b:
            ai += 1
        while ci < n and c[ci] <= _b:
            ci += 1
        ans += ai * (n - ci)
    return str(ans)


if __name__ == "__main__":
    n = int(eval(input()))
    print((solve("{}\n".format(n) + "\n".join([eval(input()) for _ in range(3)]))))

-    a = sorted(abc[:n], reverse=True) -    b = sorted(abc[n : 2 * n], reverse=True) -    c = sorted(abc[2 * n :], reverse=True) -    ab = [0] * n -    j = 0 -    for i, _a in enumerate(a): -        while j <= n - 1 and _a < b[j]: -            j += 1 -        ab[i] = j -    bc = [0] * (n + 1) -    j = 0 -    for i, _b in enumerate(b, start=1): -        while j <= n - 1 and _b < c[j]: -            j += 1 -        bc[i] = j -    for i in range(1, len(bc)): -        bc[i] += bc[i - 1] -    return str(sum([bc[_ab] for _ab in ab])) +    a, b, c = sorted(abc[:n]), sorted(abc[n : 2 * n]), sorted(abc[2 * n :]) +    ai = ci = ans = 0 +    for _b in b: +        while ai < n and a[ai] < _b: +            ai += 1 +        while ci < n and c[ci] <= _b: +            ci += 1 +        ans += ai * (n - ci) +    return str(ans)