Chocolate

There is a shop named Chocolove in the Codeland. There are many chocolates in the shop. Each chocolate has its own taste value. You want to take some chocolates from this shop. But the chocolates are not free. You have to pay. If you take chocolate i and the previous chocolate you took is j, the cost of taking chocolate i is the difference between i*Tj and j*Ti where Ti, Tj is the taste value of chocolate i and j respectively. Remember, you can’t take chocolate i more than once. The shop has an offer too. The cost of the chocolate you take first is 0. Now you want to know what is the minimum amount of money you have to pay if you take x chocolates from the shop.


This is a companion discussion topic for the original entry at https://toph.co/p/chocolate