import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let n = Int(readLine()!)!
    var upper = readInts()
    var middle = readInts()
    var lower = readInts()
    var ans = 0
    //_______________________________ここまで入力
    upper.sort()
    middle.sort()
    lower.sort()  { $0 > $1 }
    
    var (uR, lR) = (0, n - 1)
    
    for i in 0..<n {
        while uR < n && middle[i] > upper[uR] {
            uR += 1
        }
        while lR >= 0 && middle[i] >= lower[lR] {
            lR -= 1
        }
        ans += uR * (lR + 1)
    }
    
    print(ans)
}
main()
