{-# LANGUAGE RankNTypes #-}
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Array as A
import Data.Array.ST
import Control.Monad.ST
import Control.Monad
import Control.Applicative

main :: IO ()
main = breads >>= main'
    where
        main' [n, z, w] = breads >>= print . solve n z w

solve :: Int -> Int -> Int -> [Int] -> Int
solve n z w xs = arr A.! (0, 0, 0)
    where
        vs = A.listArray (0, n - 1) xs
        arr = runSTArray $ do
            a <- newArray_ ((0, 0, 0), (1, n - 1, n))
            forM_ (zip [0..] $ w : xs) $ \(k, v) ->
                writeArray a (0, n - 1, k) . abs $ vs A.! (n - 1) - v
            forM_ (zip [0..] $ z : xs) $ \(k, v) ->
                writeArray a (1, n - 1, k) . abs $ vs A.! (n - 1) - v
            forM_ [(i, j, k) | j <- [(n - 2), (n - 3)..0], i <- [0, 1], k <- [0..n]] $ \(i, j, k) -> do
                lhs <- readArray a (i, j + 1, k)
                rhs <- readArray a (1 - i, j + 1, j + 1)
                writeArray a (i, j, k) $ cmpf i lhs rhs
            return a
        cmpf i
                | i == 0 = max
                | otherwise = min

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)

