This paper derives necessary and sufficient conditions for the optimal number of firms in the sense of second best in Cournot oligopolies with nonlinear demand and nonlinear costs. These conditions reveal the precise relationship between the optimal number of firms and scale economies, and they suggest a new approach to assess whether entries (exits) are welfare-increasing or welfare-maximizing. [PUBLICATION ABSTRACT]