[![enter image description here](https://i.stack.imgur.com/0aDy9.jpg)](https://i.stack.imgur.com/0aDy9.jpg)

My answer is `46`(don't remember how I got it). I took an array in descending order, and simulated it. 

Source: GATE-CS 2016 question