import Foundation

func solve(n: Int, aSizes: [Int], bSizes: [Int], cSizes: [Int]) -> Int {

    var count = 0
    var bPassed = [Int: (combinations: Int, duplicateCount: Int)]()
    var accumulatesDict = [Int: Int]()

    for a in aSizes {

        let bBounds = corneredBounds(searchValue: a + 1, list: bSizes)

        guard let bStartIndex = findIndexWithValue(greaterThan: a, list: bSizes, candidates: bBounds) else {
            break
        }

        let bSliced = bSizes[bStartIndex..<n]
        var cNextIndex = 0
        for b in bSliced {

            if let accumulates = accumulatesDict[b] {
                count += accumulates
                break
            }

            if let met = bPassed[b] {
                count += met.combinations
                bPassed[b] = (met.combinations, met.duplicateCount + 1)
                continue
            }

            let cList = cSizes[cNextIndex..<n].map { $0 }
            let cBounds = corneredBounds(searchValue: b + 1, list: cList)

            guard let cIndex = findIndexWithValue(greaterThan: b, list: cList, candidates: cBounds) else {
                continue
            }

            let combinations = n - (cNextIndex + cIndex)
            count += combinations
            cNextIndex += cIndex
            bPassed[b] = (combinations, 1)
        }

        if accumulatesDict.isEmpty {
            let reversedBKeys = bPassed.keys.sorted().reversed()
            let accumulates = reversedBKeys.reduce([]) { $0 + [($0.last ?? 0) + (bPassed[$1]!.combinations * bPassed[$1]!.duplicateCount)] }
            accumulatesDict = Dictionary(uniqueKeysWithValues: zip(reversedBKeys, accumulates))
        }
    }

    return count
}

func findIndexWithValue(greaterThan value: Int, list: [Int], candidates: (left: Int, right: Int)) -> Int? {
    
    if candidates.left > -1 && list[candidates.left] > value {
        return candidates.left
    }
    else if list[candidates.right] > value {
        return candidates.right
    }
    else {
        return .none
    }
}

func corneredBounds(searchValue: Int, list: [Int]) -> (left: Int, right: Int) {

    var openedLower = -1
    var closedUpper = list.count - 1

    while closedUpper - openedLower > 1 {

        let mid = (closedUpper + openedLower) / 2

        func shouldBeInClosedSide() -> Bool {
            list[mid] >= searchValue ? true : false
        }

        if shouldBeInClosedSide() {
            closedUpper = mid
        }
        else {
            openedLower = mid
        }
    }

    return (openedLower, closedUpper)
}


let n = Int(readLine()!)!
let aSizes = readLine()!.split(separator: " ").compactMap{ Int($0) }.sorted()
let bSizes = readLine()!.split(separator: " ").compactMap{ Int($0) }.sorted()
let cSizes = readLine()!.split(separator: " ").compactMap{ Int($0) }.sorted()

let answer = solve(n: n, aSizes: aSizes, bSizes: bSizes, cSizes: cSizes)
print(answer)
