Capacitor optimal placement is one of the most important designs and control issues of power systems in order to reduce network losses, improve the voltage profile, reduce the reactive load, and reducing the power factor. The distribution network operator, taking into account two major goals of reducing real power losses and maximizing the return on investment required for installation of capacitive banks for sale to the transmission system, obtains the position, number, and capacity of capacitive banks. In this paper, the optimization problem is formulated for different values of the parameter "reactive energy value". After evaluating the objective function and implementing an optimization algorithm for each value of this parameter, the arrangement and capacitance of the capacitors in the network load nodes are obtained. Meanwhile, using the objective function defined in this paper, you can obtain the threshold for the sale of reactive energy, and by selling it to the transmission network, the investment in installing capacitor banks will be profitable for the distribution network operator.