Buggy python submission (verdict: Time Limit Exceeded):
# -*- 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
from functools import lru_cache
input = stdin.readline


@lru_cache(maxsize=None)
def calc(i):
    ans = 0
    for b in B[i:]:
        j = lut_B[b]
        if j == N:
            break
        ans += (N - j)
    return ans


lut_B = {}
B = []
N = 0
def main(args):
    global lut_B
    global B
    global N
    N = int(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 = {a:bisect_right(B, a) for a in A}
    lut_B = {b:bisect_right(C, b) for b in B}

    ans = 0
    for a in A:
        i = lut_A[a]
        if i == N:
            break
        ans += calc(i)

    print(ans)


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


Fixed submission:
# -*- 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(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:])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- 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
from functools import lru_cache
input = stdin.readline



@lru_cache(maxsize=None)
def calc(i):
    ans = 0
    for b in B[i:]:
        j = lut_B[b]
        ans += (N - j)
    return ans


lut_B = {}
B = []
N = 0
def main(args):
    global lut_B
    global B
    global N
    N = int(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 = {a:bisect_right(B, a) for a in A}
    lut_B = {b:bisect_right(C, b) for b in B}


    ans = 0
    for a in A:
        i = lut_A[a]
#        for b in B[i:]:
#            j = lut_B[b]
#            temp += (N - j)
        ans += calc(i)


    print(ans)


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


Fixed submission:
# -*- 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(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:])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- 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(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 = {a:bisect_right(B, a) for a in A}
    lut_B = {b:bisect_right(C, b) for b in B}

    ans = 0
    old_i = -1
    for a in A:
        i = lut_A[a]

        if i == old_i:
            ans += temp
            continue
        else:
            temp = 0
            for b in B[i:]:
                j = lut_B[b]
                temp += (N - j)
        ans += temp
        old_i = i

    print(ans)


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


Fixed submission:
# -*- 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(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:])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- 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(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 = {}
    for a in A:
        j = bisect_right(B, a)
        lut_A[a] = j

    lut_B = [0] * N
    for i, b in enumerate(B):
        j = bisect_right(C, b)
        lut_B[i] = N-j

    ans = 0

    for a in A:
        i = lut_A[a]
        ans += sum(lut_B[i:])

    print(ans)



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


Fixed submission:
# -*- 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(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:])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- 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(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 = {}
    for a in A:
        j = bisect_right(B, a)
        lut_A[a] = j

    lut_B = {}
    for b in B:
        j = bisect_right(C, b)
        lut_B[b] = j

    ans = 0

    for a in A:
        # i = bisect_right(B, a)
        i = lut_A[a]
        if i == N:
            continue
        for b in B[i:]:
            # j = bisect_right(C, b)
            j = lut_B[b]
            if j == N:
                continue
            ans += (N-j)

    print(ans)



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


Fixed submission:
# -*- 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(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:])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- 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(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 = {}
    for b in B:
        j = bisect_right(C, b)
        lut[b] = j


    ans = 0

    for a in A:
        i = bisect_right(B, a)
        if i == N:
            continue
        for b in B[i:]:
            # j = bisect_right(C, b)
            j = lut[b]
            if j == N:
                continue
            ans += (N-j)

    print(ans)



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


Fixed submission:
# -*- 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(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:])