The deal reflects the changing fortunes of Madison Avenue, an ad industry upended by new technologies, emerging competitors, and strained ad budgets.