import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Maybe as Maybe
import qualified Text.Printf as Printf
import qualified Control.Monad as Monad
import qualified Data.Array as Array

bisectLeft :: (Ord a) => a -> (Array.Array Int a) -> Int
bisectLeft n xs = bisectLeft' 0 (length xs) n xs

bisectLeft' :: (Ord a) => Int -> Int -> a -> (Array.Array Int a) -> Int
bisectLeft' lo hi n xs = if lo >= hi then lo else
                    if n <= (xs Array.! mid) then bisectLeft' lo mid n xs
                      else bisectLeft' (mid + 1) hi n xs
                    where mid = (lo + hi) `div` 2

bisectRight :: (Ord a) => a -> (Array.Array Int a) -> Int
bisectRight n xs = bisectRight' 0 (length xs) n xs

bisectRight' :: (Ord a) => Int -> Int -> a -> (Array.Array Int a) -> Int
bisectRight' lo hi n xs = if lo >= hi then hi else
                    if n < (xs Array.! mid) then bisectRight' lo mid n xs
                      else bisectRight' (mid + 1) hi n xs
                    where mid = (lo + hi) `div` 2


main :: IO ()
main = do
  n <- (read :: String -> Int) <$> getLine
  as <- List.sort . map (read :: String -> Int) . words <$> getLine
  bs <- map (read :: String -> Int) . words <$> getLine
  cs <- List.sort . map (read :: String -> Int) . words <$> getLine
  let as_ = Array.array (0,length as - 1) (zip [0..length as - 1] as)
  let cs_ = Array.array (0,length cs - 1) (zip [0..length cs - 1] cs)
  print $ foldl (+) 0 $ map (\ b -> (bisectLeft b as_) * (n - bisectRight b cs_)) bs