Roy is helping the police department of his city in crime fighting. Today, they informed him about a new planned operation. The city has only one road and criminals live there! To catch these criminals, the police department has to recruit some police officers and give each of them as wages. A police officer can start his operation from any point , drive his car to point in a straight line, and catch all the criminals who live on this way.

The cost of the fuel used

Thus, find the minimum amount of money spent to catch all the criminals.

#### Constraints

##### Subtask 1 [20%]

##### Subtask 2 [20%]

##### Subtask 3 [60%]

##### Subtask 4 [0%]

Sample test cases.

#### Input Specification

st line: Number of criminals () and value of

nd line: Position of where the criminals live

#### Output Specification

st line: Minimum amount of money spent.

#### Sample Input

```
5 10
1 4 5 6 9
```

#### Sample Output

`34`

#### Explanation

One police deployed at position

One police deployed at position , travel until position

One police deployed at position

Total

Original Problem Author: Bidhan; Problem Resource: HackerRank

## Comments

Does anyone know how I can optimize my code to get ?

https://codeforces.com/blog/entry/63823

took me a while to figure out the query/insert operations, but CHT is a really cool optimization technique!

Copy of a problem from the University of Chicago Invitational Programming Contest 2012: https://www.e-olymp.com/en/problems/3972

Yes and yes.