import Control.Monad
import Control.Applicative

main :: IO ()
main = do
    n <- read <$> getLine
    rs <- map read <$> replicateM n getLine
    print $ maximum $ solve rs

solve :: [Int] -> [Int]
solve [] = []
solve (x:xs) = (maximum (map (subtract x) xs)):(solve xs)