import Control.Applicative
 
main = do
  _ <- getLine
  xs <- map read . words <$> getLine
  ys <- map read . words <$> getLine
  putStr . show . (`mod` 1000000007) . (* 3) $ (f xs) * (f ys)

f zs = (maximum zs) - (minimum zs)