Comments

can anyone explain what's wrong in my logic?

whenever I find a[i+1]>a[i],then I insert each of the elements from i+1 on wards which are smaller than a[i] and then take the lowest element present in the set to calculate the number of operations required. And then repeat the process several times

http://codeforces.me/contest/1392/submission/90294667