given array is `0 1 0 2 1 0 1 3 2 1 2 1`

- so I traverse from start
- Reach an index whose value is equal to or greater than the number.

3.find the minimum of the values. - subtract the values of arrays from that number and add them up.

In the above example first 0 the greatest index next is 1 minimum is 0. There is nothing in between them so sol+=0 from 1 I again go till 2 minimum is 1 so 1-0 = 1 sol+=1 and then from 2 I go till 3 minimum is 2 sol+=(2-1)+(2-0)+(2-1) and from 2. So on but my approach is O(n^2). Will this work? Any modification or caching by which I can make this O(n)