import Control.Applicative
import Control.Monad

helper :: (Int, Int) -> Int -> IO (Int, Int)
helper (x, y) _ = do
    z <- readLn
    return (min x z, max y (z - x))

solve :: Int -> Int -> Int -> IO Int
solve x y n = snd <$> foldM helper (min x y, y - x) [1 .. n - 2]

main :: IO ()
main = do
    n <- readLn
    x <- readLn
    y <- readLn
    solve x y n >>= print