

foo :: Int -> [Int] -> [Int]
foo x []     = [x]
foo x (n:ns) = x:foo next ns
  where next = 2 * n - x

printList :: [Int] -> IO ()
printList ints = putStrLn $ unwords $ map show ints

main = do
  _ <- getLine
  nums <- map read . words <$> getLine :: IO [Int]
  loop nums [2,4..head nums]
  where
    loop nums (x:xs) =
      let res = foo x nums
      in
        if head res == last res then printList $ init res
        else loop nums xs

