Perfect Competition and Optimal Product Differentiation