Replace with sum of greater nodes

please help to get better approach ------

my code lacks something and hence not working fine at some point. please suggest another way to do this or correct my one.
link to my code is:

please try with the input
7
20 30 40 50 60 70 80

The shortcoming of your code is that you are only checking for the left part of left subtree of the whole tree . That is why the node with value 40 is never visited , so it is never replaced by the nodes greater to it.
Try using inorder Traversal in this , starting from the right subtree instead of left.
That is , Inorder will go like 'Right Root then Left’.