import Data.Maybe (isJust)
import qualified Data.IntSet as S

main :: IO ()
main = do
  [a, b, q] <- map read . words <$> getLine
  stxs <- map read . lines <$> getContents
  let
    (ss, (ts, xs)) = ((,) <$> fst <*> splitAt b . snd) . splitAt a $ stxs
    ss' = S.fromDistinctAscList ss
    ts' = S.fromDistinctAscList ts
    f x = min (g ss' ts' x) (g ts' ss' x)
      where
        g ss ts x
          =
            let
                h :: (Int -> S.IntSet -> Maybe Int) -> (Int -> S.IntSet -> Maybe Int) -> Maybe Int
                h u v = do
                  s <- u x ss
                  t <- v s ts
                  return $ abs (s - x) + abs (t - s)
              in
                minimum . map (maybe undefined id) . filter isJust . map (uncurry h) $ [(S.lookupLT, S.lookupLT), (S.lookupLT, S.lookupGT), (S.lookupGT, S.lookupLT), (S.lookupGT, S.lookupGT)]
  mapM_ (print . f) xs
