You are the manager of the hotel and you have N customers to serve. Each customer has a happiness quotient (Ci) if the food is served to him at time x. The unhappiness of a customer is defined by |Ci - x|. You must serve all the customers and you can serve them in any order. You have to find the minimum sum of unhappiness.
Note: At a particular time only one customer is served and Each customer takes one unit of time.
1 <= N <=10^3
1<= Ci <=N
2 2 3 3
1 1 1 1
Please give suggestions on how to solve this problem efficiently.