import Data.List
import Debug.Trace

main :: IO ()
main = do
  _ <- readLn :: IO Int
  as <- (sort . map read . words) <$> getLine :: IO [Int]
  bs <- (sort . map read . words) <$> getLine :: IO [Int]
  cs <- (sort . map read . words) <$> getLine :: IO [Int]
  print $ solve as bs cs

solve as bs cs =
  sum $ map (\a -> solveA a bs cs) as

solveA a bs cs =
  let p = binSearch a bs 0 (length bs - 1)
      bs' = drop p bs
  in sum $ map (\b -> solveB b cs) bs'

solveB b cs =
    let p = binSearch b cs 0 (length cs - 1)
        cs' = drop p cs
    in length cs'

binSearch :: Int -> [Int] -> Int -> Int -> Int
binSearch a bs left right
  | left == 0 && a < bs !! left = 0
  | right == length bs - 1 && a >= bs !! right = length bs
  | left + 1 >= right = right
  | otherwise =
    let p = (left + right) `div` 2
        v = bs !! p
    in if v <= a then binSearch a bs p right else binSearch a bs left p
