The constraints are 1<n<=10⁵ and a[i]<=10⁹ Now you are given an array a. You task is to find minimum in the current sized array and remove that element and it's adjacent elements. The cost of this operation will be the minimum element choosen. Repeat this step till array becomes empty. Mathematics for any i within array limit such that a[i] is minimum of array a, then remove a[i] and if i-1 exists remove a[i-1] and if i+1 exists a[i+1], the cost will be cost+=a[i] , the array will become {a1, a2,...ai-2,ai+2,....an} again find minimum and repeat the same till array becomes empty.



