Help in solving C1. Skyscrapers - Codeforces

Problem Link :

Can someone help me in solving this greedy problem ???
I struggle a lot with these types of tricky greedy problem.

I thought of 2 passes left and right and storing max and then changing the elements and then comparing the sum of both sides(left and right) but it is not working , Can someone suggest a good approach to solve this problem. There is no tutorial for this problem .