import Control.Applicative
import Control.Monad
import Data.List

f :: [Int] -> (Int, Int)
f xs = g (0, 0) xs
g (up, dn) (s:xs@(t:_))
  | s > t = g (up, max dn (s-t)) xs
  | s < t = g (max up (t-s), dn) xs
  | otherwise = g (up, dn) xs
g r _ = r

main = readLn >>= flip replicateM_ (getLine >> (f . map read . words <$> getLine) >>= \(u, d) -> putStrLn $ show u ++ " " ++ show d)
