import Control.Applicative
func (x:[]) = []
func a  = (maximum (tail a) - (head a)) : (func (tail a))

main = do{
    n<-getLine;
    a<-map (read::String->Int).lines<$>getContents;
    print$maximum (func a);
}