-- Maximum Profit
main = getContents >>= putStrLn . solve

max0 = -1000000000

solve :: String -> String
solve = show . (\(x:xs) -> maxProf max0 x xs) . map read . lines

maxProf :: Int -> Int -> [Int] -> Int
maxProf maxx _ [] = maxx
maxProf maxx minx (x:xs) = maxProf maxx' minx' xs
  where
    maxx' = max maxx (x - minx)
    minx' = min minx x