import           Control.Applicative
import           Control.Monad
import           Data.List
import           Text.Printf

main = do
    n<- getLine
    a<- map (read::String->Int) <$> replicateM (read n) getLine
    print $ maximum $ zipWith (-) (tail a) (tail $ scanl1 min a)

