Codeforces: Make It Equal

Can anyone tell me how to solve this question.
Link