judge :: (Int, Int) -> [Int] -> (Int, Int)
judge (a, b) [a1, b1]
  | a1 > b1 = (a + a1 + b1, b)
  | a1 < b1 = (a, b + a1 + b1)
  | otherwise = (a + a1, b + b1)
judge _ _ = error "3"

showScore :: (Int, Int) -> String
showScore (a, b) = show a ++ ' ' : show b

solve :: [[Int]] -> String
solve [[0]] = ""
solve ([n]:r) = showScore (foldl judge (0, 0) (take n r)) ++ '\n':solve (drop n r)
solve _ = ""
main :: IO ()
main = do
  args <- fmap (map (map (\n -> read n :: Int) . words) . lines) getContents
  putStr $ solve args