Generating Optimal Revenue from Ad Sales