import Foundation

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

    return bSizes
        .map {
            let lowerCases = corneredBounds(searchValue: $0, list: aSizes, policy: .lower).left + 1
            let upperCases = n - corneredBounds(searchValue: $0, list: cSizes, policy: .upper).right
            return lowerCases * upperCases
        }
        .reduce(0, +)
}

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

    var openedLeft = -1
    var openedRight = list.count

    while openedRight - openedLeft > 1 {

        let mid = (openedRight + openedLeft) / 2

        func midValueShouldBeInLeftSide() -> Bool {
            policy.midValueShouldBeInLeftSide(at: mid, on: list, with: searchValue)
        }

        if midValueShouldBeInLeftSide() {
            openedLeft = mid
        }
        else {
            openedRight = mid
        }
    }

    return (openedLeft, openedRight)
}

enum Direction {

    case lower
    case upper

    func midValueShouldBeInLeftSide(at index: Int, on list: [Int], with searchValue: Int) -> Bool {

        switch self {
            case .lower: return list[index] <  searchValue ? true : false
            case .upper: return list[index] <= searchValue ? true : false
        }
    }
}

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)
