Statement
Statement language
castles stand in a row. The current height of castle is a positive integer .
The dwarf may change every height to any positive integer. Increasing the height of castle by one costs , and decreasing it by one costs .
Let the resulting heights be . The castles are harmonious if
for every . Find the minimum cost required to make the castles harmonious.
Input
The input is given in the following format:
Each case is given in the following format:
Output
For each test case, print the minimum cost modulo .
Constraints
- ()
- The sum of over all test cases does not exceed .
Subtasks
Samples
Input
2
2
1 1
1 1
1 1
3
1 2 3
5 5 5
7 7 7
Output
1
0