main :: IO()
main = do
        n <- readLn
        x <- readLn
        y <- readLn
        print =<< solve (y- x, min x y) n 2

solve :: (Int, Int) -> Int -> Int -> IO Int
solve (max', min') n m | n == m    = return max'
                       | otherwise = do
                                      z <- readLn
                                      solve (max (z - min') max', min z min') n (m + 1)