Many optimal reinsurance studies in the literature only take into consideration the insurer. However, there are two parties in reinsurance contracts. The aim of the study is to contribute to the optimal reinsurance literature by considering the interests of both the insurer and the reinsurer. A reasonable compromise between their interests is desired. Then, we examine the optimal retention problem that minimizes the absolute value of the difference between the insurer's and the reinsurer's profits under stop-loss and excess-of-loss reinsurance arrangements. With a nonnegative random variable, we incorporate the stochastic essence of the aggregate loss for the reinsurer's and insurer's profits into the model. For reinsurance premium calculation we use two different premium principles and for aggregate loss we use exponential, Pareto and lognormal distributions. The results of the studies only deal with the benefits of the insurer and the studies consider both the benefits of the insurer and reinsurer are compared. Our findings can be helpful for insurance companies and reinsurer companies in their decision making task. For simulation studies in the model MATLAB programming language is used.