main :: IO()
main = getContents >>= print.solve.map read.tail.lines

solve          :: [Int] -> Int
solve (x:y:ys) = fst $foldl f (y-x, min x y) ys
    where f (x,y) z = let a = max (z-y) x; b = min z y  in (a, b) 