why don’t we use a priority_queue?
we can push the difference between two adjacent elements and then for each move, we can pop the top element and push (top/2) and (top-top/2) into the priority_queue
At the end top of priority_queue would be the answer.