#C4402. Minimum Sum of Distances

    ID: 47937 Type: Default 1000ms 256MiB

Minimum Sum of Distances

Minimum Sum of Distances

You are given T test cases. For each test case, you are given two integers N and M on the first line and a list of N rental requests on the second line. The depot is located at position 1. Your task is to compute the minimum sum of distances from the depot to the rental locations. The distance between the depot and any given rental location p is given by the formula: $$|p-1|$$.

Note: The parameter M is provided but not used in the calculation.

inputFormat

The first line of the input contains an integer T, representing the number of test cases. Each test case consists of two lines:

  1. The first line contains two integers N and M, where N is the number of rental requests and M is an auxiliary parameter.
  2. The second line contains N space-separated integers, each representing a rental request.

All input should be read from standard input (stdin).

outputFormat

For each test case, output a single integer on a new line representing the minimum sum of distances from the depot (located at 1) to the requested locations. All output should be written to standard output (stdout).

## sample
2
3 5
3 3 1
4 3
2 3 3 2
4

6

</p>