This function assumes that a [ ] is sorted . If a [ ] is not sorted , we need to sort it first .
using System ; using System . Collections . Generic ; class GFG { static int minCostToMakeElementEqual ( int [ ] a , int n ) {